X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffileffmpeg.C;h=494844c3de02219580c9e49a260e988b5d41d39d;hb=29cc4023b50d6f7f9ab518978d8c9e839832b900;hp=9ac47e56b18001e19619176831094b2f855e586d;hpb=a9bdd58fae360fa33d27caa059f5ca2c6fa26cd4;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index 9ac47e56..494844c3 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -112,14 +112,16 @@ void FileFFMPEG::get_parameters(BC_WindowBase *parent_window, FFMPEGConfigAudio *window = new FFMPEGConfigAudio(parent_window, asset); format_window = window; window->create_objects(); - window->run_window(); + if( !window->run_window() ) + strcpy(asset->ff_audio_options, window->audio_options->get_text()); delete window; } else if(video_options) { FFMPEGConfigVideo *window = new FFMPEGConfigVideo(parent_window, asset); format_window = window; window->create_objects(); - window->run_window(); + if( !window->run_window() ) + strcpy(asset->ff_video_options, window->video_options->get_text()); delete window; } } @@ -396,10 +398,12 @@ void FFMPEGConfigAudio::create_objects() FFMPEG::load_options(option_path, asset->ff_audio_options, sizeof(asset->ff_audio_options)); } + audio_options = new FFAudioOptions(this, x, y, get_w()-x-20, 10, sizeof(asset->ff_audio_options)-1, asset->ff_audio_options); audio_options->create_objects(); add_subwindow(new BC_OKButton(this)); + add_subwindow(new BC_CancelButton(this)); show_window(1); bitrate->handle_event(); @@ -408,15 +412,10 @@ void FFMPEGConfigAudio::create_objects() int FFMPEGConfigAudio::close_event() { - set_done(0); + set_done(1); return 1; } -void FFMPEGConfigAudio::update_options() -{ - audio_options->update(asset->ff_audio_options); -} - FFAudioOptions::FFAudioOptions(FFMPEGConfigAudio *audio_popup, int x, int y, int w, int rows, int size, char *text) : BC_ScrollTextBox(audio_popup, x, y, w, rows, text, size) @@ -557,8 +556,9 @@ void FFMPEGConfigVideo::create_objects() video_options = new FFVideoOptions(this, x, y, get_w()-x-20, 10, sizeof(asset->ff_video_options)-1, asset->ff_video_options); video_options->create_objects(); - add_subwindow(new BC_OKButton(this)); + add_subwindow(new BC_CancelButton(this)); + show_window(1); if( asset->ff_video_bitrate ) quality->disable(); @@ -569,15 +569,10 @@ void FFMPEGConfigVideo::create_objects() int FFMPEGConfigVideo::close_event() { - set_done(0); + set_done(1); return 1; } -void FFMPEGConfigVideo::update_options() -{ - video_options->update(asset->ff_video_options); -} - FFVideoOptions::FFVideoOptions(FFMPEGConfigVideo *video_popup, int x, int y, int w, int rows, int size, char *text) : BC_ScrollTextBox(video_popup, x, y, w, rows, text, size) @@ -1299,23 +1294,30 @@ FFOptionsWindow::~FFOptionsWindow() void FFOptionsWindow::create_objects() { BC_Title *title; - int x = 10, y = 10; - add_subwindow(title = new BC_Title(x, y, dialog->codec_name)); - y += title->get_h() + 10; - int x0 = x, y0 = y; - add_subwindow(title = new BC_Title(x0, y0, _("Type: "))); - x0 += title->get_w() + 8; - add_subwindow(type = new BC_Title(x0, y0, (char *)"")); - x0 = x + 150; - add_subwindow(title = new BC_Title(x0, y0, _("Range: "))); - x0 += title->get_w() + 8; - add_subwindow(range = new BC_Title(x0, y0, (char *)"")); - x0 = x; - y += title->get_h() + 10; - add_subwindow(units = new FFOptionsUnits(this, x0, y, 120)); - x0 += units->get_w() + 8; + int x0 = 10, y0 = 10; + int x = x0, y = y0; + add_subwindow(title = new BC_Title(x, y, _("Format: "))); + x += title->get_w(); + add_subwindow(new BC_Title(x, y, dialog->format_name)); + x = x0 + 150; + add_subwindow(title = new BC_Title(x, y, _("Codec: "))); + x += title->get_w(); + add_subwindow(new BC_Title(x, y, dialog->codec_name)); + + x = x0; y += title->get_h() + 10; y0 = y; + add_subwindow(title = new BC_Title(x, y, _("Type: "))); + x += title->get_w() + 8; + add_subwindow(type = new BC_Title(x, y, (char *)"")); + x = x0 + 150; + add_subwindow(title = new BC_Title(x, y, _("Range: "))); + x += title->get_w() + 8; + add_subwindow(range = new BC_Title(x, y, (char *)"")); + + x = x0; y += title->get_h() + 10; + add_subwindow(units = new FFOptionsUnits(this, x, y, 120)); + x += units->get_w() + 8; int x1 = get_w() - BC_GenericButton::calculate_w(this, _("Apply")) - 8; - add_subwindow(text = new FFOptionsText(this, x0, y, x1-x0 - 8)); + add_subwindow(text = new FFOptionsText(this, x, y, x1-x - 8)); add_subwindow(apply = new FFOptionsApply(this, x1, y)); y += units->get_h() + 10; add_subwindow(kind = new FFOptionsKind(this, x1, y0, apply->get_w())); @@ -1323,8 +1325,9 @@ void FFOptionsWindow::create_objects() const char *kind_text = _("Kind:"); x1 -= BC_Title::calculate_w(this, kind_text) + 8; add_subwindow(kind_title = new BC_Title(x1, y0, kind_text)); + y0 = y; - panel_x = x; panel_y = y; + panel_x = x0; panel_y = y0; panel_w = get_w()-10 - panel_x; panel_h = get_h()-10 - panel_y - BC_OKButton::calculate_h(); panel = new FFOptions_OptPanel(this, panel_x, panel_y, panel_w, panel_h); @@ -1367,9 +1370,8 @@ FFOptionsDialog::FFOptionsDialog() this->options_window = 0; this->codec_name = 0; this->codec = 0; - this->ff_options = 0; - this->ff_len = 0; this->ff_opts = 0; + this->ff_len = 0; } FFOptionsDialog::~FFOptionsDialog() @@ -1378,11 +1380,11 @@ FFOptionsDialog::~FFOptionsDialog() delete [] codec_name; } -void FFOptionsDialog::load_options() +void FFOptionsDialog::load_options(const char *bp, int len) { char line[BCTEXTLEN]; char key[BCSTRLEN], val[BCTEXTLEN]; - char *bp = ff_options, *dp = bp + ff_len-1; + const char *dp = bp + len-1; int no = 0; while( bp < dp && *bp != 0 ) { ++no; @@ -1400,9 +1402,9 @@ void FFOptionsDialog::load_options() } } -void FFOptionsDialog::store_options() +void FFOptionsDialog::store_options(char *cp, int len) { - char *cp = ff_options, *ep = cp + ff_len-1; + char *ep = cp + len-1; AVDictionaryEntry *elem = 0; while( (elem=av_dict_get(ff_opts, "", elem, AV_DICT_IGNORE_SUFFIX)) != 0 ) { if( elem->key[0] == '#' ) { @@ -1414,7 +1416,8 @@ void FFOptionsDialog::store_options() *cp = 0; } -void FFOptionsDialog::start(const char *codec_name, AVCodec *codec, char *options, int len) +void FFOptionsDialog::start(const char *format_name, const char *codec_name, + AVCodec *codec, const char *options, int len) { if( options_window ) { options_window->lock_window("FFOptionsDialog::start"); @@ -1423,12 +1426,12 @@ void FFOptionsDialog::start(const char *codec_name, AVCodec *codec, char *option return; } + this->format_name = cstrdup(format_name); this->codec_name = cstrdup(codec_name); this->codec = codec; this->ff_opts = 0; - this->ff_options = options; this->ff_len = len; - load_options(); + load_options(options, len); BC_DialogThread::start(); } @@ -1443,10 +1446,12 @@ BC_Window* FFOptionsDialog::new_gui() void FFOptionsDialog::handle_done_event(int result) { if( !result ) { - store_options(); - update_options(); + char options[ff_len]; + store_options(options, ff_len); + update_options(options); } options_window = 0; + delete [] format_name; format_name = 0; delete [] codec_name; codec_name = 0; av_dict_free(&ff_opts); } @@ -1461,9 +1466,9 @@ FFOptionsAudioDialog::~FFOptionsAudioDialog() close_window(); } -void FFOptionsAudioDialog::update_options() +void FFOptionsAudioDialog::update_options(const char *options) { - aud_config->update_options(); + aud_config->audio_options->update(options); } FFOptionsVideoDialog::FFOptionsVideoDialog(FFMPEGConfigVideo *vid_config) @@ -1476,9 +1481,9 @@ FFOptionsVideoDialog::~FFOptionsVideoDialog() close_window(); } -void FFOptionsVideoDialog::update_options() +void FFOptionsVideoDialog::update_options(const char *options) { - vid_config->update_options(); + vid_config->video_options->update(options); } @@ -1494,18 +1499,20 @@ FFOptionsViewAudio::~FFOptionsViewAudio() int FFOptionsViewAudio::handle_event() { - AVCodec *codec = 0; + char audio_format[BCSTRLEN]; audio_format[0] = 0; char audio_codec[BCSTRLEN]; audio_codec[0] = 0; + AVCodec *codec = 0; Asset *asset = aud_config->asset; const char *name = asset->acodec; - if( !FFMPEG::get_codec(audio_codec, "audio", name) ) + if( !FFMPEG::get_format(audio_format, "audio", name) && + !FFMPEG::get_codec(audio_codec, "audio", name) ) codec = avcodec_find_encoder_by_name(audio_codec); if( !codec ) { eprintf(_("no codec named: %s: %s"), name, audio_codec); return 1; } - aud_config->ff_options_dialog->start(audio_codec, codec, - asset->ff_audio_options, sizeof(asset->ff_audio_options)); + aud_config->ff_options_dialog->start(audio_format, audio_codec, codec, + asset->ff_audio_options, sizeof(asset->ff_audio_options)); return 1; } @@ -1521,18 +1528,20 @@ FFOptionsViewVideo::~FFOptionsViewVideo() int FFOptionsViewVideo::handle_event() { - AVCodec *codec = 0; + char video_format[BCSTRLEN]; video_format[0] = 0; char video_codec[BCSTRLEN]; video_codec[0] = 0; + AVCodec *codec = 0; Asset *asset = vid_config->asset; const char *name = asset->vcodec; - if( !FFMPEG::get_codec(video_codec, "video", name) ) + if( !FFMPEG::get_format(video_format, "video", name) && + !FFMPEG::get_codec(video_codec, "video", name) ) codec = avcodec_find_encoder_by_name(video_codec); if( !codec ) { eprintf(_("no codec named: %s: %s"), name, video_codec); return 1; } - vid_config->ff_options_dialog->start(video_codec, codec, - asset->ff_video_options, sizeof(asset->ff_video_options)); + vid_config->ff_options_dialog->start(video_format, video_codec, codec, + asset->ff_video_options, sizeof(asset->ff_video_options)); return 1; }