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