7 // work around for __STDC_CONSTANT_MACROS
11 #include "bcwindowbase.h"
12 #include "bitspopup.h"
18 #include "fileffmpeg.h"
19 #include "filesystem.h"
20 #include "indexfile.h"
22 #include "mainerror.h"
23 #include "mainprogress.h"
25 #include "preferences.h"
26 #include "videodevice.inc"
32 FileFFMPEG::FileFFMPEG(Asset *asset, File *file)
33 : FileBase(asset, file)
36 if(asset->format == FILE_UNKNOWN)
37 asset->format = FILE_FFMPEG;
40 FileFFMPEG::~FileFFMPEG()
46 FFMpegConfigNum::FFMpegConfigNum(BC_Window *window,
47 int x, int y, char *title_text, int *output)
48 : BC_TumbleTextBox(window, *output, -1, INT_MAX, 100, y, 100)
50 this->window = window;
51 this->x = x; this->y = y;
52 this->title_text = title_text;
53 this->output = output;
56 FFMpegConfigNum::~FFMpegConfigNum()
60 void FFMpegConfigNum::create_objects()
62 window->add_subwindow(title = new BC_Title(x, y, title_text));
63 BC_TumbleTextBox::create_objects();
66 int FFMpegConfigNum::update_param(const char *param, const char *opts)
69 if( !FFMPEG::get_ff_option(param, opts, value) ) {
70 if( (*output = atoi(value)) < 0 ) {
75 BC_TumbleTextBox::update((int64_t)*output);
80 int FFMpegConfigNum::handle_event()
82 *output = atoi(get_text());
86 FFMpegAudioNum::FFMpegAudioNum(BC_Window *window,
87 int x, int y, char *title_text, int *output)
88 : FFMpegConfigNum(window, x, y, title_text, output)
92 int FFMpegAudioBitrate::handle_event()
94 int ret = FFMpegAudioNum::handle_event();
95 Asset *asset = window()->asset;
96 if( asset->ff_audio_bitrate > 0 )
97 window()->quality->disable();
98 else if( !window()->quality->get_textbox()->is_hidden() )
99 window()->quality->enable();
103 int FFMpegAudioQuality::handle_event()
105 int ret = FFMpegAudioNum::handle_event();
106 Asset *asset = window()->asset;
107 if( asset->ff_audio_quality >= 0 )
108 window()->bitrate->disable();
109 else if( !window()->bitrate->get_textbox()->is_hidden() )
110 window()->bitrate->enable();
114 FFMpegVideoNum::FFMpegVideoNum(BC_Window *window,
115 int x, int y, char *title_text, int *output)
116 : FFMpegConfigNum(window, x, y, title_text, output)
120 int FFMpegVideoBitrate::handle_event()
122 int ret = FFMpegVideoNum::handle_event();
123 Asset *asset = window()->asset;
124 if( asset->ff_video_bitrate > 0 )
125 window()->quality->disable();
126 else if( !window()->quality->get_textbox()->is_hidden() )
127 window()->quality->enable();
131 int FFMpegVideoQuality::handle_event()
133 int ret = FFMpegVideoNum::handle_event();
134 Asset *asset = window()->asset;
135 if( asset->ff_video_quality >= 0 )
136 window()->bitrate->disable();
137 else if( !window()->bitrate->get_textbox()->is_hidden() )
138 window()->bitrate->enable();
142 FFMpegPixelFormat::FFMpegPixelFormat(FFMPEGConfigVideo *vid_config,
143 int x, int y, int w, int list_h)
144 : BC_PopupTextBox(vid_config, 0, 0, x, y, w, list_h)
146 this->vid_config = vid_config;
149 int FFMpegPixelFormat::handle_event()
151 strncpy(vid_config->asset->ff_pixel_format, get_text(),
152 sizeof(vid_config->asset->ff_pixel_format));
156 void FFMpegPixelFormat::update_formats()
158 pixfmts.remove_all_objects();
159 char video_codec[BCSTRLEN]; video_codec[0] = 0;
160 const char *vcodec = vid_config->asset->vcodec;
161 AVCodec *av_codec = !FFMPEG::get_codec(video_codec, "video", vcodec) ?
162 avcodec_find_encoder_by_name(video_codec) : 0;
163 const AVPixelFormat *pix_fmts = av_codec ? av_codec->pix_fmts : 0;
165 for( int i=0; pix_fmts[i]>=0; ++i ) {
166 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmts[i]);
167 if( desc ) pixfmts.append(new BC_ListBoxItem(desc->name));
170 update_list(&pixfmts);
173 FFMpegSampleFormat::FFMpegSampleFormat(FFMPEGConfigAudio *aud_config,
174 int x, int y, int w, int list_h)
175 : BC_PopupTextBox(aud_config, 0, 0, x, y, w, list_h)
177 this->aud_config = aud_config;
180 int FFMpegSampleFormat::handle_event()
182 strncpy(aud_config->asset->ff_sample_format, get_text(),
183 sizeof(aud_config->asset->ff_sample_format));
187 void FFMpegSampleFormat::update_formats()
189 samplefmts.remove_all_objects();
190 char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
191 const char *acodec = aud_config->asset->acodec;
192 AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", acodec) ?
193 avcodec_find_encoder_by_name(audio_codec) : 0;
194 const AVSampleFormat *sample_fmts = av_codec ? av_codec->sample_fmts : 0;
196 for( int i=0; sample_fmts[i]>=0; ++i ) {
197 const char *name = av_get_sample_fmt_name(sample_fmts[i]);
198 if( name ) samplefmts.append(new BC_ListBoxItem(name));
201 update_list(&samplefmts);
204 void FileFFMPEG::set_options(char *cp, int len, const char *bp)
206 char *ep = cp + len-2, ch = 0;
207 while( cp < ep && *bp != 0 ) { ch = *bp++; *cp++ = ch; }
208 if( ch != '\n' ) *cp++ = '\n';
212 void FileFFMPEG::get_parameters(BC_WindowBase *parent_window,
213 Asset *asset, BC_WindowBase *&format_window,
214 int audio_options, int video_options, EDL *edl)
216 Asset *ff_asset = new Asset();
217 ff_asset->copy_from(asset, 0);
218 if( audio_options ) {
219 FFMPEGConfigAudio *window = new FFMPEGConfigAudio(parent_window, ff_asset, edl);
220 format_window = window;
221 window->create_objects();
222 if( !window->run_window() ) {
223 asset->copy_from(ff_asset,0);
224 set_options(asset->ff_audio_options,
225 sizeof(asset->ff_audio_options),
226 window->audio_options->get_text());
230 else if( video_options ) {
231 FFMPEGConfigVideo *window = new FFMPEGConfigVideo(parent_window, ff_asset, edl);
232 format_window = window;
233 window->create_objects();
234 if( !window->run_window() ) {
235 asset->copy_from(ff_asset,0);
236 set_options(asset->ff_video_options,
237 sizeof(asset->ff_video_options),
238 window->video_options->get_text());
242 ff_asset->remove_user();
245 int FileFFMPEG::check_sig(Asset *asset)
247 char *ptr = strstr(asset->path, ".pcm");
249 ptr = strstr(asset->path, ".raw");
253 int ret = !ffmpeg.init_decoder(asset->path) &&
254 !ffmpeg.open_decoder() ? 1 : 0;
258 void FileFFMPEG::get_info(char *path, char *text, int len)
262 cp += sprintf(cp, _("file path: %s\n"), path);
265 if( stat(path, &st) < 0 ) {
266 cp += sprintf(cp, _(" err: %s\n"), strerror(errno));
270 cp += sprintf(cp, _(" %jd bytes\n"), st.st_size);
272 if( !ret ) ret = ffmpeg.init_decoder(path);
273 if( !ret ) ret = ffmpeg.open_decoder();
275 cp += sprintf(cp, _("info:\n"));
276 ffmpeg.info(cp, len-(cp-text));
279 sprintf(cp, _("== open failed\n"));
282 int FileFFMPEG::get_video_info(int track, int &pid, double &framerate,
283 int &width, int &height, char *title)
286 pid = ff->ff_video_pid(track);
287 framerate = ff->ff_frame_rate(track);
288 width = ff->ff_video_width(track);
289 height = ff->ff_video_height(track);
290 if( title ) *title = 0;
294 int FileFFMPEG::get_audio_for_video(int vstream, int astream, int64_t &channel_mask)
297 return ff->ff_audio_for_video(vstream, astream, channel_mask);
300 int FileFFMPEG::select_video_stream(Asset *asset, int vstream)
302 if( !ff || !asset->video_data ) return 1;
303 asset->width = ff->ff_video_width(vstream);
304 asset->height = ff->ff_video_height(vstream);
305 if( (asset->video_length = ff->ff_video_frames(vstream)) < 2 )
306 asset->video_length = asset->video_length < 0 ? 0 : -1;
307 asset->frame_rate = ff->ff_frame_rate(vstream);
311 int FileFFMPEG::select_audio_stream(Asset *asset, int astream)
313 if( !ff || !asset->audio_data ) return 1;
314 asset->sample_rate = ff->ff_sample_rate(astream);
315 asset->audio_length = ff->ff_audio_samples(astream);
319 int FileFFMPEG::open_file(int rd, int wr)
323 ff = new FFMPEG(this);
326 result = ff->init_decoder(asset->path);
327 if( !result ) result = ff->open_decoder();
329 int audio_channels = ff->ff_total_audio_channels();
330 if( audio_channels > 0 ) {
331 asset->audio_data = 1;
332 asset->channels = audio_channels;
333 asset->sample_rate = ff->ff_sample_rate(0);
334 asset->audio_length = ff->ff_audio_samples(0);
335 strcpy(asset->acodec, ff->ff_audio_format(0));
337 int video_layers = ff->ff_total_video_layers();
338 if( video_layers > 0 ) {
339 asset->video_data = 1;
340 if( !asset->layers ) asset->layers = video_layers;
341 asset->actual_width = ff->ff_video_width(0);
342 asset->actual_height = ff->ff_video_height(0);
343 if( !asset->width ) asset->width = asset->actual_width;
344 if( !asset->height ) asset->height = asset->actual_height;
345 if( !asset->video_length &&
346 (asset->video_length = ff->ff_video_frames(0)) < 2 )
347 asset->video_length = asset->video_length < 0 ? 0 : -1;
348 if( !asset->frame_rate ) asset->frame_rate = ff->ff_frame_rate(0);
349 strcpy(asset->vcodec, ff->ff_video_format(0));
351 IndexState *index_state = asset->index_state;
352 index_state->read_markers(file->preferences->index_directory, asset->path);
356 result = ff->init_encoder(asset->path);
357 // must be in this order or dvdauthor will fail
358 if( !result && asset->video_data )
359 result = ff->open_encoder("video", asset->vcodec);
360 if( !result && asset->audio_data )
361 result = ff->open_encoder("audio", asset->acodec);
366 int FileFFMPEG::close_file()
374 int FileFFMPEG::write_samples(double **buffer, int64_t len)
376 if( !ff || len < 0 ) return -1;
378 int ret = ff->encode(stream, buffer, len);
382 int FileFFMPEG::write_frames(VFrame ***frames, int len)
385 int ret = 0, layer = 0;
386 for(int i = 0; i < 1; i++) {
387 for(int j = 0; j < len && !ret; j++) {
388 VFrame *frame = frames[i][j];
389 ret = ff->encode(layer, frame);
396 int FileFFMPEG::read_samples(double *buffer, int64_t len)
398 if( !ff || len < 0 ) return -1;
399 int ch = file->current_channel;
400 int64_t pos = file->current_sample;
401 int ret = ff->decode(ch, pos, buffer, len);
402 if( ret > 0 ) return 0;
403 memset(buffer,0,len*sizeof(*buffer));
407 int FileFFMPEG::read_frame(VFrame *frame)
410 int layer = file->current_layer;
411 int64_t pos = asset->video_length >= 0 ? file->current_frame : 0;
412 int ret = ff->decode(layer, pos, frame);
413 frame->set_status(ret);
414 if( ret >= 0 ) return 0;
415 frame->clear_frame();
420 int64_t FileFFMPEG::get_memory_usage()
425 int FileFFMPEG::colormodel_supported(int colormodel)
431 int FileFFMPEG::get_best_colormodel(int driver, int vstream)
433 if( vstream < 0 ) vstream = 0;
434 int is_mpeg = !ff ? 0 : ff->ff_video_mpeg_color_range(vstream);
438 case PLAYBACK_X11_GL: return is_mpeg ? BC_YUV888 : BC_RGB888;
439 case PLAYBACK_X11_XV: return BC_YUV420P;
445 int FileFFMPEG::get_best_colormodel(Asset *asset, int driver)
448 // the direct X11 color model requires scaling in the codec
451 case PLAYBACK_X11_GL: return BC_RGB888;
452 case PLAYBACK_X11_XV: return BC_YUV420P;
460 FFMPEGConfigAudio::FFMPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset, EDL *edl)
461 : BC_Window(_(PROGRAM_NAME ": Audio Preset"),
462 parent_window->get_abs_cursor_x(1),
463 parent_window->get_abs_cursor_y(1),
466 this->parent_window = parent_window;
473 ff_options_dialog = 0;
476 FFMPEGConfigAudio::~FFMPEGConfigAudio()
478 delete ff_options_dialog;
479 lock_window("FFMPEGConfigAudio::~FFMPEGConfigAudio");
481 presets.remove_all_objects();
485 void FFMPEGConfigAudio::load_options()
487 FFMPEG::load_audio_options(asset, edl);
490 void FFMPEGConfigAudio::create_objects()
493 lock_window("FFMPEGConfigAudio::create_objects");
496 char option_path[BCTEXTLEN];
497 FFMPEG::set_option_path(option_path, "audio");
498 fs.update(option_path);
499 int total_files = fs.total_files();
500 for(int i = 0; i < total_files; i++) {
501 const char *name = fs.get_entry(i)->get_name();
502 if( asset->fformat[0] != 0 ) {
503 const char *ext = strrchr(name,'.');
505 if( strcmp(asset->fformat, ++ext) ) continue;
507 presets.append(new BC_ListBoxItem(name));
510 if( asset->acodec[0] ) {
511 int k = presets.size();
512 while( --k >= 0 && strcmp(asset->acodec, presets[k]->get_text()) );
513 if( k < 0 ) asset->acodec[0] = 0;
516 if( !asset->acodec[0] && presets.size() > 0 )
517 strcpy(asset->acodec, presets[0]->get_text());
519 add_tool(new BC_Title(x, y, _("Preset:")));
521 preset_popup = new FFMPEGConfigAudioPopup(this, x, y);
522 preset_popup->create_objects();
525 bitrate = new FFMpegAudioBitrate(this, x, y, _("Bitrate:"), &asset->ff_audio_bitrate);
526 bitrate->create_objects();
527 bitrate->set_increment(1000);
528 bitrate->set_boundaries((int64_t)0, (int64_t)INT_MAX);
529 y += bitrate->get_h() + 5;
530 quality = new FFMpegAudioQuality(this, x, y, _("Quality:"), &asset->ff_audio_quality);
531 quality->create_objects();
532 quality->set_increment(1);
533 quality->set_boundaries((int64_t)-1, (int64_t)51);
534 y += quality->get_h() + 10;
536 add_subwindow(new BC_Title(x, y, _("Samples:")));
537 sample_format = new FFMpegSampleFormat(this, x+90, y, 100, 120);
538 sample_format->create_objects();
539 if( asset->acodec[0] ) {
540 sample_format->update_formats();
541 if( !asset->ff_audio_options[0] )
544 if( !asset->ff_sample_format[0] ) strcpy(asset->ff_sample_format, _("None"));
545 sample_format->update(asset->ff_sample_format);
546 y += sample_format->get_h() + 10;
548 BC_Title *title = new BC_Title(x, y, _("Audio Options:"));
549 add_subwindow(title);
551 ff_options_dialog = new FFOptionsAudioDialog(this);
552 int x1 = x + title->get_w() + 8;
553 add_subwindow(new FFOptionsViewAudio(this, x1, y, _("view")));
556 audio_options = new FFAudioOptions(this, x, y, get_w()-x-20, 8,
557 sizeof(asset->ff_audio_options)-1, asset->ff_audio_options);
558 audio_options->create_objects();
559 add_subwindow(new BC_OKButton(this));
560 add_subwindow(new BC_CancelButton(this));
563 bitrate->update_param("cin_bitrate", asset->ff_audio_options);
564 quality->update_param("cin_quality", asset->ff_audio_options);
566 if( asset->ff_audio_bitrate > 0 ) quality->disable();
567 else if( asset->ff_audio_quality >= 0 ) bitrate->disable();
572 int FFMPEGConfigAudio::close_event()
578 FFAudioOptions::FFAudioOptions(FFMPEGConfigAudio *audio_popup,
579 int x, int y, int w, int rows, int size, char *text)
580 : BC_ScrollTextBox(audio_popup, x, y, w, rows, text, size)
582 this->audio_popup = audio_popup;
586 FFMPEGConfigAudioPopup::FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y)
587 : BC_PopupTextBox(popup, &popup->presets, popup->asset->acodec, x, y, 300, 300)
592 int FFMPEGConfigAudioPopup::handle_event()
594 strcpy(popup->asset->acodec, get_text());
595 popup->sample_format->update_formats();
596 Asset *asset = popup->asset;
597 asset->ff_audio_bitrate = 0; asset->ff_audio_quality = -1;
598 popup->load_options();
599 popup->audio_options->update(asset->ff_audio_options);
600 popup->audio_options->set_text_row(0);
602 popup->bitrate->update_param("cin_bitrate", asset->ff_audio_options);
603 popup->quality->update_param("cin_quality", asset->ff_audio_options);
604 popup->sample_format->update(asset->ff_sample_format);
609 FFMPEGConfigAudioToggle::FFMPEGConfigAudioToggle(FFMPEGConfigAudio *popup,
610 char *title_text, int x, int y, int *output)
611 : BC_CheckBox(x, y, *output, title_text)
614 this->output = output;
616 int FFMPEGConfigAudioToggle::handle_event()
618 *output = get_value();
624 FFMPEGConfigVideo::FFMPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset, EDL *edl)
625 : BC_Window(_(PROGRAM_NAME ": Video Preset"),
626 parent_window->get_abs_cursor_x(1),
627 parent_window->get_abs_cursor_y(1),
630 this->parent_window = parent_window;
634 ff_options_dialog = 0;
642 FFMPEGConfigVideo::~FFMPEGConfigVideo()
644 lock_window("FFMPEGConfigVideo::~FFMPEGConfigVideo");
645 delete ff_options_dialog;
648 presets.remove_all_objects();
652 void FFMPEGConfigVideo::load_options()
654 FFMPEG::load_video_options(asset, edl);
657 void FFMPEGConfigVideo::create_objects()
660 lock_window("FFMPEGConfigVideo::create_objects");
662 add_subwindow(new BC_Title(x, y, _("Compression:")));
666 char option_path[BCTEXTLEN];
667 FFMPEG::set_option_path(option_path, "video");
668 fs.update(option_path);
669 int total_files = fs.total_files();
670 for(int i = 0; i < total_files; i++) {
671 const char *name = fs.get_entry(i)->get_name();
672 if( asset->fformat[0] != 0 ) {
673 const char *ext = strrchr(name,'.');
675 if( strcmp(asset->fformat, ++ext) ) continue;
677 presets.append(new BC_ListBoxItem(name));
680 if( asset->vcodec[0] ) {
681 int k = presets.size();
682 while( --k >= 0 && strcmp(asset->vcodec, presets[k]->get_text()) );
683 if( k < 0 ) asset->vcodec[0] = 0;
686 if( !asset->vcodec[0] && presets.size() > 0 )
687 strcpy(asset->vcodec, presets[0]->get_text());
689 preset_popup = new FFMPEGConfigVideoPopup(this, x, y);
690 preset_popup->create_objects();
692 if( asset->ff_video_bitrate > 0 && asset->ff_video_quality >= 0 ) {
693 asset->ff_video_bitrate = 0; asset->ff_video_quality = -1;
697 bitrate = new FFMpegVideoBitrate(this, x, y, _("Bitrate:"), &asset->ff_video_bitrate);
698 bitrate->create_objects();
699 bitrate->set_increment(100000);
700 bitrate->set_boundaries((int64_t)0, (int64_t)INT_MAX);
701 y += bitrate->get_h() + 5;
702 quality = new FFMpegVideoQuality(this, x, y, _("Quality:"), &asset->ff_video_quality);
703 quality->create_objects();
704 quality->set_increment(1);
705 quality->set_boundaries((int64_t)-1, (int64_t)51);
706 y += quality->get_h() + 10;
708 add_subwindow(new BC_Title(x, y, _("Pixels:")));
709 pixel_format = new FFMpegPixelFormat(this, x+90, y, 100, 120);
710 pixel_format->create_objects();
711 if( asset->vcodec[0] ) {
712 pixel_format->update_formats();
713 if( !asset->ff_video_options[0] )
716 if( !asset->ff_pixel_format[0] ) strcpy(asset->ff_pixel_format, _("None"));
717 pixel_format->update(asset->ff_pixel_format);
718 y += pixel_format->get_h() + 10;
720 BC_Title *title = new BC_Title(x, y, _("Video Options:"));
721 add_subwindow(title);
723 ff_options_dialog = new FFOptionsVideoDialog(this);
724 int x1 = x + title->get_w() + 8;
725 add_subwindow(new FFOptionsViewVideo(this, x1, y, _("view")));
728 video_options = new FFVideoOptions(this, x, y, get_w()-x-20, 8,
729 sizeof(asset->ff_video_options)-1, asset->ff_video_options);
730 video_options->create_objects();
731 add_subwindow(new BC_OKButton(this));
732 add_subwindow(new BC_CancelButton(this));
735 bitrate->update_param("cin_bitrate", asset->ff_video_options);
736 quality->update_param("cin_quality", asset->ff_video_options);
738 if( asset->ff_video_bitrate > 0 ) quality->disable();
739 else if( asset->ff_video_quality >= 0 ) bitrate->disable();
743 int FFMPEGConfigVideo::close_event()
749 FFVideoOptions::FFVideoOptions(FFMPEGConfigVideo *video_popup,
750 int x, int y, int w, int rows, int size, char *text)
751 : BC_ScrollTextBox(video_popup, x, y, w, rows, text, size)
753 this->video_popup = video_popup;
757 FFMPEGConfigVideoPopup::FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y)
758 : BC_PopupTextBox(popup, &popup->presets, popup->asset->vcodec, x, y, 300, 300)
763 int FFMPEGConfigVideoPopup::handle_event()
765 strcpy(popup->asset->vcodec, get_text());
766 popup->pixel_format->update_formats();
767 Asset *asset = popup->asset;
768 asset->ff_video_bitrate = 0; asset->ff_video_quality = -1;
769 popup->load_options();
770 popup->video_options->update(asset->ff_video_options);
771 popup->video_options->set_text_row(0);
773 popup->bitrate->update_param("cin_bitrate", asset->ff_video_options);
774 popup->quality->update_param("cin_quality", asset->ff_video_options);
775 popup->pixel_format->update(asset->ff_pixel_format);
780 FFMPEGConfigVideoToggle::FFMPEGConfigVideoToggle(FFMPEGConfigVideo *popup,
781 char *title_text, int x, int y, int *output)
782 : BC_CheckBox(x, y, *output, title_text)
785 this->output = output;
787 int FFMPEGConfigVideoToggle::handle_event()
789 *output = get_value();
793 FFMPEGScanProgress::FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
794 const char *title, int64_t length, int64_t *position, int *canceled)
797 this->index_file = index_file;
798 this->progress_bar = progress_bar;
799 strcpy(this->progress_title, title);
800 this->length = length;
801 this->position = position;
802 this->canceled = canceled;
807 FFMPEGScanProgress::~FFMPEGScanProgress()
814 void FFMPEGScanProgress::run()
817 if( progress_bar->update(*position) ) {
818 *canceled = done = 1;
821 index_file->redraw_edits(0);
826 int FileFFMPEG::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
829 if( !file->preferences->ffmpeg_marker_indexes ) return 1;
831 IndexState *index_state = index_file->get_state();
832 if( index_state->index_status != INDEX_NOTTESTED ) return 0;
833 index_state->reset_index();
834 index_state->reset_markers();
835 index_state->index_status = INDEX_BUILDING;
837 for( int aidx=0; aidx<ff->ffaudio.size(); ++aidx ) {
838 FFAudioStream *aud = ff->ffaudio[aidx];
839 index_state->add_audio_stream(aud->channels, aud->length);
843 int64_t file_bytes = fs.get_size(ff->fmt_ctx->url);
844 char *index_path = index_file->index_filename;
847 int64_t scan_position = 0;
848 FFMPEGScanProgress *scan_progress = 0;
850 char progress_title[BCTEXTLEN];
851 sprintf(progress_title, _("Creating %s\n"), index_path);
852 progress_bar->update_title(progress_title, 1);
853 progress_bar->update_length(file_bytes);
854 scan_progress = new FFMPEGScanProgress(index_file,
855 progress_bar, progress_title, file_bytes,
856 &scan_position, &canceled);
859 index_state->index_bytes = file_bytes;
860 index_state->init_scan(file->preferences->index_size);
862 if( ff->scan(index_state, &scan_position, &canceled) || canceled ) {
863 index_state->reset_index();
864 index_state->reset_markers();
868 delete scan_progress;
869 if( canceled ) return 1;
871 index_state->marker_status = MARKERS_READY;
872 return index_state->create_index(index_path, asset);
877 FFOptions_OptPanel(FFOptionsWindow *fwin, int x, int y, int w, int h)
878 : BC_ListBox(x, y, w, h, LISTBOX_TEXT), opts(items[0]), vals(items[1])
881 update(); // init col/wid/columns
885 ~FFOptions_OptPanel()
889 void FFOptions_OptPanel::create_objects()
891 const char *cols[] = { _("option"), _("value"), };
892 const int col1_w = 150;
893 int wids[] = { col1_w, get_w()-col1_w };
894 BC_ListBox::update(&items[0], &cols[0], &wids[0], sizeof(items)/sizeof(items[0]));
897 int FFOptions_OptPanel::update()
901 FFOptions &options = fwin->options;
902 for( int i=0; i<options.size(); ++i ) {
903 FFOptions_Opt *opt = options[i];
904 opts.append(opt->item_name);
905 vals.append(opt->item_value);
911 int FFOptions_OptPanel::cursor_leave_event()
918 FFOptions_OptName::FFOptions_OptName(FFOptions_Opt *opt, const char *nm)
924 FFOptions_OptName::~FFOptions_OptName()
928 FFOptions_OptValue::FFOptions_OptValue(FFOptions_Opt *opt)
934 void FFOptions_OptValue::update()
937 char val[BCTEXTLEN]; val[0] = 0;
938 opt->get(val, sizeof(val));
942 void FFOptions_OptValue::update(const char *v)
947 FFOptions_Opt::FFOptions_Opt(FFOptions *options, const AVOption *opt, const char *nm)
949 this->options = options;
951 item_name = new FFOptions_OptName(this, nm);
952 item_value = new FFOptions_OptValue(this);
955 FFOptions_Opt::~FFOptions_Opt()
961 char *FFOptions_Opt::get(char *vp, int sz)
965 if( !opt ) return cp;
967 void *obj = (void *)options->obj;
969 if( av_opt_get(obj, opt->name, 0, &bp) >= 0 && bp != 0 ) {
970 const char *val = (const char *)bp;
971 if( opt->unit && *val ) {
973 const char *uid = unit_name(id);
976 cp = sz >= 0 ? strncpy(vp,val,sz) : strcpy(vp, val);
977 if( sz > 0 ) vp[sz-1] = 0;
984 void FFOptions_Opt::set(const char *val)
986 void *obj = (void *)options->obj;
987 if( !obj || !opt ) return;
988 av_opt_set(obj, opt->name, val, 0);
992 FFOptionsKindItem::FFOptionsKindItem(FFOptionsKind *kind, const char *text, int idx)
999 FFOptionsKindItem::~FFOptionsKindItem()
1003 int FFOptionsKindItem::handle_event()
1005 FFOptionsWindow *fwin = kind->fwin;
1006 FFOptions &options = fwin->options;
1007 options.initialize(fwin, idx);
1012 const char *FFOptionsKind::kinds[] = {
1013 N_("codec"), // FF_KIND_CODEC
1014 N_("ffmpeg"), // FF_KIND_FFMPEG
1018 FFOptionsKind(FFOptionsWindow *fwin, int x, int y, int w)
1019 : BC_PopupMenu(x, y, w-calculate_w(0), "")
1029 void FFOptionsKind::create_objects()
1031 for( int i=0; i<(int)(sizeof(kinds)/sizeof(kinds[0])); ++i )
1032 add_item(new FFOptionsKindItem(this, _(kinds[i]), i));
1035 int FFOptionsKind::handle_event()
1040 void FFOptionsKind::set(int k)
1043 set_text(_(kinds[k]));
1047 FFOptionsText(FFOptionsWindow *fwin, int x, int y, int w)
1048 : BC_TextBox(x, y, w, 1, (char *)"")
1058 int FFOptionsText::handle_event()
1064 FFOptionsUnits(FFOptionsWindow *fwin, int x, int y, int w)
1065 : BC_PopupMenu(x, y, w, "")
1075 int FFOptionsUnits::handle_event()
1077 const char *text = get_text();
1078 if( text && fwin->selected ) {
1079 fwin->selected->set(text);
1080 fwin->selected->item_value->update();
1081 av_dict_set(&fwin->dialog->ff_opts,
1082 fwin->selected->item_name->get_text(),
1083 fwin->selected->item_value->get_text(), 0);
1090 FFOptionsApply(FFOptionsWindow *fwin, int x, int y)
1091 : BC_GenericButton(x, y, _("Apply"))
1101 int FFOptionsApply::handle_event()
1103 const char *text = fwin->text->get_text();
1104 if( text && fwin->selected ) {
1105 fwin->selected->set(text);
1106 fwin->selected->item_value->update();
1107 av_dict_set(&fwin->dialog->ff_opts,
1108 fwin->selected->item_name->get_text(),
1109 fwin->selected->item_value->get_text(), 0);
1115 FFOptions::FFOptions()
1121 FFOptions::~FFOptions()
1123 remove_all_objects();
1124 avcodec_free_context(&avctx);
1127 int FFOptions::cmpr(const void *a, const void *b)
1129 FFOptions_Opt *ap = *(FFOptions_Opt **)a;
1130 FFOptions_Opt *bp = *(FFOptions_Opt **)b;
1131 const char *vap = ap->item_name->get_text();
1132 const char *vbp = bp->item_name->get_text();
1133 return strcmp(vap, vbp);
1136 void FFOptions::initialize(FFOptionsWindow *win, int kind)
1138 remove_all_objects();
1143 avctx = avcodec_alloc_context3(win->dialog->codec);
1147 obj = (const void *)avctx->priv_data;
1149 case FF_KIND_FFMPEG:
1150 obj = (const void *)avctx;
1155 FFOptions &conf = *this;
1156 const AVOption *opt = 0;
1157 while( (opt=av_opt_next(obj, opt)) != 0 ) {
1158 if( opt->type == AV_OPT_TYPE_CONST ) continue;
1160 for( int i=0; !dupl && i<size(); ++i ) {
1161 FFOptions_Opt *fopt = conf[i];
1162 const AVOption *op = fopt->opt;
1163 if( op->offset != opt->offset ) continue;
1164 if( op->type != opt->type ) continue;
1166 if( strlen(op->name) < strlen(opt->name) )
1169 if( dupl ) continue;
1170 FFOptions_Opt *fopt = new FFOptions_Opt(this, opt, opt->name);
1172 AVDictionaryEntry *elem = av_dict_get(win->dialog->ff_opts,
1173 opt->name, 0, AV_DICT_IGNORE_SUFFIX);
1174 if( elem && elem->value ) fopt->set(elem->value);
1175 char val[BCTEXTLEN], *vp = fopt->get(val, sizeof(val));
1176 fopt->item_value->update(vp);
1180 qsort(&values[0],size(),sizeof(values[0]),cmpr);
1181 win->kind->set(kind);
1182 win->panel->update();
1183 win->panel->set_yposition(0);
1186 int FFOptions::update()
1189 FFOptions &conf = *this;
1191 for( int i=0; i<size(); ++i ) {
1192 FFOptions_Opt *fopt = conf[i];
1193 char val[BCTEXTLEN], *vp = fopt->get(val, sizeof(val));
1194 if( !vp || !strcmp(val, fopt->item_value->get_text()) ) continue;
1195 fopt->item_value->update(val);
1201 void FFOptions::dump(FILE *fp)
1204 const AVOption *opt = 0;
1205 FFOptions &conf = *this;
1207 while( (opt=av_opt_next(obj, opt)) != 0 ) {
1208 if( opt->type == AV_OPT_TYPE_CONST ) continue;
1210 while( --k >= 0 && strcmp(opt->name, conf[k]->opt->name) );
1211 if( k < 0 ) continue;
1212 FFOptions_Opt *fopt = conf[k];
1213 char val[BCTEXTLEN], *vp = fopt->get(val,sizeof(val));
1214 fprintf(fp, " %s:=%s", opt->name, vp);
1216 char unt[BCTEXTLEN], *up = unt;
1218 fprintf(fp, "%s", unt);
1225 void FFOptionsWindow::update(FFOptions_Opt *opt)
1227 if( selected != opt ) {
1228 if( selected ) selected->item_name->set_selected(0);
1230 if( selected ) selected->item_name->set_selected(1);
1232 clear_box(0,0, 0,panel->get_y());
1233 char str[BCTEXTLEN], *sp;
1235 if( opt ) opt->types(sp);
1238 if( opt ) opt->ranges(sp);
1240 while( units->total_items() ) units->del_item(0);
1241 char unit[BCSTRLEN]; strcpy(unit, "()");
1242 if( opt && opt->opt ) {
1243 ArrayList<const char *> names;
1245 if( opt->opt->unit ) {
1246 n = opt->units(names);
1247 if( n > 0 ) strcpy(unit,opt->opt->unit);
1249 for( int i=0; i<n; ++i )
1250 units->add_item(new BC_MenuItem(names[i], 0));
1252 units->set_text(unit);
1253 char val[BCTEXTLEN]; val[0] = 0;
1254 if( opt ) opt->get(val, sizeof(val));
1260 void FFOptions_OptPanel::show_tip(const char *tip)
1263 int len = strlen(tip);
1264 if( len > (int)sizeof(tip_text)-1 ) len = sizeof(tip_text)-1;
1265 strncpy(tip_text,tip,len);
1267 int line_limit = 60;
1268 int limit2 = line_limit/2;
1269 int limit4 = line_limit/4-2;
1270 char *cp = tip_text, *dp = cp+len;
1271 int n; char *bp, *ep, *pp, *sp;
1273 for( ep=cp; ep<dp && *ep!='\n'; ++ep );
1274 // target about half remaining line, constrain line_limit
1275 if( (n=(ep-1-cp)/2) < limit2 || n > line_limit )
1277 // search for last punct, last space before line_limit
1278 for( bp=cp, pp=sp=0; --n>=0 && cp<ep; ++cp ) {
1279 if( ispunct(*cp) && isspace(*(cp+1)) ) pp = cp;
1280 else if( isspace(*cp) ) sp = cp;
1284 // first, after punctuation
1285 if( pp && pp-bp >= limit4 )
1291 // last, on next space
1293 while( cp<dp && !isspace(*cp) ) ++cp;
1300 fwin->panel->set_tooltip(tip_text);
1301 fwin->panel->show_tooltip();
1304 int FFOptions_OptPanel::selection_changed()
1306 FFOptions_Opt *opt = 0;
1307 BC_ListBoxItem *item = get_selection(0, 0);
1309 FFOptions_OptName *opt_name = (FFOptions_OptName *)item;
1310 opt = opt_name->opt;
1313 if( opt ) show_tip(opt->tip());
1318 int FFOptions_Opt::types(char *rp)
1320 const char *cp = "";
1321 if( opt ) switch (opt->type) {
1322 case AV_OPT_TYPE_FLAGS: cp = N_("<flags>"); break;
1323 case AV_OPT_TYPE_INT: cp = N_("<int>"); break;
1324 case AV_OPT_TYPE_INT64: cp = N_("<int64>"); break;
1325 case AV_OPT_TYPE_DOUBLE: cp = N_("<double>"); break;
1326 case AV_OPT_TYPE_FLOAT: cp = N_("<float>"); break;
1327 case AV_OPT_TYPE_STRING: cp = N_("<string>"); break;
1328 case AV_OPT_TYPE_RATIONAL: cp = N_("<rational>"); break;
1329 case AV_OPT_TYPE_BINARY: cp = N_("<binary>"); break;
1330 case AV_OPT_TYPE_IMAGE_SIZE: cp = N_("<image_size>"); break;
1331 case AV_OPT_TYPE_VIDEO_RATE: cp = N_("<video_rate>"); break;
1332 case AV_OPT_TYPE_PIXEL_FMT: cp = N_("<pix_fmt>"); break;
1333 case AV_OPT_TYPE_SAMPLE_FMT: cp = N_("<sample_fmt>"); break;
1334 case AV_OPT_TYPE_DURATION: cp = N_("<duration>"); break;
1335 case AV_OPT_TYPE_COLOR: cp = N_("<color>"); break;
1336 case AV_OPT_TYPE_CHANNEL_LAYOUT: cp = N_("<channel_layout>"); break;
1337 case AV_OPT_TYPE_BOOL: cp = N_("<bool>"); break;
1338 default: cp = N_("<undef>"); break;
1340 return sprintf(rp, "%s", _(cp));
1342 int FFOptions_Opt::scalar(double d, char *rp)
1345 if( d == INT_MAX ) cp = "INT_MAX";
1346 else if( d == INT_MIN ) cp = "INT_MIN";
1347 else if( d == UINT32_MAX ) cp = "UINT32_MAX";
1348 else if( d == (double)INT64_MAX ) cp = "I64_MAX";
1349 else if( d == INT64_MIN ) cp = "I64_MIN";
1350 else if( d == FLT_MAX ) cp = "FLT_MAX";
1351 else if( d == FLT_MIN ) cp = "FLT_MIN";
1352 else if( d == -FLT_MAX ) cp = "-FLT_MAX";
1353 else if( d == -FLT_MIN ) cp = "-FLT_MIN";
1354 else if( d == DBL_MAX ) cp = "DBL_MAX";
1355 else if( d == DBL_MIN ) cp = "DBL_MIN";
1356 else if( d == -DBL_MAX ) cp = "-DBL_MAX";
1357 else if( d == -DBL_MIN ) cp = "-DBL_MIN";
1358 else if( d == 0 ) cp = signbit(d) ? "-0" : "0";
1359 else if( isnan(d) ) cp = signbit(d) ? "-NAN" : "NAN";
1360 else if( isinf(d) ) cp = signbit(d) ? "-INF" : "INF";
1361 else return sprintf(rp, "%g", d);
1362 return sprintf(rp, "%s", cp);
1365 int FFOptions_Opt::ranges(char *rp)
1367 if( !opt ) return 0;
1368 void *obj = (void *)options->obj;
1369 if( !obj ) return 0;
1371 switch (opt->type) {
1372 case AV_OPT_TYPE_INT:
1373 case AV_OPT_TYPE_INT64:
1374 case AV_OPT_TYPE_DOUBLE:
1375 case AV_OPT_TYPE_FLOAT: break;
1378 AVOptionRanges *r = 0;
1380 if( av_opt_query_ranges(&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) < 0 ) return 0;
1381 for( int i=0; i<r->nb_ranges; ++i ) {
1382 cp += sprintf(cp, " ("); cp += scalar(r->range[i]->value_min, cp);
1383 cp += sprintf(cp, ".."); cp += scalar(r->range[i]->value_max, cp);
1384 cp += sprintf(cp, ")");
1386 av_opt_freep_ranges(&r);
1390 int FFOptions_Opt::units(ArrayList<const char *> &names)
1392 if( !opt || !opt->unit ) return 0;
1393 const void *obj = options->obj;
1394 if( !obj ) return 0;
1396 ArrayList<const AVOption *> opts;
1397 const AVOption *opt = NULL;
1398 while( (opt=av_opt_next(obj, opt)) != 0 ) {
1399 if( !opt->unit ) continue;
1400 if( opt->type != AV_OPT_TYPE_CONST ) continue;
1401 if( strcmp(this->opt->unit, opt->unit) ) continue;
1402 int i = opts.size();
1404 if( opts[i]->default_val.i64 != opt->default_val.i64 ) continue;
1405 if( strlen(opts[i]->name) < strlen(opt->name) ) opts[i] = opt;
1408 if( i >= 0 ) continue;
1412 for( int i=0; i<opts.size(); ++i )
1413 names.append(opts[i]->name);
1415 return names.size();
1418 int FFOptions_Opt::units(char *rp)
1420 ArrayList<const char *> names;
1421 int n = units(names);
1424 cp += sprintf(cp, " [%s:", this->opt->unit);
1425 for( int i=0; i<n; ++i )
1426 cp += sprintf(cp, " %s", names[i]);
1427 cp += sprintf(cp, "]:");
1431 const char *FFOptions_Opt::unit_name(int id)
1433 if( !opt || !opt->unit ) return 0;
1434 const void *obj = options->obj;
1435 if( !obj ) return 0;
1437 const char *ret = 0;
1438 const AVOption *opt = NULL;
1439 while( (opt=av_opt_next(obj, opt)) != 0 ) {
1440 if( !opt->unit ) continue;
1441 if( opt->type != AV_OPT_TYPE_CONST ) continue;
1442 if( strcmp(this->opt->unit, opt->unit) ) continue;
1443 if( opt->default_val.i64 != id ) continue;
1444 if( !ret ) { ret = opt->name; continue; }
1445 if( strlen(ret) < strlen(opt->name) ) ret = opt->name;
1451 const char *FFOptions_Opt::tip()
1453 return !opt ? 0 : opt->help;
1457 FFOptionsWindow::FFOptionsWindow(FFOptionsDialog *dialog)
1458 : BC_Window(_(PROGRAM_NAME ": Options"), 60, 30, 640, 400)
1460 this->dialog = dialog;
1464 FFOptionsWindow::~FFOptionsWindow()
1468 void FFOptionsWindow::create_objects()
1471 int x0 = 10, y0 = 10;
1473 add_subwindow(title = new BC_Title(x, y, _("Format: ")));
1474 x += title->get_w();
1475 add_subwindow(new BC_Title(x, y, dialog->format_name));
1477 add_subwindow(title = new BC_Title(x, y, _("Codec: ")));
1478 x += title->get_w();
1479 add_subwindow(new BC_Title(x, y, dialog->codec_name));
1481 x = x0; y += title->get_h() + 10; y0 = y;
1482 add_subwindow(title = new BC_Title(x, y, _("Type: ")));
1483 x += title->get_w() + 8;
1484 add_subwindow(type = new BC_Title(x, y, (char *)""));
1486 add_subwindow(title = new BC_Title(x, y, _("Range: ")));
1487 x += title->get_w() + 8;
1488 add_subwindow(range = new BC_Title(x, y, (char *)""));
1490 x = x0; y += title->get_h() + 10;
1491 add_subwindow(units = new FFOptionsUnits(this, x, y, 120));
1492 x += units->get_w() + 8;
1493 int x1 = get_w() - BC_GenericButton::calculate_w(this, _("Apply")) - 8;
1494 add_subwindow(text = new FFOptionsText(this, x, y, x1-x - 8));
1495 add_subwindow(apply = new FFOptionsApply(this, x1, y));
1496 y += units->get_h() + 10;
1497 add_subwindow(kind = new FFOptionsKind(this, x1, y0, apply->get_w()));
1498 kind->create_objects();
1499 const char *kind_text = _("Kind:");
1500 x1 -= BC_Title::calculate_w(this, kind_text) + 8;
1501 add_subwindow(kind_title = new BC_Title(x1, y0, kind_text));
1504 panel_x = x0; panel_y = y0;
1505 panel_w = get_w()-10 - panel_x;
1506 panel_h = get_h()-10 - panel_y - BC_OKButton::calculate_h();
1507 panel = new FFOptions_OptPanel(this, panel_x, panel_y, panel_w, panel_h);
1508 add_subwindow(panel);
1509 add_subwindow(new BC_OKButton(this));
1510 add_subwindow(new BC_CancelButton(this));
1511 panel->create_objects();
1512 options.initialize(this, FF_KIND_CODEC);
1517 void FFOptionsWindow::draw()
1522 int FFOptionsWindow::resize_event(int w, int h)
1524 int x1 = w - 8 - kind->get_w();
1525 int y = kind->get_y();
1526 kind->reposition_window(x1, y);
1527 x1 -= kind_title->get_w() + 8;
1528 kind_title->reposition_window(x1,y);
1529 x1 = get_w() - apply->get_w() - 8;
1530 int y1 = units->get_y();
1531 apply->reposition_window(x1, y1);
1532 int x0 = units->get_x() + units->get_w() + 8;
1533 int y0 = units->get_y();
1534 text->reposition_window(x0,y0, x1-x0-8);
1535 panel_w = get_w()-10 - panel_x;
1536 panel_h = get_h()-10 - panel_y;
1537 panel->reposition_window(panel_x,panel_y, panel_w, panel_h);
1541 FFOptionsDialog::FFOptionsDialog()
1544 this->options_window = 0;
1545 this->codec_name = 0;
1551 FFOptionsDialog::~FFOptionsDialog()
1554 delete [] codec_name;
1557 void FFOptionsDialog::load_options(const char *bp, int len)
1559 char line[BCTEXTLEN];
1560 char key[BCSTRLEN], val[BCTEXTLEN];
1561 const char *dp = bp + len-1;
1563 while( bp < dp && *bp != 0 ) {
1565 char *cp = line, *ep = cp+sizeof(line)-1;
1566 while( *bp && cp<ep && (*cp=*bp++)!='\n' ) ++cp;
1568 if( line[0] == '#' ) {
1569 sprintf(key,"#%d", no);
1570 av_dict_set(&ff_opts, key, line, 0);
1573 if( line[0] == '\n' ) continue;
1574 if( FFMPEG::scan_option_line(line, key, val) ) continue;
1575 av_dict_set(&ff_opts, key, val, 0);
1579 void FFOptionsDialog::store_options(char *cp, int len)
1581 char *ep = cp + len-1;
1582 AVDictionaryEntry *elem = 0;
1583 while( (elem=av_dict_get(ff_opts, "", elem, AV_DICT_IGNORE_SUFFIX)) != 0 ) {
1584 if( elem->key[0] == '#' ) {
1585 cp += snprintf(cp,ep-cp, "%s\n", elem->value);
1588 cp += snprintf(cp,ep-cp, "%s=%s\n", elem->key, elem->value);
1593 void FFOptionsDialog::start(const char *format_name, const char *codec_name,
1594 AVCodec *codec, const char *options, int len)
1596 if( options_window ) {
1597 options_window->lock_window("FFOptionsDialog::start");
1598 options_window->raise_window();
1599 options_window->unlock_window();
1603 this->format_name = cstrdup(format_name);
1604 this->codec_name = cstrdup(codec_name);
1605 this->codec = codec;
1608 load_options(options, len);
1610 BC_DialogThread::start();
1613 BC_Window* FFOptionsDialog::new_gui()
1615 options_window = new FFOptionsWindow(this);
1616 options_window->create_objects();
1617 return options_window;
1620 void FFOptionsDialog::handle_done_event(int result)
1623 char options[ff_len];
1624 store_options(options, ff_len);
1625 update_options(options);
1628 delete [] format_name; format_name = 0;
1629 delete [] codec_name; codec_name = 0;
1630 av_dict_free(&ff_opts);
1633 FFOptionsAudioDialog::FFOptionsAudioDialog(FFMPEGConfigAudio *aud_config)
1635 this->aud_config = aud_config;
1638 FFOptionsAudioDialog::~FFOptionsAudioDialog()
1643 void FFOptionsAudioDialog::update_options(const char *options)
1645 aud_config->audio_options->update(options);
1648 FFOptionsVideoDialog::FFOptionsVideoDialog(FFMPEGConfigVideo *vid_config)
1650 this->vid_config = vid_config;
1653 FFOptionsVideoDialog::~FFOptionsVideoDialog()
1658 void FFOptionsVideoDialog::update_options(const char *options)
1660 vid_config->video_options->update(options);
1664 FFOptionsViewAudio::FFOptionsViewAudio(FFMPEGConfigAudio *aud_config, int x, int y, const char *text)
1665 : BC_GenericButton(x, y, text)
1667 this->aud_config = aud_config;
1670 FFOptionsViewAudio::~FFOptionsViewAudio()
1674 int FFOptionsViewAudio::handle_event()
1676 char audio_format[BCSTRLEN]; audio_format[0] = 0;
1677 char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
1679 Asset *asset = aud_config->asset;
1680 const char *name = asset->acodec;
1681 if( !FFMPEG::get_format(audio_format, "audio", name) &&
1682 !FFMPEG::get_codec(audio_codec, "audio", name) )
1683 codec = avcodec_find_encoder_by_name(audio_codec);
1685 eprintf(_("no codec named: %s: %s"), name, audio_codec);
1688 aud_config->ff_options_dialog->start(audio_format, audio_codec, codec,
1689 asset->ff_audio_options, sizeof(asset->ff_audio_options));
1693 FFOptionsViewVideo::FFOptionsViewVideo(FFMPEGConfigVideo *vid_config, int x, int y, const char *text)
1694 : BC_GenericButton(x, y, text)
1696 this->vid_config = vid_config;
1699 FFOptionsViewVideo::~FFOptionsViewVideo()
1703 int FFOptionsViewVideo::handle_event()
1705 char video_format[BCSTRLEN]; video_format[0] = 0;
1706 char video_codec[BCSTRLEN]; video_codec[0] = 0;
1708 Asset *asset = vid_config->asset;
1709 const char *name = asset->vcodec;
1710 if( !FFMPEG::get_format(video_format, "video", name) &&
1711 !FFMPEG::get_codec(video_codec, "video", name) )
1712 codec = avcodec_find_encoder_by_name(video_codec);
1714 eprintf(_("no codec named: %s: %s"), name, video_codec);
1717 vid_config->ff_options_dialog->start(video_format, video_codec, codec,
1718 asset->ff_video_options, sizeof(asset->ff_video_options));