From 435c332902d2bab8c2e6fd71797ddddce43ad98f Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Fri, 17 Sep 2021 22:26:22 -0400 Subject: [PATCH] Bug fix for auto-detection of default encoders for libav. --- src/drivers/Qt/AviRecord.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/drivers/Qt/AviRecord.cpp b/src/drivers/Qt/AviRecord.cpp index 68050591..6f94cfbb 100644 --- a/src/drivers/Qt/AviRecord.cpp +++ b/src/drivers/Qt/AviRecord.cpp @@ -1018,7 +1018,7 @@ static int initAudioStream( const char *codec_name, OutputStream *ost ) if (codec == NULL) { - fprintf(stderr, "codec not found\n"); + fprintf(stderr, "codec not found: '%s'\n", codec_name); return -1; } @@ -1181,11 +1181,21 @@ static int setCodecFromConfig(void) { if ( video_st.selEnc.size() == 0 ) { - video_st.selEnc = avcodec_get_name(fmt->video_codec); + c = avcodec_find_encoder( fmt->video_codec ); + + if ( c ) + { + video_st.selEnc = c->name; + } } if ( audio_st.selEnc.size() == 0 ) { - audio_st.selEnc = avcodec_get_name(fmt->audio_codec); + c = avcodec_find_encoder( fmt->audio_codec ); + + if ( c ) + { + audio_st.selEnc = c->name; + } } } return 0;