On su, 2015-04-12 at 16:40 -0700, Philip Langdale wrote: > On Sun, 12 Apr 2015 08:13:39 +0000 (UTC) > Carl Eugen Hoyos <ceho...@ag.or.at> wrote: > > > > I tested with samples from the following directories: > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket598/ > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1722/ > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3820/ > > > > None of them work for me with the patch. It seems I am > > doing something wrong, could you explain how I should > > test? > > OK. > > I used: > > http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket598/00002_nosubs_detected.m2ts > > Then I did: > > ffmpeg -i 00002_nosubs_detected.m2ts -map 0 -c:v copy -c:a copy -c:s \ > copy remux.m2ts > > and I played remux.m2ts successfully in mplayer with working subtitles. > > Now, the ffmpeg probe output will not look the same as the original > file. You'll see: > > Stream #0:7[0x107], 0, 1/90000: Unknown: none ([144][0][0][0] / 0x0090) > Stream #0:8[0x108], 0, 1/90000: Unknown: none ([144][0][0][0] / 0x0090) > Stream #0:9[0x109], 0, 1/90000: Unknown: none ([144][0][0][0] / 0x0090) > Stream #0:10[0x10a], 0, 1/90000: Unknown: none ([144][0][0][0] / 0x0090) > Stream #0:11[0x10b], 0, 1/90000: Unknown: none ([144][0][0][0] / 0x0090)
0x90 stream type is not detected as PGS because of there's no HDMV registration descriptor in the program. Without it HDMV stream types are not "valid", and most demuxers (ffmpeg, vlc, ...) ignore those. > This change makes sure the 0x0090 type ID at the end is carried over > during the copy operation. There is a bunch of separate metadata which > needs to be copied for the 'Unknown' to be replaced by the right info > for the pgs subtitles, but that's a separate lower level problem in the > muxer - it doesn't appear to copy that info correctly in a whole class > of types, where pgs is just one example. > > It does have implications. You can remux from a proper bluray m2ts and > get a working file, but if you try and remux that output into a new > file, everything fails because ffmpeg can't identify the subtitle > tracks any more. > > So, this change is not a complete fix, but it's one of the necessary > steps. I don't know if it is a good idea to use HDMV stream types without HDMV program registration descriptor. If this is fixed incrementally, fixing should be started from the opposite direction: - Using HDMV stream type requires HDMV registration descriptor - using HDMV registration descriptor requires HDMV conforming stream I've attached a simple patch to add HDMV registration descriptor to the program. With it streams are correctly detected with ffmpeg. But, I don't think the patch should be applied: using HDMV registration descriptor in a stream that is not HDMV conforming is a really bad idea. > --phil > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 7670fc6..2e98d2a 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -233,7 +233,7 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) { MpegTSWrite *ts = s->priv_data; uint8_t data[SECTION_LENGTH], *q, *desc_length_ptr, *program_info_length_ptr; - int val, stream_type, i, err = 0; + int val, stream_type, i, err = 0, hdmv = 0; q = data; put16(&q, 0xe000 | service->pcr_pid); @@ -241,8 +241,27 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) program_info_length_ptr = q; q += 2; /* patched after */ + for (i = 0; i < s->nb_streams; i++) { + switch (s->streams[i]->codec->codec_id) { + case AV_CODEC_ID_PCM_BLURAY: + case AV_CODEC_ID_HDMV_PGS_SUBTITLE: + hdmv = 1; + break; + } + } + /* put program info here */ + /* add HDMV registration descriptor */ + if (hdmv) { + *q++ = 0x05; /* tag: registration descriptor */ + *q++ = 4; /* length: 4 */ + *q++ = 'H'; + *q++ = 'D'; + *q++ = 'M'; + *q++ = 'V'; + } + val = 0xf000 | (q - program_info_length_ptr - 2); program_info_length_ptr[0] = val >> 8; program_info_length_ptr[1] = val;
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel