X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffileffmpeg.C;h=2fbf6c86f80327055b703295b5d66017895aaf0e;hp=21e3067e2f4bbbd4203962979ceac13b442f40bc;hb=refs%2Fheads%2Fmaster;hpb=676954c909c19080350cb159fb6be7ec65fd3ef6 diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index 21e3067e..2fbf6c86 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -1,3 +1,24 @@ +/* + * CINELERRA + * Copyright (C) 2008 Adam Williams + * Copyright (C) 2010 Monty Montgomery + * Copyright (C) 2012-2014 Paolo Rampino + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ #include #include @@ -159,7 +180,7 @@ void FFMpegPixelFormat::update_formats() pixfmts.remove_all_objects(); char video_codec[BCSTRLEN]; video_codec[0] = 0; const char *vcodec = vid_config->asset->vcodec; - AVCodec *av_codec = !FFMPEG::get_codec(video_codec, "video", vcodec) ? + const AVCodec *av_codec = !FFMPEG::get_codec(video_codec, "video", vcodec) ? avcodec_find_encoder_by_name(video_codec) : 0; const AVPixelFormat *pix_fmts = av_codec ? av_codec->pix_fmts : 0; if( pix_fmts ) { @@ -190,7 +211,7 @@ void FFMpegSampleFormat::update_formats() samplefmts.remove_all_objects(); char audio_codec[BCSTRLEN]; audio_codec[0] = 0; const char *acodec = aud_config->asset->acodec; - AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", acodec) ? + const AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", acodec) ? avcodec_find_encoder_by_name(audio_codec) : 0; const AVSampleFormat *sample_fmts = av_codec ? av_codec->sample_fmts : 0; if( sample_fmts ) { @@ -326,7 +347,7 @@ int FileFFMPEG::open_file(int rd, int wr) int result = 0; if( ff ) return 1; ff = new FFMPEG(this); - + if( rd ) { result = ff->init_decoder(asset->path); if( !result ) result = ff->open_decoder(); @@ -342,6 +363,12 @@ int FileFFMPEG::open_file(int rd, int wr) int video_layers = ff->ff_total_video_layers(); if( video_layers > 0 ) { asset->video_data = 1; + asset->aspect_ratio = ff->ff_aspect_ratio(0); + if (!asset->interlace_mode) asset->interlace_mode = ff->ff_interlace(0); + if ( ff->ff_video_frames(0) > 1 ) { +// ff->video_probe(1); + if (!asset->interlace_mode && (ff->interlace_from_codec) ) asset->interlace_mode = ff->video_probe(1); + } if( !asset->layers ) asset->layers = video_layers; asset->actual_width = ff->ff_video_width(0); asset->actual_height = ff->ff_video_height(0); @@ -510,6 +537,8 @@ FFMPEGConfigAudio::FFMPEGConfigAudio(BC_WindowBase *parent_window, audio_options = 0; format_name = asset->fformat; codec_name = asset->acodec; +// *** CONTEXT_HELP *** + context_help_set_keyword("Options for Render with FFmpeg"); } FFMPEGConfigAudio::~FFMPEGConfigAudio() @@ -675,6 +704,8 @@ FFMPEGConfigVideo::FFMPEGConfigVideo(BC_WindowBase *parent_window, bitrate = 0; quality = 0; video_options = 0; +// *** CONTEXT_HELP *** + context_help_set_keyword("Options for Render with FFmpeg"); } FFMPEGConfigVideo::~FFMPEGConfigVideo() @@ -841,6 +872,8 @@ FFMPEGConfigFormat::FFMPEGConfigFormat(FFOptionsFormatViewDialog *view_dialog, format_options = 0; format_name = asset->fformat; codec_name = 0; +// *** CONTEXT_HELP *** + context_help_set_keyword("Modifying FFmpeg Format Options"); } FFMPEGConfigFormat::~FFMPEGConfigFormat() @@ -864,10 +897,10 @@ void FFMPEGConfigFormat::save_options() } void FFMPEGConfigFormat::save_changes() { + read_options(); char *options = asset->ff_format_options; int options_len = sizeof(asset->ff_format_options)-1; ff_options_dialog->store_options(options, options_len); - format_options->update(options); } void FFMPEGConfigFormat::load_options() @@ -1587,6 +1620,8 @@ FFOptionsWindow::FFOptionsWindow(FFOptionsDialog *dialog, int x, int y) this->dialog = dialog; this->selected = 0; this->kind = 0; +// *** CONTEXT_HELP *** + context_help_set_keyword("Modifying FFmpeg Format Options"); } FFOptionsWindow::~FFOptionsWindow() @@ -1838,7 +1873,7 @@ int FFOptionsViewAudio::handle_event() const char *name = asset->acodec; char audio_format[BCSTRLEN]; audio_format[0] = 0; char audio_codec[BCSTRLEN]; audio_codec[0] = 0; - AVCodec *codec = !ret && + const AVCodec *codec = !ret && !FFMPEG::get_format(audio_format, "audio", name) && !FFMPEG::get_codec(audio_codec, "audio", name) ? avcodec_find_encoder_by_name(audio_codec) : 0; @@ -1876,7 +1911,7 @@ int FFOptionsViewVideo::handle_event() const char *name = asset->vcodec; char video_format[BCSTRLEN]; video_format[0] = 0; char video_codec[BCSTRLEN]; video_codec[0] = 0; - AVCodec *codec = !ret && + const AVCodec *codec = !ret && !FFMPEG::get_format(video_format, "video", name) && !FFMPEG::get_codec(video_codec, "video", name) ? avcodec_find_encoder_by_name(video_codec) : 0; @@ -1938,6 +1973,15 @@ int FFOptionsFormatView::handle_event() { Asset *asset = fmt_config->asset; char *format_name = asset->fformat; + char replace_name0[] = "mov"; + char replace_name1[] = "mpegts"; + char replace_name2[] = "matroska"; + if (!strcmp(format_name, "qt")) + format_name = replace_name0; // fixup + if (!strcmp(format_name, "m2ts")) + format_name = replace_name1; // fixup + if (!strcmp(format_name, "mkv")) + format_name = replace_name2; // fixup avformat_free_context(fmt_ctx); fmt_ctx = 0; int ret = avformat_alloc_output_context2(&fmt_ctx, 0, format_name, 0); if( ret || !fmt_ctx ) { @@ -1974,11 +2018,8 @@ BC_Window *FFOptionsFormatViewDialog::new_gui() void FFOptionsFormatViewDialog::handle_done_event(int result) { - if( !result ) { - cfg_window->lock_window("FFOptionsFormatViewDialog::handle_done_event"); + if( !result ) cfg_window->save_changes(); - cfg_window->unlock_window(); - } cfg_window = 0; }