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