merge hv v6, rework trace methods
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formattools.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010-2013 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "asset.h"
23 #include "bcsignals.h"
24 #include "clip.h"
25 #include "guicast.h"
26 #include "file.h"
27 #include "filesystem.h"
28 #include "formattools.h"
29 #include "language.h"
30 #include "libdv.h"
31 #include "libmjpeg.h"
32 #include "maxchannels.h"
33 #include "mwindow.h"
34 #include "preferences.h"
35 #include "theme.h"
36 #include "videodevice.inc"
37 #include <string.h>
38 #include <unistd.h>
39 #include <ctype.h>
40
41
42 FormatTools::FormatTools(MWindow *mwindow,
43                                 BC_WindowBase *window,
44                                 Asset *asset)
45 {
46         this->mwindow = mwindow;
47         this->window = window;
48         this->asset = asset;
49         this->plugindb = mwindow->plugindb;
50
51         aparams_button = 0;
52         vparams_button = 0;
53         aparams_thread = 0;
54         vparams_thread = 0;
55         channels_tumbler = 0;
56         audio_switch = 0;
57         video_switch = 0;
58         path_textbox = 0;
59         path_button = 0;
60         path_recent = 0;
61         format_title = 0;
62         format_button = 0;
63         format_text = 0;
64         audio_title = 0;
65         audio_switch = 0;
66         video_title = 0;
67         video_switch = 0;
68         channels_title = 0;
69         channels_button = 0;
70         multiple_files = 0;
71         file_entries = 0;
72         w = window->get_w();
73
74         recording = 0;
75         use_brender = 0;
76         do_audio = 0;
77         do_video = 0;
78         prompt_audio = 0;
79         prompt_audio_channels = 0;
80         prompt_video = 0;
81         prompt_video_compression = 0;
82         strategy = 0;
83         locked_compressor = 0;
84         video_driver = 0;
85 }
86
87 FormatTools::~FormatTools()
88 {
89         delete path_recent;
90 SET_TRACE
91         delete path_button;
92 SET_TRACE
93         delete path_textbox;
94 SET_TRACE
95         delete format_button;
96 SET_TRACE
97
98         if(aparams_button) delete aparams_button;
99 SET_TRACE
100         if(vparams_button) delete vparams_button;
101 SET_TRACE
102         if(aparams_thread) delete aparams_thread;
103 SET_TRACE
104         if(vparams_thread) delete vparams_thread;
105 SET_TRACE
106         if(channels_tumbler) delete channels_tumbler;
107 SET_TRACE
108         if(file_entries)
109         {
110                 file_entries->remove_all_objects();
111                 delete file_entries;
112         }
113 }
114
115 void FormatTools::create_objects(int &init_x,
116                                                 int &init_y,
117                                                 int do_audio,    // Include support for audio
118                                                 int do_video,   // Include support for video
119                                                 int prompt_audio,  // Include checkbox for audio
120                                                 int prompt_video,
121                                                 int prompt_audio_channels,
122                                                 int prompt_video_compression,
123                                                 const char *locked_compressor,
124                                                 int recording,
125                                                 int *strategy,
126                                                 int brender,
127                                                 int horizontal_layout)
128 {
129         int x = init_x;
130         int y = init_y;
131         int ylev = init_y;
132
133         this->locked_compressor = locked_compressor;
134         this->recording = recording;
135         this->use_brender = brender;
136         this->do_audio = do_audio;
137         this->do_video = do_video;
138         this->prompt_audio = prompt_audio;
139         this->prompt_audio_channels = prompt_audio_channels;
140         this->prompt_video = prompt_video;
141         this->prompt_video_compression = prompt_video_compression;
142         this->strategy = strategy;
143
144
145         file_entries = new ArrayList<BC_ListBoxItem*>;
146         FileSystem fs;
147         char string[BCTEXTLEN];
148 // Load current directory
149         fs.update(getcwd(string, BCTEXTLEN));
150         for(int i = 0; i < fs.total_files(); i++)
151         {
152                 file_entries->append(
153                         new BC_ListBoxItem(
154                                 fs.get_entry(i)->get_name()));
155         }
156
157 //printf("FormatTools::create_objects 1\n");
158
159 // Modify strategy depending on render farm
160         if(strategy)
161         {
162                 if(mwindow->preferences->use_renderfarm)
163                 {
164                         if(*strategy == FILE_PER_LABEL)
165                                 *strategy = FILE_PER_LABEL_FARM;
166                         else
167                         if(*strategy == SINGLE_PASS)
168                                 *strategy = SINGLE_PASS_FARM;
169                 }
170                 else
171                 {
172                         if(*strategy == FILE_PER_LABEL_FARM)
173                                 *strategy = FILE_PER_LABEL;
174                         else
175                         if(*strategy == SINGLE_PASS_FARM)
176                                 *strategy = SINGLE_PASS;
177                 }
178         }
179
180         if(!recording)
181         {
182                 int px = x;
183                 window->add_subwindow(path_textbox = new FormatPathText(px, y, this));
184                 px += path_textbox->get_w() + 5;
185                 path_recent = new BC_RecentList("PATH", mwindow->defaults,
186                                         path_textbox, 10, px, y, 300, 100);
187                 window->add_subwindow(path_recent);
188                 path_recent->load_items(File::formattostr(asset->format));
189                 px += path_recent->get_w() + 8;
190                 window->add_subwindow(path_button = new BrowseButton(
191                         mwindow->theme, window, path_textbox, px, y, asset->path,
192                         _("Output to file"), _("Select a file to write to:"), 0));
193
194 // Set w for user.
195                 w = MAX(w, 305);
196                 y += path_textbox->get_h() + 10;
197         }
198         else
199         {
200 //              w = x + 305;
201                 w = 305;
202         }
203
204         x = init_x;
205         window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
206         x += 90;
207         window->add_subwindow(format_text = new BC_TextBox(x, y, 160, 1,
208                 File::formattostr(asset->format)));
209         x += format_text->get_w();
210 //printf("FormatTools::create_objects %d %p\n", __LINE__, window);
211         window->add_subwindow(format_button = new FormatFormat(x, y, this));
212         format_button->create_objects();
213         x += format_button->get_w() + 5;
214         window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 64, 1, asset->fformat));
215         FFMPEG::set_asset_format(asset, asset->fformat);
216         x += ffmpeg_type->get_w();
217         window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this));
218         format_ffmpeg->create_objects();
219         x = init_x;
220         y += format_button->get_h() + 10;
221         if(do_audio)
222         {
223                 window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
224                 x += 80;
225                 window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
226                 x += aparams_button->get_w() + 10;
227                 if(prompt_audio)
228                 {
229                         window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
230                 }
231                 x = init_x;
232                 ylev = y;
233                 y += aparams_button->get_h() + 10;
234
235 // Audio channels only used for recording.
236 //              if(prompt_audio_channels)
237 //              {
238 //                      window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
239 //                      x += 260;
240 //                      window->add_subwindow(channels_button = new FormatChannels(x, y, this));
241 //                      x += channels_button->get_w() + 5;
242 //                      window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
243 //                      y += channels_button->get_h() + 20;
244 //                      x = init_x;
245 //              }
246
247 //printf("FormatTools::create_objects 6\n");
248                 aparams_thread = new FormatAThread(this);
249         }
250
251 //printf("FormatTools::create_objects 7\n");
252         if(do_video)
253         {
254                 if(horizontal_layout && do_audio){
255                         x += 370;
256                         y = ylev;
257                 }
258
259 //printf("FormatTools::create_objects 8\n");
260                 window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
261                 x += 80;
262                 if(prompt_video_compression)
263                 {
264                         window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
265                         x += vparams_button->get_w() + 10;
266                 }
267
268 //printf("FormatTools::create_objects 9\n");
269                 if(prompt_video)
270                 {
271                         window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
272                         y += video_switch->get_h();
273                 }
274                 else
275                 {
276                         y += vparams_button->get_h();
277                 }
278
279 //printf("FormatTools::create_objects 10\n");
280                 y += 10;
281                 vparams_thread = new FormatVThread(this);
282         }
283
284 //printf("FormatTools::create_objects 11\n");
285
286         x = init_x;
287         if(strategy)
288         {
289                 window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
290                 y += multiple_files->get_h() + 10;
291         }
292
293 //printf("FormatTools::create_objects 12\n");
294
295         init_y = y;
296         update_format();
297 }
298
299 void FormatTools::update_driver(int driver)
300 {
301         this->video_driver = driver;
302
303         locked_compressor = 0;
304         switch(driver)
305         {
306                 case CAPTURE_DVB:
307                 case VIDEO4LINUX2MPEG:
308 // Just give the user information about how the stream is going to be
309 // stored but don't change the asset.
310 // Want to be able to revert to user settings.
311                         if(asset->format == FILE_MPEG) break;
312                         asset->format = FILE_MPEG;
313                         format_text->update(File::formattostr(asset->format));
314                         asset->audio_data = 1;
315                         asset->video_data = 1;
316                         audio_switch->update(1);
317                         video_switch->update(1);
318                         break;
319
320                 case CAPTURE_IEC61883:
321                 case CAPTURE_FIREWIRE:
322                 case VIDEO4LINUX2JPEG:
323                 case CAPTURE_JPEG_WEBCAM:
324                         asset->format = FILE_FFMPEG;
325                         format_text->update(File::formattostr(asset->format));
326
327                         switch(driver) {
328                         case CAPTURE_IEC61883:
329                         case CAPTURE_FIREWIRE:
330                                 locked_compressor = (char*)CODEC_TAG_DVSD;
331                                 break;
332
333                         case VIDEO4LINUX2JPEG:
334                                 locked_compressor = (char*)CODEC_TAG_MJPEG;
335                                 break;
336
337                         case CAPTURE_JPEG_WEBCAM:
338                                 locked_compressor = (char*)CODEC_TAG_JPEG;
339                                 break;
340                         }
341                         if( locked_compressor )
342                                 strcpy(asset->vcodec, locked_compressor);
343
344                         audio_switch->update(asset->audio_data);
345                         video_switch->update(asset->video_data);
346                         break;
347
348                 default:
349                         format_text->update(File::formattostr(asset->format));
350                         audio_switch->update(asset->audio_data);
351                         video_switch->update(asset->video_data);
352                         break;
353         }
354         close_format_windows();
355         update_format();
356 }
357
358 void FormatTools::update_format()
359 {
360         if( do_audio && prompt_audio && audio_switch ) {
361                 audio_switch->update(asset->audio_data);
362                 if( !asset->audio_data )
363                         audio_switch->disable();
364                 else
365                         audio_switch->enable();
366         }
367         if( do_video && prompt_video && video_switch ) {
368                 video_switch->update(asset->video_data);
369                 if( !asset->video_data )
370                         video_switch->disable();
371                 else
372                         video_switch->enable();
373         }
374         if( asset->format == FILE_FFMPEG ) {
375                 ffmpeg_type->show();
376                 format_ffmpeg->show();
377         }
378         else {
379                 ffmpeg_type->hide();
380                 format_ffmpeg->hide();
381         }
382 }
383
384 int FormatTools::handle_event()
385 {
386         return 0;
387 }
388
389 Asset* FormatTools::get_asset()
390 {
391         return asset;
392 }
393
394 void FormatTools::update_extension()
395 {
396         const char *extension = File::get_tag(asset->format);
397 // split multiple extensions
398         ArrayList<const char*> extensions;
399         int len = !extension ? -1 : strlen(extension);
400         const char *extension_ptr = extension;
401         for(int i = 0; i <= len; i++)
402         {
403                 if(extension[i] == '/' || extension[i] == 0)
404                 {
405                         extensions.append(extension_ptr);
406                         extension_ptr = extension + i + 1;
407                 }
408         }
409
410         if(extensions.size())
411         {
412                 char *ptr = strrchr(asset->path, '.');
413                 if(!ptr)
414                 {
415                         ptr = asset->path + strlen(asset->path);
416                         *ptr = '.';
417                 }
418                 ptr++;
419
420 // test for equivalent extension
421                 int need_extension = 1;
422                 //int extension_len = 0;
423                 for(int i = 0; i < extensions.size() && need_extension; i++)
424                 {
425                         char *ptr1 = ptr;
426                         extension_ptr = extensions.get(i);
427 // test an extension
428                         need_extension = 0;
429                         while(*ptr1 != 0 && *extension_ptr != 0 && *extension_ptr != '/')
430                         {
431                                 if(tolower(*ptr1) != tolower(*extension_ptr))
432                                 {
433                                         need_extension = 1;
434                                         break;
435                                 }
436                                 ptr1++;
437                                 extension_ptr++;
438                         }
439
440                         if(*ptr1 == 0 &&
441                                 *extension_ptr != 0 &&
442                                 *extension_ptr != '/')
443                                 need_extension = 1;
444                 }
445
446 //printf("FormatTools::update_extension %d %d\n", __LINE__, need_extension);
447 // copy extension
448                 if(need_extension)
449                 {
450                         char *ptr1 = ptr;
451                         extension_ptr = asset->format != FILE_FFMPEG ?
452                                 extensions.get(0) : asset->fformat;
453                         while(*extension_ptr != 0 && *extension_ptr != '/')
454                                 *ptr1++ = *extension_ptr++;
455                         *ptr1 = 0;
456                 }
457
458                 int character1 = ptr - asset->path;
459                 int character2 = strlen(asset->path);
460 //              *(asset->path + character2) = 0;
461                 if(path_textbox)
462                 {
463                         path_textbox->update(asset->path);
464                         path_textbox->set_selection(character1, character2, character2);
465                 }
466         }
467 }
468
469 void FormatTools::update(Asset *asset, int *strategy)
470 {
471         this->asset = asset;
472         this->strategy = strategy;
473
474         if(path_textbox)
475                 path_textbox->update(asset->path);
476         format_text->update(File::formattostr(plugindb, asset->format));
477         if(do_audio && prompt_audio && audio_switch)
478                 audio_switch->update(asset->audio_data);
479         if(do_video && prompt_video && video_switch)
480                 video_switch->update(asset->video_data);
481         if(strategy)
482         {
483                 multiple_files->update(strategy);
484         }
485         close_format_windows();
486 }
487
488 void FormatTools::close_format_windows()
489 {
490 // This is done in ~file
491         if( aparams_thread ) {
492                 if( aparams_thread->running() )
493                         aparams_thread->file->close_window();
494                 aparams_thread->join();
495         }
496         if( vparams_thread ) {
497                 if( vparams_thread->running() )
498                         vparams_thread->file->close_window();
499                 vparams_thread->join();
500         }
501 }
502
503 int FormatTools::get_w()
504 {
505         return asset->format != FILE_FFMPEG ? w :
506                 format_ffmpeg->get_x() + format_ffmpeg->get_w();
507 }
508
509 void FormatTools::set_w(int w)
510 {
511         this->w = w;
512 }
513
514 void FormatTools::reposition_window(int &init_x, int &init_y)
515 {
516         int x = init_x;
517         int y = init_y;
518
519         if(path_textbox)
520         {
521                 int px = x;
522                 path_textbox->reposition_window(px, y);
523                 px += path_textbox->get_w() + 5;
524                 path_recent->reposition_window(px, y);
525                 px += path_recent->get_w() + 8;
526                 path_button->reposition_window(px, y);
527                 y += path_textbox->get_h() + 10;
528         }
529
530         format_title->reposition_window(x, y);
531         x += 90;
532         format_text->reposition_window(x, y);
533         x += format_text->get_w();
534         format_button->reposition_window(x, y);
535
536         x = init_x;
537         y += format_button->get_h() + 10;
538
539         if(do_audio)
540         {
541                 audio_title->reposition_window(x, y);
542                 x += 80;
543                 aparams_button->reposition_window(x, y);
544                 x += aparams_button->get_w() + 10;
545                 if(prompt_audio) audio_switch->reposition_window(x, y);
546
547                 x = init_x;
548                 y += aparams_button->get_h() + 10;
549                 if(prompt_audio_channels)
550                 {
551                         channels_title->reposition_window(x, y);
552                         x += 260;
553                         channels_button->reposition_window(x, y);
554                         x += channels_button->get_w() + 5;
555                         channels_tumbler->reposition_window(x, y);
556                         y += channels_button->get_h() + 20;
557                         x = init_x;
558                 }
559         }
560
561
562         if(do_video)
563         {
564                 video_title->reposition_window(x, y);
565                 x += 80;
566                 if(prompt_video_compression)
567                 {
568                         vparams_button->reposition_window(x, y);
569                         x += vparams_button->get_w() + 10;
570                 }
571
572                 if(prompt_video)
573                 {
574                         video_switch->reposition_window(x, y);
575                         y += video_switch->get_h();
576                 }
577                 else
578                 {
579                         y += vparams_button->get_h();
580                 }
581
582                 y += 10;
583                 x = init_x;
584         }
585
586         if(strategy)
587         {
588                 multiple_files->reposition_window(x, y);
589                 y += multiple_files->get_h() + 10;
590         }
591
592         init_y = y;
593 }
594
595
596 int FormatTools::set_audio_options()
597 {
598 //      if(video_driver == CAPTURE_DVB)
599 //      {
600 //              return 0;
601 //      }
602
603         if(!aparams_thread->running())
604         {
605                 aparams_thread->start();
606         }
607         else
608         {
609                 aparams_thread->file->raise_window();
610         }
611         return 0;
612 }
613
614 int FormatTools::set_video_options()
615 {
616 //      if(video_driver == CAPTURE_DVB)
617 //      {
618 //              return 0;
619 //      }
620
621         if(!vparams_thread->running())
622         {
623                 vparams_thread->start();
624         }
625         else
626         {
627                 vparams_thread->file->raise_window();
628         }
629
630         return 0;
631 }
632
633
634
635
636
637 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
638  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
639 {
640         this->format = format;
641         set_tooltip(_("Configure audio compression"));
642 }
643
644 FormatAParams::~FormatAParams()
645 {
646 }
647
648 int FormatAParams::handle_event()
649 {
650         format->set_audio_options();
651         return 1;
652 }
653
654
655
656
657
658 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
659  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
660 {
661         this->format = format;
662         set_tooltip(_("Configure video compression"));
663 }
664
665 FormatVParams::~FormatVParams()
666 {
667 }
668
669 int FormatVParams::handle_event()
670 {
671         format->set_video_options();
672         return 1;
673 }
674
675
676
677
678
679 FormatAThread::FormatAThread(FormatTools *format)
680  : Thread(1, 0, 0)
681 {
682         this->format = format;
683         file = new File;
684         joined = 1;
685 }
686
687 FormatAThread::~FormatAThread()
688 {
689         delete file;  file = 0;
690         join();
691 }
692
693 void FormatAThread::start()
694 {
695         join();
696         joined = 0;
697         Thread::start();
698 }
699
700
701 void FormatAThread::run()
702 {
703         file->get_options(format, 1, 0);
704 }
705
706
707
708
709 FormatVThread::FormatVThread(FormatTools *format)
710  : Thread(1, 0, 0)
711 {
712         this->format = format;
713         file = new File;
714         joined = 1;
715 }
716
717 FormatVThread::~FormatVThread()
718 {
719         delete file;  file = 0;
720         join();
721 }
722
723 void FormatVThread::start()
724 {
725         join();
726         joined = 0;
727         Thread::start();
728 }
729
730 void FormatVThread::run()
731 {
732         file->get_options(format, 0, 1);
733 }
734
735
736
737
738
739 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
740  : BC_TextBox(x, y, format->w - x -
741                 2*format->mwindow->theme->get_image_set("wrench")[0]->get_w() - 20, 1,
742         format->asset->path)
743 {
744         this->format = format;
745 }
746
747 FormatPathText::~FormatPathText()
748 {
749 }
750 int FormatPathText::handle_event()
751 {
752 // Suggestions
753         calculate_suggestions(format->file_entries);
754
755
756
757         strcpy(format->asset->path, get_text());
758         format->handle_event();
759         return 1;
760 }
761
762
763
764
765 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
766  : BC_CheckBox(x,
767         y,
768         default_,
769         (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
770 {
771         this->format = format;
772 }
773
774 FormatAudio::~FormatAudio() {}
775 int FormatAudio::handle_event()
776 {
777         format->asset->audio_data = get_value();
778         return 1;
779 }
780
781
782 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
783  : BC_CheckBox(x,
784         y,
785         default_,
786         (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
787 {
788 this->format = format;
789 }
790
791 FormatVideo::~FormatVideo() {}
792 int FormatVideo::handle_event()
793 {
794         format->asset->video_data = get_value();
795         return 1;
796 }
797
798
799
800
801 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
802  : FormatPopup(format->plugindb, x, y, format->use_brender)
803 {
804         this->format = format;
805 }
806
807 FormatFormat::~FormatFormat()
808 {
809 }
810
811 int FormatFormat::handle_event()
812 {
813         BC_ListBoxItem *selection = get_selection(0, 0);
814         if( selection ) {
815                 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
816 //              if(new_format != format->asset->format)
817                 {
818                         Asset *asset = format->asset;
819                         asset->format = new_format;
820                         asset->audio_data = File::supports_audio(asset->format);
821                         asset->video_data = File::supports_video(asset->format);
822                         asset->ff_audio_options[0] = 0;
823                         asset->ff_video_options[0] = 0;
824                         format->format_text->update(selection->get_text());
825                         format->update_extension();
826                         format->close_format_windows();
827                         if (format->path_recent) format->path_recent->
828                                 load_items(File::formattostr(format->asset->format));
829                         format->update_format();
830                 }
831         }
832         return 1;
833 }
834
835
836 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
837  : FFMPEGPopup(format->plugindb, x, y)
838 {
839         this->format = format;
840 }
841
842 FormatFFMPEG::~FormatFFMPEG()
843 {
844 }
845
846 int FormatFFMPEG::handle_event()
847 {
848         BC_ListBoxItem *selection = get_selection(0, 0);
849         if( selection ) {
850                 char *text = get_selection(0, 0)->get_text();
851                 format->ffmpeg_type->update(text);
852                 format->asset->ff_audio_options[0] = 0;
853                 format->asset->ff_video_options[0] = 0;
854                 FFMPEG::set_asset_format(format->asset, text);
855                 format->update_extension();
856                 format->close_format_windows();
857                 format->update_format();
858         }
859         return 1;
860 }
861
862
863
864
865 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
866  : BC_TextBox(x, y, 100, 1, format->asset->channels)
867 {
868         this->format = format;
869 }
870
871 FormatChannels::~FormatChannels()
872 {
873 }
874
875 int FormatChannels::handle_event()
876 {
877         format->asset->channels = atol(get_text());
878         return 1;
879 }
880
881
882 FormatToTracks::FormatToTracks(int x, int y, int *output)
883  : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
884 {
885         this->output = output;
886 }
887
888 FormatToTracks::~FormatToTracks()
889 {
890 }
891
892 int FormatToTracks::handle_event()
893 {
894         *output = get_value();
895         return 1;
896 }
897
898
899 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
900  : BC_CheckBox(x,
901         y,
902         (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
903         _("Create new file at each label"))
904 {
905         this->output = output;
906         this->mwindow = mwindow;
907 }
908
909 FormatMultiple::~FormatMultiple()
910 {
911 }
912
913 int FormatMultiple::handle_event()
914 {
915         if(get_value())
916         {
917                 if(mwindow->preferences->use_renderfarm)
918                         *output = FILE_PER_LABEL_FARM;
919                 else
920                         *output = FILE_PER_LABEL;
921         }
922         else
923         {
924                 if(mwindow->preferences->use_renderfarm)
925                         *output = SINGLE_PASS_FARM;
926                 else
927                         *output = SINGLE_PASS;
928         }
929         return 1;
930 }
931
932 void FormatMultiple::update(int *output)
933 {
934         this->output = output;
935         if(*output == FILE_PER_LABEL_FARM ||
936                 *output ==FILE_PER_LABEL)
937                 set_value(1);
938         else
939                 set_value(0);
940 }
941
942