summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-12-15 22:52:23 +0100
committerStefano Sabatini <stefasab@gmail.com>2012-12-16 10:58:02 +0100
commit013b700771ec5eabc6687fc3813c1c9f341bc1e8 (patch)
treeefaa095454730859ee13e31bd8a81d821b2049f3 /ffplay.c
parent1cbb11cda79eb9796ba5d00653819706c566dab8 (diff)
ffplay: provide some feedback in case the codec cannot be set
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/ffplay.c b/ffplay.c
index 2561a07419..d5985f73ea 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2300,6 +2300,7 @@ static int stream_component_open(VideoState *is, int stream_index)
AVFormatContext *ic = is->ic;
AVCodecContext *avctx;
AVCodec *codec;
+ const char *forced_codec_name = NULL;
AVDictionary *opts;
AVDictionaryEntry *t = NULL;
@@ -2310,12 +2311,17 @@ static int stream_component_open(VideoState *is, int stream_index)
codec = avcodec_find_decoder(avctx->codec_id);
switch(avctx->codec_type){
- case AVMEDIA_TYPE_AUDIO : is->last_audio_stream = stream_index; if(audio_codec_name ) codec= avcodec_find_decoder_by_name( audio_codec_name); break;
- case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; if(subtitle_codec_name) codec= avcodec_find_decoder_by_name(subtitle_codec_name); break;
- case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; if(video_codec_name ) codec= avcodec_find_decoder_by_name( video_codec_name); break;
- }
- if (!codec)
+ case AVMEDIA_TYPE_AUDIO : is->last_audio_stream = stream_index; forced_codec_name = audio_codec_name; break;
+ case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break;
+ case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break;
+ }
+ if (forced_codec_name)
+ codec = avcodec_find_decoder_by_name(forced_codec_name);
+ if (!codec) {
+ if (forced_codec_name) fprintf(stderr, "No codec could be found with name '%s'\n", forced_codec_name);
+ else fprintf(stderr, "No codec could be found with id %d\n", avctx->codec_id);
return -1;
+ }
avctx->codec_id = codec->id;
avctx->workaround_bugs = workaround_bugs;