[FFmpeg-devel] [PATCH] Populate MPEG2TS codec_tag using ff_codec_movvideo_tags/ff_codec_movaudio_tags (av4cc) rather than the PES stream_type. For MPEG2TS files containing h264, ffprobe currently returns codec_tag_string=[27][0][0][0], this change will now produce codec_tag_string=avc1

Damien Levin dlevin at google.com
Wed May 15 19:14:53 EEST 2019


---
 libavformat/mpegts.c                          | 9 +++++++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8a84e5cc19..79c0b78b1f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -877,6 +877,13 @@ static void mpegts_find_stream_type(AVStream *st,
                 st->codecpar->codec_id   != types->codec_id) {
                 st->codecpar->codec_type = types->codec_type;
                 st->codecpar->codec_id   = types->codec_id;
+                if (types->codec_type == AVMEDIA_TYPE_VIDEO) {
+                    st->codecpar->codec_tag =
+                        ff_codec_get_tag(ff_codec_movvideo_tags, types->codec_id);
+                } else if (types->codec_type == AVMEDIA_TYPE_AUDIO) {
+                    st->codecpar->codec_tag =
+                        ff_codec_get_tag(ff_codec_movaudio_tags, types->codec_id);
+                }
                 st->internal->need_context_update = 1;
             }
             st->request_probe        = 0;
@@ -908,8 +915,6 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
            "stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
            st->index, pes->stream_type, pes->pid, (char *)&prog_reg_desc);
 
-    st->codecpar->codec_tag = pes->stream_type;
-
     mpegts_find_stream_type(st, pes->stream_type, ISO_types);
     if (pes->stream_type == 4 || pes->stream_type == 0x0f)
         st->request_probe = 50;
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index e5cf18bbce..95f9859205 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -211,5 +211,5 @@ video|1|171982|1.910911|168382|1.870911|3600|0.040000|N/A|N/A|17440|216388|__MPE
 
 video|1|175582|1.950911|171982|1.910911|3600|0.040000|N/A|N/A|15019|235000|__MPEGTS Stream ID
 
-0|mp2|unknown|audio|1/44100|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0
-1|mpeg2video|4|video|1/25|[2][0][0][0]|0x0002|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|N/A|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0|0
+0|mp2|unknown|audio|1/44100|.mp3|0x33706d2e|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0
+1|mpeg2video|4|video|1/25|m2v1|0x3176326d|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|N/A|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|0|0|0|0|0|0|0|0|0|0|0|0
-- 
2.21.0.1020.gf2820cf01a-goog



More information about the ffmpeg-devel mailing list