[PATCH] * mpegts demuxer should recognize private streams
The patch addresses this problem: https://lists.ffmpeg.org/pipermail/libav-user/2014-September/007475.html What it does is this: * Except stream type 0x06 as a private stream. (AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE) (It was necessary to convince mpegts_set_stream_info(), that AV_CODEC_ID_NONE might be a valid codec id.) * Handle stream id 0xbd (private_stream_1). This stream uses PES headers, but needs no further parsing (as there is no codec defined). --- libavformat/mpegts.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index aeb2335..4025bcf 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -689,6 +689,7 @@ static const StreamType ISO_types[] = { { 0x02, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG2VIDEO }, { 0x03, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, { 0x04, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, + { 0x06, AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE }, { 0x0f, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC }, { 0x10, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG4 }, /* Makito encoder sets stream type 0x11 for AAC, @@ -756,13 +757,13 @@ static const StreamType DESC_types[] = { { 0 }, }; -static void mpegts_find_stream_type(AVStream *st, - uint32_t stream_type, - const StreamType *types) +static int mpegts_find_stream_type(AVStream *st, + uint32_t stream_type, + const StreamType *types) { if (avcodec_is_open(st->codec)) { av_log(NULL, AV_LOG_DEBUG, "cannot set stream info, codec is open\n"); - return; + return 0; } for (; types->stream_type; types++) @@ -770,8 +771,10 @@ static void mpegts_find_stream_type(AVStream *st, st->codec->codec_type = types->codec_type; st->codec->codec_id = types->codec_id; st->request_probe = 0; - return; + return 1; } + + return 0; } static int mpegts_set_stream_info(AVStream *st, PESContext *pes, @@ -779,6 +782,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, { int old_codec_type = st->codec->codec_type; int old_codec_id = st->codec->codec_id; + int new_codec_found; if (avcodec_is_open(st->codec)) { av_log(pes->stream, AV_LOG_DEBUG, "cannot set stream info, codec is open\n"); @@ -799,11 +803,12 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, st->codec->codec_tag = pes->stream_type; - mpegts_find_stream_type(st, pes->stream_type, ISO_types); + new_codec_found = mpegts_find_stream_type(st, pes->stream_type, ISO_types); if ((prog_reg_desc == AV_RL32("HDMV") || prog_reg_desc == AV_RL32("HDPR")) && - st->codec->codec_id == AV_CODEC_ID_NONE) { - mpegts_find_stream_type(st, pes->stream_type, HDMV_types); + st->codec->codec_id == AV_CODEC_ID_NONE && + !new_codec_found) { + new_codec_found = mpegts_find_stream_type(st, pes->stream_type, HDMV_types); if (pes->stream_type == 0x83) { // HDMV TrueHD streams also contain an AC3 coded version of the // audio track - add a second stream for this @@ -829,13 +834,19 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, sub_pes->sub_st = pes->sub_st = sub_st; } } - if (st->codec->codec_id == AV_CODEC_ID_NONE) - mpegts_find_stream_type(st, pes->stream_type, MISC_types); - if (st->codec->codec_id == AV_CODEC_ID_NONE) { + if (st->codec->codec_id == AV_CODEC_ID_NONE && + !new_codec_found) + new_codec_found = mpegts_find_stream_type(st, pes->stream_type, MISC_types); + if (st->codec->codec_id == AV_CODEC_ID_NONE && + !new_codec_found) { st->codec->codec_id = old_codec_id; st->codec->codec_type = old_codec_type; } - + if (new_codec_found && + st->codec->codec_id == AV_CODEC_ID_NONE && + st->codec->codec_type == AVMEDIA_TYPE_DATA) { + st->need_parsing = 0; + } return 0; } @@ -1036,7 +1047,9 @@ static int mpegts_push_data(MpegTSFilter *filter, code != 0x1ff && code != 0x1f2 && /* program_stream_directory, DSMCC_stream */ code != 0x1f8) { /* ITU-T Rec. H.222.1 type E stream */ pes->state = MPEGTS_PESHEADER; - if (pes->st->codec->codec_id == AV_CODEC_ID_NONE && !pes->st->request_probe) { + if (code == 0x1bd) { /* private_stream_1 */ + pes->st->need_parsing = 0; + } else if (pes->st->codec->codec_id == AV_CODEC_ID_NONE && !pes->st->request_probe) { av_log(pes->stream, AV_LOG_TRACE, "pid=%x stream_type=%x probing\n", pes->pid, -- 1.9.1
On Fri, May 29, 2015 at 10:45:47PM +0200, Wolfgang Lorenz wrote:
The patch addresses this problem: https://lists.ffmpeg.org/pipermail/libav-user/2014-September/007475.html
What it does is this: * Except stream type 0x06 as a private stream. (AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE) (It was necessary to convince mpegts_set_stream_info(), that AV_CODEC_ID_NONE might be a valid codec id.) * Handle stream id 0xbd (private_stream_1). This stream uses PES headers, but needs no further parsing (as there is no codec defined).
this breaks maks fate TEST aac-latm_stereo_to_51 TEST aac-aref-encode Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire
On Fri, May 29, 2015 at 10:45 PM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
The patch addresses this problem: https://lists.ffmpeg.org/pipermail/libav-user/2014-September/007475.html
What it does is this: * Except stream type 0x06 as a private stream. (AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE) (It was necessary to convince mpegts_set_stream_info(), that AV_CODEC_ID_NONE might be a valid codec id.) * Handle stream id 0xbd (private_stream_1). This stream uses PES headers, but needs no further parsing (as there is no codec defined).
To simplify the patch, maybe you should use AV_CODEC_ID_BIN_DATA as the codec id to indicate its generic binary data. That way you don't need all the special-handling to allow CODEC_ID_NONE. - Hendrik
Indeed, this does work too. And it even doesn't break any fates... At least on my machine. --- libavformat/mpegts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index aeb2335..cafcc92 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -689,6 +689,7 @@ static const StreamType ISO_types[] = { { 0x02, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG2VIDEO }, { 0x03, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, { 0x04, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, + { 0x06, AVMEDIA_TYPE_DATA, AV_CODEC_ID_BIN_DATA }, { 0x0f, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC }, { 0x10, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG4 }, /* Makito encoder sets stream type 0x11 for AAC, -- 1.9.1
On Sat, May 30, 2015 at 03:54:18AM +0200, Wolfgang Lorenz wrote:
Indeed, this does work too. And it even doesn't break any fates... At least on my machine. --- libavformat/mpegts.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index aeb2335..cafcc92 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -689,6 +689,7 @@ static const StreamType ISO_types[] = { { 0x02, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG2VIDEO }, { 0x03, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, { 0x04, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3 }, + { 0x06, AVMEDIA_TYPE_DATA, AV_CODEC_ID_BIN_DATA }, { 0x0f, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC }, { 0x10, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG4 }, /* Makito encoder sets stream type 0x11 for AAC,
still breaks fate --- ./tests/ref/acodec/s302m 2015-05-29 00:02:07.530881596 +0200 +++ tests/data/fate/acodec-s302m 2015-05-30 05:29:38.689115803 +0200 @@ -1,4 +1,2 @@ 2d1494ad78292dca556fd079ec27f28d *tests/data/fate/acodec-s302m.mpegts 1589164 tests/data/fate/acodec-s302m.mpegts -f9b6528eee1aea04640ee83400c78689 *tests/data/fate/acodec-s302m.out.wav -stddev: 986.97 PSNR: 36.44 MAXDIFF:18642 bytes: 1058400/ 1056708 Test acodec-s302m failed. Look at tests/data/fate/acodec-s302m.err for details. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML.
Am Sat, 30 May 2015 05:30:30 +0200 schrieb Michael Niedermayer <michaelni@gmx.at>: [...]
--- ./tests/ref/acodec/s302m 2015-05-29 00:02:07.530881596 +0200 +++ tests/data/fate/acodec-s302m 2015-05-30 05:29:38.689115803 +0200 @@ -1,4 +1,2 @@ 2d1494ad78292dca556fd079ec27f28d *tests/data/fate/acodec-s302m.mpegts 1589164 tests/data/fate/acodec-s302m.mpegts -f9b6528eee1aea04640ee83400c78689 *tests/data/fate/acodec-s302m.out.wav -stddev: 986.97 PSNR: 36.44 MAXDIFF:18642 bytes: 1058400/ 1056708 Test acodec-s302m failed. Look at tests/data/fate/acodec-s302m.err for details.
[...]
Strange. Do you have another configuration? I configured ffmpeg via: $ ./configure --disable-static --enable-shared --disable-debug --enable-debug --disable-optimizations --disable-stripping I call FATE via: $ make fate OS: Ubuntu 14.04 Last tested with ffmpeg commit: debf4d6e67dfb29f3d71683add429c588828f8e8 No problems here. Do I do anything wrong? Greetings, Wolfgang
Wolfgang Lorenz <wl-chmw <at> gmx.de> writes:
Strange. Do you have another configuration? I configured ffmpeg via: $ ./configure --disable-static --enable-shared
--disable-debug --enable-debug
That looks strange... (But works as expected iirc)
--disable-optimizations --disable-stripping
I call FATE via: $ make fate
(You did not read the first line of the output.)
No problems here. Do I do anything wrong?
$ make SAMPLES=fate-suite fate-rsync $ make SAMPLES=fate-suite fate Carl Eugen
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Sat, 30 May 2015 06:57:49 +0000 (UTC) schrieb Carl Eugen Hoyos <cehoyos@ag.or.at>:
Wolfgang Lorenz <wl-chmw <at> gmx.de> writes:
Strange. Do you have another configuration? I configured ffmpeg via: $ ./configure --disable-static --enable-shared
--disable-debug --enable-debug
That looks strange... (But works as expected iirc)
Ah, yes... I have a small "configure configuration" script, that disables debugging per default and adds debugging flags on request. So, that's why...
--disable-optimizations --disable-stripping
I call FATE via: $ make fate
(You did not read the first line of the output.)
No problems here. Do I do anything wrong?
$ make SAMPLES=fate-suite fate-rsync $ make SAMPLES=fate-suite fate
I see. Looks like this is going to take a while. I come back, when I have any results. Greetings, Wolfgang -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJVaXwqAAoJEHObOCppoHMZsBUQAKT6iqfDp2u/0N6RwiyajVGP ZmnzB+xIlZHG1puGt0dkbEpiy97jonfvSprNKieDHUwHJC4eU6HHjrZpuuPXglhw tcV86ssFn0csTlgkPuxwsBDmarO7WjCaT2fg4r3ud1O5YqdhligzZ2mf6aEFdzXO Nkb4ovAEDpr9hFeztktJfBws8jGsXldoKKS6jhyC19qggaZdWhnArZJ9Wr3emgfO yidnELgclzXjeMBA6jY4c1acU7d8QvdfAyDMX6cjQIVjrRHccl00kiVPcegKZa+N IFT6S2PvU08j6Z1jVY5qzGP77T0TKh67M5chEQyrSNkVIwVc4A9LCmZG7HAAKMBX IwmwwqYbFDcwQAzgSWhfnB+ljXmQNvBnfd0M7J2XkuhWehsubxcryONbxv/F0X4r mDu9eWhsUUaNgnIy2GaH1/fcGGxJphh/Yp28Yped588RmSogh6Q2wcIYyf7hWP0e Nc+N4dKTWVDivsCIl5QNeZ4cnriD0aDyx7A4xW4yfdV1z33yjt8sXTv69EkOBtnQ 0BHwEmTRkF6PAdSLXXizlhJt5IBmSPL3RRbqoEPRwhkbx19kMg5rad4NLR6TUifp kW6OuYTCWqmEcHTztwWkUIBq4tx65Btxeapzeh9Y925zOduhPmH6Jn3tXhs436BT ZDrzPDtZfsCJt73XRUep =FSnW -----END PGP SIGNATURE-----
Am Sat, 30 May 2015 11:00:18 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
Am Sat, 30 May 2015 06:57:49 +0000 (UTC) schrieb Carl Eugen Hoyos <cehoyos@ag.or.at>:
[...]
$ make SAMPLES=fate-suite fate-rsync $ make SAMPLES=fate-suite fate
I see. Looks like this is going to take a while. I come back, when I have any results.
Okay. Now I get the same errors Michael had, after the first version of the patch, but with the second version: Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1 Any suggestions? I hope, I get to look at this in more detail, in the evening. Greetings, Wolfgang
On Sat, May 30, 2015 at 12:39 PM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
Am Sat, 30 May 2015 11:00:18 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
Am Sat, 30 May 2015 06:57:49 +0000 (UTC) schrieb Carl Eugen Hoyos <cehoyos@ag.or.at>:
[...]
$ make SAMPLES=fate-suite fate-rsync $ make SAMPLES=fate-suite fate
I see. Looks like this is going to take a while. I come back, when I have any results.
Okay. Now I get the same errors Michael had, after the first version of the patch, but with the second version:
Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1
Any suggestions? I hope, I get to look at this in more detail, in the evening.
You should check out the .err files it mentions and actually see what its complaining about. - Hendrik
Am Sat, 30 May 2015 12:58:38 +0200 schrieb Hendrik Leppkes <h.leppkes@gmail.com>:
On Sat, May 30, 2015 at 12:39 PM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
Am Sat, 30 May 2015 11:00:18 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
[...]
Okay. Now I get the same errors Michael had, after the first version of the patch, but with the second version:
Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1
Okay, that was due to some old library versions, that were still lingering in my LD_LIBRARY_PATH. Now, also acodec-s302m fails.
You should check out the .err files it mentions and actually see what its complaining about.
That didn't help much. There doesn't seem to be much information available, but as I understand it s302m is some kind of codec defined by SMPTE, that writes PCM data into a private stream of an MPEG-TS. Without the patch the stream is identified as an AVMEDIA_UNKNOWN and AV_CODEC_NONE by mpegts.c. Later the missing codec leads to probing the stream for a codec id. The type is set to AVMEDIA_AUDIO and the codec id is set accordingly. All is well. With the patch the stream is identified as AVMEDIA_DATA and AV_CODEC_ID_BIN_DATA. In this case ffmpeg doesn't find any audio data to transcode and the fate test fails. This may be too bold, but I think the acodec-s302m test is broken. I think, that trying to decode private data is a bad idea. There's no way to see whether the chosen coder is the correct one. In my case FFMPEG thought AAC might be a good choice to decode random data. I'm not sure, what can be done about this, though. Just applying the patch, since the standard says so, might break other people's code. Maybe it is possible to implement a function, that changes the codec of a stream after probing for one that works. This could then be used by someone who knows what to expect in a private stream. Also, this would break other people's code. A third idea is to add a flag to each stream, that states whether FFPEG should still probe the stream, even if it is defined as a data stream. If this flag is set to true by default, this would not break other people's code. I've been trying to implement something like this for the last couple of hours, but it just doesn't work. :-( Well, I just don't know the internals of FFMPEG well enough. I guess the best I can do now, is to open a bug report describing my problem. What do you think? Greetings, Wolfgang
Here is a new version, that doesn't touch the way ffmpeg behaves without further user actions: I added a new flag to AVFormatContext, that activates the check for private streams, when set. It can be used like this: AVFormatContext * formatContext = avformat_alloc_context(); formatContext->flags |= AVFMT_FLAG_MPEGTS_RECOGNIZE_PRIVATE_STREAMS; avformat_open_input(&formatContext, fileName, NULL, NULL); --- libavformat/avformat.h | 1 + libavformat/mpegts.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 719c23b..f5dd3a8 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1394,6 +1394,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate. #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats +#define AVFMT_FLAG_MPEGTS_RECOGNIZE_PRIVATE_STREAMS 0x100000 ///< In MPEG-TS files, private streams will be recognized as such and not probed for encoded data /** * @deprecated deprecated in favor of probesize2 diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index aeb2335..2f4ae20 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -705,6 +705,11 @@ static const StreamType ISO_types[] = { { 0 }, }; +static const StreamType ISO_type_private_stream[] = { + { 0x06, AVMEDIA_TYPE_DATA, AV_CODEC_ID_BIN_DATA }, + { 0 }, +}; + static const StreamType HDMV_types[] = { { 0x80, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_BLURAY }, { 0x81, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AC3 }, @@ -800,6 +805,11 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, st->codec->codec_tag = pes->stream_type; mpegts_find_stream_type(st, pes->stream_type, ISO_types); + if (st->codec->codec_id == AV_CODEC_ID_NONE && + (pes->stream->flags & AVFMT_FLAG_MPEGTS_RECOGNIZE_PRIVATE_STREAMS)) + { + mpegts_find_stream_type(st, pes->stream_type, ISO_type_private_stream); + } if ((prog_reg_desc == AV_RL32("HDMV") || prog_reg_desc == AV_RL32("HDPR")) && st->codec->codec_id == AV_CODEC_ID_NONE) { -- 1.9.1
On Thu, Jun 4, 2015 at 12:52 AM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
Here is a new version, that doesn't touch the way ffmpeg behaves without further user actions:
I added a new flag to AVFormatContext, that activates the check for private streams, when set. It can be used like this:
AVFormatContext * formatContext = avformat_alloc_context(); formatContext->flags |= AVFMT_FLAG_MPEGTS_RECOGNIZE_PRIVATE_STREAMS; avformat_open_input(&formatContext, fileName, NULL, NULL);
Please make this a private option to the mpegts demuxer instead of a mpegts specific flag in global space. - Hendrik
The option went into the MpegTSContext struct and can be addressed via dictionary: AVFormatContext * formatContext = NULL; /* enable mpeg-ts private stream recognition */ AVDictionary * dict = NULL; av_dict_set_int(&dict, "mpegts_recognize_private_streams", 1, 0); /* open file */ avformat_open_input(&formatContext, fileName, NULL, &dict); --- libavformat/mpegts.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index aeb2335..9c883a8 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -147,6 +147,8 @@ struct MpegTSContext { int resync_size; + int recognize_private_streams; + /******************************************/ /* private mpegts data */ /* scan context */ @@ -175,6 +177,8 @@ static const AVOption options[] = { {.i64 = 0}, 0, 1, 0 }, {"skip_clear", "Skip clearing programs.", offsetof(MpegTSContext, skip_clear), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0 }, + {"mpegts_recognize_private_streams", "Assign AVMEDIA_TYPE_DATA and AV_CODEC_ID_BIN_DATA to data streams", offsetof(MpegTSContext, recognize_private_streams), AV_OPT_TYPE_INT, + {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; @@ -705,6 +709,11 @@ static const StreamType ISO_types[] = { { 0 }, }; +static const StreamType ISO_type_private_stream[] = { + { 0x06, AVMEDIA_TYPE_DATA, AV_CODEC_ID_BIN_DATA }, + { 0 }, +}; + static const StreamType HDMV_types[] = { { 0x80, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_BLURAY }, { 0x81, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AC3 }, @@ -800,6 +809,10 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, st->codec->codec_tag = pes->stream_type; mpegts_find_stream_type(st, pes->stream_type, ISO_types); + if (st->codec->codec_id == AV_CODEC_ID_NONE && + pes->ts->recognize_private_streams) { + mpegts_find_stream_type(st, pes->stream_type, ISO_type_private_stream); + } if ((prog_reg_desc == AV_RL32("HDMV") || prog_reg_desc == AV_RL32("HDPR")) && st->codec->codec_id == AV_CODEC_ID_NONE) { -- 1.9.1
No answers? Well, I do have a question. Am Thu, 4 Jun 2015 23:46:21 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
The option went into the MpegTSContext struct and can be addressed via dictionary:
AVFormatContext * formatContext = NULL;
/* enable mpeg-ts private stream recognition */ AVDictionary * dict = NULL; av_dict_set_int(&dict, "mpegts_recognize_private_streams", 1, 0);
/* open file */ avformat_open_input(&formatContext, fileName, NULL, &dict);
[...]
While I have used some kind of name scoping for the dictionary access, to avoid name clashes, I've seen, that this is not done for the rest of the formats. I think in most cases, this won't matter anyway. There are many doubling names between different input formats, but these won't make a problem, as one format context can only contain one input format. I've seen one name clash between AVFormatContext and an input format ("auto", mov.c), and "strict" seems to be declared twice for AVFormatContext. So, here's my question: Is there any kind of convention for naming options? And should I rename my option to "recognize_private_streams", or something different, to get the patch accepted? Recommendations are welcome. Okay, that's two questions. Anyway... Greetings, Wolfgang
On Wed, Jun 10, 2015 at 10:41:10PM +0200, Wolfgang Lorenz wrote:
No answers?
Well, I do have a question.
Am Thu, 4 Jun 2015 23:46:21 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
The option went into the MpegTSContext struct and can be addressed via dictionary:
AVFormatContext * formatContext = NULL;
/* enable mpeg-ts private stream recognition */ AVDictionary * dict = NULL; av_dict_set_int(&dict, "mpegts_recognize_private_streams", 1, 0);
/* open file */ avformat_open_input(&formatContext, fileName, NULL, &dict);
[...]
While I have used some kind of name scoping for the dictionary access, to avoid name clashes, I've seen, that this is not done for the rest of the formats. I think in most cases, this won't matter anyway. There are many doubling names between different input formats, but these won't make a problem, as one format context can only contain one input format. I've seen one name clash between AVFormatContext and an input format ("auto", mov.c), and "strict" seems to be declared twice for
constants have a scope limited to their type and field to which they apply
AVFormatContext. So, here's my question: Is there any kind of convention for naming options? And should I rename my option to "recognize_private_streams", or something different, to get the patch accepted? Recommendations are welcome.
i have no oppinon on the name, either is fine what kept me from applying this is that i dont see why it has to break detection of streams for which reliable detection exists, it breaks at least fate-acodec-s302m and fate-dca-core This should be a fallback for private streams which are not identified by a strong probing method ill post a patch which will do this in a moment, please comment/test thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt.
Am Wed, 10 Jun 2015 23:28:19 +0200 schrieb Michael Niedermayer <michaelni@gmx.at>:
On Wed, Jun 10, 2015 at 10:41:10PM +0200, Wolfgang Lorenz wrote:
No answers?
Well, I do have a question.
Am Thu, 4 Jun 2015 23:46:21 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
The option went into the MpegTSContext struct and can be addressed via dictionary:
AVFormatContext * formatContext = NULL;
/* enable mpeg-ts private stream recognition */ AVDictionary * dict = NULL; av_dict_set_int(&dict, "mpegts_recognize_private_streams", 1, 0);
/* open file */ avformat_open_input(&formatContext, fileName, NULL, &dict);
[...]
While I have used some kind of name scoping for the dictionary access, to avoid name clashes, I've seen, that this is not done for the rest of the formats. I think in most cases, this won't matter anyway. There are many doubling names between different input formats, but these won't make a problem, as one format context can only contain one input format. I've seen one name clash between AVFormatContext and an input format ("auto", mov.c), and "strict" seems to be declared twice for
constants have a scope limited to their type and field to which they apply
AVFormatContext. So, here's my question: Is there any kind of convention for naming options? And should I rename my option to "recognize_private_streams", or something different, to get the patch accepted? Recommendations are welcome.
i have no oppinon on the name, either is fine what kept me from applying this is that i dont see why it has to break detection of streams for which reliable detection exists, it breaks at least fate-acodec-s302m and fate-dca-core
Yes, I see your point here, and I agree with you. The last patch was meant to not touch the default behaviour, though, as a user would have to explicitly, deliberately and proactively (the last one was somewhat exaggerated) tell the mpegts demuxer to assign type and id for data streams. I wouldn't have considered this a breaking change.
This should be a fallback for private streams which are not identified by a strong probing method
I guess, that would be the best solution.
ill post a patch which will do this in a moment, please comment/test
Thank you. I'll have a look.
thanks
[...]
On Sun, May 31, 2015 at 06:35:18PM +0200, Wolfgang Lorenz wrote:
Am Sat, 30 May 2015 12:58:38 +0200 schrieb Hendrik Leppkes <h.leppkes@gmail.com>:
On Sat, May 30, 2015 at 12:39 PM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
Am Sat, 30 May 2015 11:00:18 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
[...]
Okay. Now I get the same errors Michael had, after the first version of the patch, but with the second version:
Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1
Okay, that was due to some old library versions, that were still lingering in my LD_LIBRARY_PATH.
Now, also acodec-s302m fails.
You should check out the .err files it mentions and actually see what its complaining about.
That didn't help much. There doesn't seem to be much information available, but as I understand it s302m is some kind of codec defined by SMPTE, that writes PCM data into a private stream of an MPEG-TS.
Without the patch the stream is identified as an AVMEDIA_UNKNOWN and AV_CODEC_NONE by mpegts.c. Later the missing codec leads to probing the stream for a codec id. The type is set to AVMEDIA_AUDIO and the codec id is set accordingly. All is well.
With the patch the stream is identified as AVMEDIA_DATA and AV_CODEC_ID_BIN_DATA. In this case ffmpeg doesn't find any audio data to transcode and the fate test fails.
This may be too bold, but I think the acodec-s302m test is broken. I think, that trying to decode private data is a bad idea. There's no way to see whether the chosen coder is the correct one. In my case FFMPEG thought AAC might be a good choice to decode random data.
I'm not sure, what can be done about this, though. Just applying the patch, since the standard says so, might break other people's code. Maybe it is possible to implement a function, that changes the codec of a stream after probing for one that works. This could then be used by someone who knows what to expect in a private stream. Also, this would break other people's code. A third idea is to add a flag to each stream, that states whether FFPEG should still probe the stream, even if it is defined as a data stream. If this flag is set to true by default, this would not break other people's code. I've been trying to implement something like this for the last couple of hours, but it just doesn't work. :-( Well, I just don't know the internals of FFMPEG well enough.
I guess the best I can do now, is to open a bug report describing my problem. What do you think?
Do i understand correctly that you put data in a mpegts file and you leave absolutely no way to identify this data except that its a private stream ? I think its a very bad idea not to add some reliable method to identify your data. Also the S302 in fate is identified by a registration descriptor there should be nothing unreliable in its detection [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire
Michael Niedermayer <michaelni <at> gmx.at> writes:
Also the S302 in fate is identified by a registration descriptor there should be nothing unreliable in its detection
I don't know if this is related at all but FFmpeg (also) detects Dolby-E as S302, see http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3890/ Completely independent of a decoder, I believe it is very bad that Dolby-E leads to white noise because it is misdetected. Carl Eugen
Am Thu, 4 Jun 2015 03:18:20 +0200 schrieb Michael Niedermayer <michaelni@gmx.at>:
On Sun, May 31, 2015 at 06:35:18PM +0200, Wolfgang Lorenz wrote:
Am Sat, 30 May 2015 12:58:38 +0200 schrieb Hendrik Leppkes <h.leppkes@gmail.com>:
On Sat, May 30, 2015 at 12:39 PM, Wolfgang Lorenz <wl-chmw@gmx.de> wrote:
Am Sat, 30 May 2015 11:00:18 +0200 schrieb Wolfgang Lorenz <wl-chmw@gmx.de>:
[...]
Okay. Now I get the same errors Michael had, after the first version of the patch, but with the second version:
Test aac-latm_000000001180bc60 failed. Look at tests/data/fate/aac-latm_000000001180bc60.err for details. make: *** [fate-aac-latm_000000001180bc60] Error 1 make: *** Waiting for unfinished jobs.... Test aac-latm_stereo_to_51 failed. Look at tests/data/fate/aac-latm_stereo_to_51.err for details. make: *** [fate-aac-latm_stereo_to_51] Error 1
Okay, that was due to some old library versions, that were still lingering in my LD_LIBRARY_PATH.
Now, also acodec-s302m fails.
You should check out the .err files it mentions and actually see what its complaining about.
That didn't help much. There doesn't seem to be much information available, but as I understand it s302m is some kind of codec defined by SMPTE, that writes PCM data into a private stream of an MPEG-TS.
Without the patch the stream is identified as an AVMEDIA_UNKNOWN and AV_CODEC_NONE by mpegts.c. Later the missing codec leads to probing the stream for a codec id. The type is set to AVMEDIA_AUDIO and the codec id is set accordingly. All is well.
With the patch the stream is identified as AVMEDIA_DATA and AV_CODEC_ID_BIN_DATA. In this case ffmpeg doesn't find any audio data to transcode and the fate test fails.
This may be too bold, but I think the acodec-s302m test is broken. I think, that trying to decode private data is a bad idea. There's no way to see whether the chosen coder is the correct one. In my case FFMPEG thought AAC might be a good choice to decode random data.
I'm not sure, what can be done about this, though. Just applying the patch, since the standard says so, might break other people's code. Maybe it is possible to implement a function, that changes the codec of a stream after probing for one that works. This could then be used by someone who knows what to expect in a private stream. Also, this would break other people's code. A third idea is to add a flag to each stream, that states whether FFPEG should still probe the stream, even if it is defined as a data stream. If this flag is set to true by default, this would not break other people's code. I've been trying to implement something like this for the last couple of hours, but it just doesn't work. :-( Well, I just don't know the internals of FFMPEG well enough.
I guess the best I can do now, is to open a bug report describing my problem. What do you think?
Do i understand correctly that you put data in a mpegts file and you leave absolutely no way to identify this data except that its a private stream ?
I think its a very bad idea not to add some reliable method to identify your data.
You are right, there. Ich should at least add some magic number to each packet, and I will. This wouldn't solve my original problem though.
Also the S302 in fate is identified by a registration descriptor there should be nothing unreliable in its detection
[...]
participants (4)
-
Carl Eugen Hoyos -
Hendrik Leppkes -
Michael Niedermayer -
Wolfgang Lorenz