FFmpeg: use Codec name instead if codec_id integer to identify codec

This allows selecting the intended codec when there are multiple with the same
codec_id

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Benjamin Drung <bdrung@debian.org>
This commit is contained in:
benjamin.drung@gmail.com 2014-05-27 21:36:01 +00:00
parent da47fe0373
commit 73295bbc02
2 changed files with 5 additions and 3 deletions

View File

@ -423,7 +423,9 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project)
set_dict_int(&options, "prediction_order_method", gPrefs->Read(wxT("/FileFormats/FFmpegPredOrderMethod"),(long)0));
set_dict_int(&options, "muxrate", gPrefs->Read(wxT("/FileFormats/FFmpegMuxRate"),(long)0));
mEncFormatCtx->packet_size = gPrefs->Read(wxT("/FileFormats/FFmpegPacketSize"),(long)0);
mEncAudioCodecCtx->codec_id = (AVCodecID)gPrefs->Read(wxT("/FileFormats/FFmpegCodec"), mEncFormatDesc->audio_codec);
codec = avcodec_find_encoder_by_name(gPrefs->Read(wxT("/FileFormats/FFmpegCodec")).ToUTF8());
if (!codec)
mEncAudioCodecCtx->codec_id = mEncFormatDesc->audio_codec;
break;
default:
return false;

View File

@ -1261,7 +1261,7 @@ ExportFFmpegOptions::ExportFFmpegOptions(wxWindow *parent)
DoOnFormatList();
//Select the codec that was selected last time this dialog was closed
AVCodec *codec = avcodec_find_encoder((AVCodecID)gPrefs->Read(wxT("/FileFormats/FFmpegCodec"),(long)CODEC_ID_NONE));
AVCodec *codec = avcodec_find_encoder_by_name(gPrefs->Read(wxT("/FileFormats/FFmpegCodec")).ToUTF8());
if (codec != NULL) mCodecList->Select(mCodecList->FindString(wxString::FromUTF8(codec->name)));
DoOnCodecList();
}
@ -1908,7 +1908,7 @@ void ExportFFmpegOptions::OnOK(wxCommandEvent& WXUNUSED(event))
{
int selcdc = mCodecList->GetSelection();
int selfmt = mFormatList->GetSelection();
if (selcdc > -1) gPrefs->Write(wxT("/FileFormats/FFmpegCodec"),(long)avcodec_find_encoder_by_name(mCodecList->GetString(selcdc).ToUTF8())->id);
if (selcdc > -1) gPrefs->Write(wxT("/FileFormats/FFmpegCodec"),mCodecList->GetString(selcdc));
if (selfmt > -1) gPrefs->Write(wxT("/FileFormats/FFmpegFormat"),mFormatList->GetString(selfmt));
gPrefs->Flush();
ShuttleGui S(this, eIsSavingToPrefs);