-
-
Save tmm1/b582a40269af75f1f7db61845e29ff58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e91022c98a8b48791d06f2e6c8d30125447e01f8 Mon Sep 17 00:00:00 2001 | |
From: Aman Gupta <aman@tmm1.net> | |
Date: Tue, 19 Mar 2019 15:32:52 -0700 | |
Subject: [PATCH] ffmpeg: skip automatic audio stream selection for missing ac3 | |
audio streams | |
Some mpegts samples will define an ac3 stream in the PAT for which audio data never appears: | |
Program 3 | |
Stream #0:0[0x1a58]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc | |
Stream #0:1[0x1a59](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 384 kb/s | |
Stream #0:2[0x1a4a](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, fltp | |
Program 421 | |
Stream #0:0[0x621]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc | |
Stream #0:1[0x623](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s | |
Stream #0:2[0x622](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 0 channels, fltp | |
When using `ffmpeg -i ... -map 0:a` to select all audio streams, these get selected and then ffmpeg fails because it cannot decode them. | |
Signed-off-by: Aman Gupta <aman@tmm1.net> | |
--- | |
fftools/ffmpeg_opt.c | 8 ++++++++ | |
1 file changed, 8 insertions(+) | |
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c | |
index 262ee2b0ce..89285ce2b6 100644 | |
--- a/fftools/ffmpeg_opt.c | |
+++ b/fftools/ffmpeg_opt.c | |
@@ -344,6 +344,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg) | |
} | |
else | |
for (i = 0; i < input_files[file_idx]->nb_streams; i++) { | |
+ AVCodecContext *dec_ctx = input_streams[input_files[file_idx]->ist_index + i]->dec_ctx; | |
if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i], | |
*p == ':' ? p + 1 : p) <= 0) | |
continue; | |
@@ -351,6 +352,13 @@ static int opt_map(void *optctx, const char *opt, const char *arg) | |
disabled = 1; | |
continue; | |
} | |
+ if (*p == ':' && *(p+1) == 'a' && | |
+ dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO && | |
+ dec_ctx->codec_id == AV_CODEC_ID_AC3 && | |
+ dec_ctx->sample_rate == 0) { | |
+ /* don't auto-select ac3 audio streams that failed probing */ | |
+ continue; | |
+ } | |
GROW_ARRAY(o->stream_maps, o->nb_stream_maps); | |
m = &o->stream_maps[o->nb_stream_maps - 1]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment