added keyframe reticle, fixes: DEL, transition at endtrk, DVD/BD render menu
[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, 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, 180, 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+5, 50, 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+5, 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 CAPTURE_LML:
323                 case CAPTURE_BUZ:
324                 case VIDEO4LINUX2JPEG:
325                 case CAPTURE_JPEG_WEBCAM:
326                         asset->format = FILE_FFMPEG;
327                         format_text->update(File::formattostr(asset->format));
328
329                         switch(driver) {
330                         case CAPTURE_IEC61883:
331                         case CAPTURE_FIREWIRE:
332                                 locked_compressor = (char*)CODEC_TAG_DVSD;
333                                 break;
334
335                         case CAPTURE_BUZ:
336                         case CAPTURE_LML:
337                         case VIDEO4LINUX2JPEG:
338                                 locked_compressor = (char*)CODEC_TAG_MJPEG;
339                                 break;
340
341                         case CAPTURE_JPEG_WEBCAM:
342                                 locked_compressor = (char*)CODEC_TAG_JPEG;
343                                 break;
344                         }
345                         if( locked_compressor )
346                                 strcpy(asset->vcodec, locked_compressor);
347
348                         audio_switch->update(asset->audio_data);
349                         video_switch->update(asset->video_data);
350                         break;
351
352                 default:
353                         format_text->update(File::formattostr(asset->format));
354                         audio_switch->update(asset->audio_data);
355                         video_switch->update(asset->video_data);
356                         break;
357         }
358         close_format_windows();
359         update_format();
360 }
361
362 void FormatTools::update_format()
363 {
364         if( do_audio && prompt_audio && audio_switch ) {
365                 audio_switch->update(asset->audio_data);
366                 if( !asset->audio_data )
367                         audio_switch->disable();
368                 else
369                         audio_switch->enable();
370         }
371         if( do_video && prompt_video && video_switch ) {
372                 video_switch->update(asset->video_data);
373                 if( !asset->video_data )
374                         video_switch->disable();
375                 else
376                         video_switch->enable();
377         }
378         if( asset->format == FILE_FFMPEG ) {
379                 ffmpeg_type->show();
380                 format_ffmpeg->show();
381         }
382         else {
383                 ffmpeg_type->hide();
384                 format_ffmpeg->hide();
385         }
386 }
387
388 int FormatTools::handle_event()
389 {
390         return 0;
391 }
392
393 Asset* FormatTools::get_asset()
394 {
395         return asset;
396 }
397
398 void FormatTools::update_extension()
399 {
400         const char *extension = File::get_tag(asset->format);
401 // split multiple extensions
402         ArrayList<const char*> extensions;
403         int len = !extension ? -1 : strlen(extension);
404         const char *extension_ptr = extension;
405         for(int i = 0; i <= len; i++)
406         {
407                 if(extension[i] == '/' || extension[i] == 0)
408                 {
409                         extensions.append(extension_ptr);
410                         extension_ptr = extension + i + 1;
411                 }
412         }
413
414         if(extensions.size())
415         {
416                 char *ptr = strrchr(asset->path, '.');
417                 if(!ptr)
418                 {
419                         ptr = asset->path + strlen(asset->path);
420                         *ptr = '.';
421                 }
422                 ptr++;
423
424 // test for equivalent extension
425                 int need_extension = 1;
426                 //int extension_len = 0;
427                 for(int i = 0; i < extensions.size() && need_extension; i++)
428                 {
429                         char *ptr1 = ptr;
430                         extension_ptr = extensions.get(i);
431 // test an extension
432                         need_extension = 0;
433                         while(*ptr1 != 0 && *extension_ptr != 0 && *extension_ptr != '/')
434                         {
435                                 if(tolower(*ptr1) != tolower(*extension_ptr))
436                                 {
437                                         need_extension = 1;
438                                         break;
439                                 }
440                                 ptr1++;
441                                 extension_ptr++;
442                         }
443
444                         if(*ptr1 == 0 &&
445                                 *extension_ptr != 0 &&
446                                 *extension_ptr != '/')
447                                 need_extension = 1;
448                 }
449
450 //printf("FormatTools::update_extension %d %d\n", __LINE__, need_extension);
451 // copy extension
452                 if(need_extension)
453                 {
454                         char *ptr1 = ptr;
455                         extension_ptr = asset->format != FILE_FFMPEG ?
456                                 extensions.get(0) : asset->fformat;
457                         while(*extension_ptr != 0 && *extension_ptr != '/')
458                                 *ptr1++ = *extension_ptr++;
459                         *ptr1 = 0;
460                 }
461
462                 int character1 = ptr - asset->path;
463                 int character2 = strlen(asset->path);
464 //              *(asset->path + character2) = 0;
465                 if(path_textbox)
466                 {
467                         path_textbox->update(asset->path);
468                         path_textbox->set_selection(character1, character2, character2);
469                 }
470         }
471 }
472
473 void FormatTools::update(Asset *asset, int *strategy)
474 {
475         this->asset = asset;
476         this->strategy = strategy;
477
478         if(path_textbox)
479                 path_textbox->update(asset->path);
480         format_text->update(File::formattostr(plugindb, asset->format));
481         if(do_audio && prompt_audio && audio_switch)
482                 audio_switch->update(asset->audio_data);
483         if(do_video && prompt_video && video_switch)
484                 video_switch->update(asset->video_data);
485         if(strategy)
486         {
487                 multiple_files->update(strategy);
488         }
489         close_format_windows();
490 }
491
492 void FormatTools::close_format_windows()
493 {
494 // This is done in ~file
495         if( aparams_thread ) {
496                 if( aparams_thread->running() )
497                         aparams_thread->file->close_window();
498                 aparams_thread->join();
499         }
500         if( vparams_thread ) {
501                 if( vparams_thread->running() )
502                         vparams_thread->file->close_window();
503                 vparams_thread->join();
504         }
505 }
506
507 int FormatTools::get_w()
508 {
509         return asset->format != FILE_FFMPEG ? w :
510                 format_ffmpeg->get_x() + format_ffmpeg->get_w();
511 }
512
513 void FormatTools::set_w(int w)
514 {
515         this->w = w;
516 }
517
518 void FormatTools::reposition_window(int &init_x, int &init_y)
519 {
520         int x = init_x;
521         int y = init_y;
522
523         if(path_textbox)
524         {
525                 int px = x;
526                 path_textbox->reposition_window(px, y);
527                 px += path_textbox->get_w() + 5;
528                 path_recent->reposition_window(px, y);
529                 px += path_recent->get_w() + 8;
530                 path_button->reposition_window(px, y);
531                 y += path_textbox->get_h() + 10;
532         }
533
534         format_title->reposition_window(x, y);
535         x += 90;
536         format_text->reposition_window(x, y);
537         x += format_text->get_w();
538         format_button->reposition_window(x, y);
539
540         x = init_x;
541         y += format_button->get_h() + 10;
542
543         if(do_audio)
544         {
545                 audio_title->reposition_window(x, y);
546                 x += 80;
547                 aparams_button->reposition_window(x, y);
548                 x += aparams_button->get_w() + 10;
549                 if(prompt_audio) audio_switch->reposition_window(x, y);
550
551                 x = init_x;
552                 y += aparams_button->get_h() + 10;
553                 if(prompt_audio_channels)
554                 {
555                         channels_title->reposition_window(x, y);
556                         x += 260;
557                         channels_button->reposition_window(x, y);
558                         x += channels_button->get_w() + 5;
559                         channels_tumbler->reposition_window(x, y);
560                         y += channels_button->get_h() + 20;
561                         x = init_x;
562                 }
563         }
564
565
566         if(do_video)
567         {
568                 video_title->reposition_window(x, y);
569                 x += 80;
570                 if(prompt_video_compression)
571                 {
572                         vparams_button->reposition_window(x, y);
573                         x += vparams_button->get_w() + 10;
574                 }
575
576                 if(prompt_video)
577                 {
578                         video_switch->reposition_window(x, y);
579                         y += video_switch->get_h();
580                 }
581                 else
582                 {
583                         y += vparams_button->get_h();
584                 }
585
586                 y += 10;
587                 x = init_x;
588         }
589
590         if(strategy)
591         {
592                 multiple_files->reposition_window(x, y);
593                 y += multiple_files->get_h() + 10;
594         }
595
596         init_y = y;
597 }
598
599
600 int FormatTools::set_audio_options()
601 {
602 //      if(video_driver == CAPTURE_DVB)
603 //      {
604 //              return 0;
605 //      }
606
607         if(!aparams_thread->running())
608         {
609                 aparams_thread->start();
610         }
611         else
612         {
613                 aparams_thread->file->raise_window();
614         }
615         return 0;
616 }
617
618 int FormatTools::set_video_options()
619 {
620 //      if(video_driver == CAPTURE_DVB)
621 //      {
622 //              return 0;
623 //      }
624
625         if(!vparams_thread->running())
626         {
627                 vparams_thread->start();
628         }
629         else
630         {
631                 vparams_thread->file->raise_window();
632         }
633
634         return 0;
635 }
636
637
638
639
640
641 FormatAParams::FormatAParams(MWindow *mwindow, FormatTools *format, int x, int y)
642  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
643 {
644         this->format = format;
645         set_tooltip(_("Configure audio compression"));
646 }
647
648 FormatAParams::~FormatAParams()
649 {
650 }
651
652 int FormatAParams::handle_event()
653 {
654         format->set_audio_options();
655         return 1;
656 }
657
658
659
660
661
662 FormatVParams::FormatVParams(MWindow *mwindow, FormatTools *format, int x, int y)
663  : BC_Button(x, y, mwindow->theme->get_image_set("wrench"))
664 {
665         this->format = format;
666         set_tooltip(_("Configure video compression"));
667 }
668
669 FormatVParams::~FormatVParams()
670 {
671 }
672
673 int FormatVParams::handle_event()
674 {
675         format->set_video_options();
676         return 1;
677 }
678
679
680
681
682
683 FormatAThread::FormatAThread(FormatTools *format)
684  : Thread(1, 0, 0)
685 {
686         this->format = format;
687         file = new File;
688         joined = 1;
689 }
690
691 FormatAThread::~FormatAThread()
692 {
693         join();
694         delete file;
695         file = 0;
696 }
697
698 void FormatAThread::start()
699 {
700         join();
701         joined = 0;
702         Thread::start();
703 }
704
705
706 void FormatAThread::run()
707 {
708         file->get_options(format, 1, 0);
709 }
710
711
712
713
714 FormatVThread::FormatVThread(FormatTools *format)
715  : Thread(1, 0, 0)
716 {
717         this->format = format;
718         file = new File;
719         joined = 1;
720 }
721
722 FormatVThread::~FormatVThread()
723 {
724         join();
725         delete file;
726         file = 0;
727 }
728
729 void FormatVThread::start()
730 {
731         join();
732         joined = 0;
733         Thread::start();
734 }
735
736 void FormatVThread::run()
737 {
738         file->get_options(format, 0, 1);
739 }
740
741
742
743
744
745 FormatPathText::FormatPathText(int x, int y, FormatTools *format)
746  : BC_TextBox(x, y, format->w - x -
747                 2*format->mwindow->theme->get_image_set("wrench")[0]->get_w() - 20, 1,
748         format->asset->path)
749 {
750         this->format = format;
751 }
752
753 FormatPathText::~FormatPathText()
754 {
755 }
756 int FormatPathText::handle_event()
757 {
758 // Suggestions
759         calculate_suggestions(format->file_entries);
760
761
762
763         strcpy(format->asset->path, get_text());
764         format->handle_event();
765         return 1;
766 }
767
768
769
770
771 FormatAudio::FormatAudio(int x, int y, FormatTools *format, int default_)
772  : BC_CheckBox(x,
773         y,
774         default_,
775         (char*)(format->recording ? _("Record audio tracks") : _("Render audio tracks")))
776 {
777         this->format = format;
778 }
779
780 FormatAudio::~FormatAudio() {}
781 int FormatAudio::handle_event()
782 {
783         format->asset->audio_data = get_value();
784         return 1;
785 }
786
787
788 FormatVideo::FormatVideo(int x, int y, FormatTools *format, int default_)
789  : BC_CheckBox(x,
790         y,
791         default_,
792         (char*)(format->recording ? _("Record video tracks") : _("Render video tracks")))
793 {
794 this->format = format;
795 }
796
797 FormatVideo::~FormatVideo() {}
798 int FormatVideo::handle_event()
799 {
800         format->asset->video_data = get_value();
801         return 1;
802 }
803
804
805
806
807 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
808  : FormatPopup(format->plugindb, x, y, format->use_brender)
809 {
810         this->format = format;
811 }
812
813 FormatFormat::~FormatFormat()
814 {
815 }
816
817 int FormatFormat::handle_event()
818 {
819         BC_ListBoxItem *selection = get_selection(0, 0);
820         if( selection ) {
821                 int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
822 //              if(new_format != format->asset->format)
823                 {
824                         Asset *asset = format->asset;
825                         asset->format = new_format;
826                         asset->audio_data = File::supports_audio(asset->format);
827                         asset->video_data = File::supports_video(asset->format);
828                         asset->ff_audio_options[0] = 0;
829                         asset->ff_video_options[0] = 0;
830                         format->format_text->update(selection->get_text());
831                         format->update_extension();
832                         format->close_format_windows();
833                         if (format->path_recent) format->path_recent->
834                                 load_items(File::formattostr(format->asset->format));
835                         format->update_format();
836                 }
837         }
838         return 1;
839 }
840
841
842 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
843  : FFMPEGPopup(format->plugindb, x, y)
844 {
845         this->format = format;
846 }
847
848 FormatFFMPEG::~FormatFFMPEG()
849 {
850 }
851
852 int FormatFFMPEG::handle_event()
853 {
854         BC_ListBoxItem *selection = get_selection(0, 0);
855         if( selection ) {
856                 char *text = get_selection(0, 0)->get_text();
857                 format->ffmpeg_type->update(text);
858                 format->asset->ff_audio_options[0] = 0;
859                 format->asset->ff_video_options[0] = 0;
860                 FFMPEG::set_asset_format(format->asset, text);
861                 format->update_extension();
862                 format->close_format_windows();
863                 format->update_format();
864         }
865         return 1;
866 }
867
868
869
870
871 FormatChannels::FormatChannels(int x, int y, FormatTools *format)
872  : BC_TextBox(x, y, 100, 1, format->asset->channels)
873 {
874         this->format = format;
875 }
876
877 FormatChannels::~FormatChannels()
878 {
879 }
880
881 int FormatChannels::handle_event()
882 {
883         format->asset->channels = atol(get_text());
884         return 1;
885 }
886
887
888 FormatToTracks::FormatToTracks(int x, int y, int *output)
889  : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
890 {
891         this->output = output;
892 }
893
894 FormatToTracks::~FormatToTracks()
895 {
896 }
897
898 int FormatToTracks::handle_event()
899 {
900         *output = get_value();
901         return 1;
902 }
903
904
905 FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
906  : BC_CheckBox(x,
907         y,
908         (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
909         _("Create new file at each label"))
910 {
911         this->output = output;
912         this->mwindow = mwindow;
913 }
914
915 FormatMultiple::~FormatMultiple()
916 {
917 }
918
919 int FormatMultiple::handle_event()
920 {
921         if(get_value())
922         {
923                 if(mwindow->preferences->use_renderfarm)
924                         *output = FILE_PER_LABEL_FARM;
925                 else
926                         *output = FILE_PER_LABEL;
927         }
928         else
929         {
930                 if(mwindow->preferences->use_renderfarm)
931                         *output = SINGLE_PASS_FARM;
932                 else
933                         *output = SINGLE_PASS;
934         }
935         return 1;
936 }
937
938 void FormatMultiple::update(int *output)
939 {
940         this->output = output;
941         if(*output == FILE_PER_LABEL_FARM ||
942                 *output ==FILE_PER_LABEL)
943                 set_value(1);
944         else
945                 set_value(0);
946 }
947
948