Fixing very little bug for blu ray pcm in .mts files: The nature of bug: duration of blu ray packets is little bit wrong. How to reproduce: ./ffprobe -i bluray-pcm-file.mts -show_packets -select_streams a:0 | head -n 50 ... Stream #0:1[0x1100]: Audio: pcm_bluray (HDMV / 0x564D4448), 48000 Hz, stereo, s16, 1536 kb/s ... [PACKET] codec_type=audio stream_index=1 pts=118350 pts_time=1.315000 dts=118350 dts_time=1.315000 duration=451 duration_time=0.005011 convergence_duration=N/A convergence_duration_time=N/A size=964 pos=1035456 flags=K_ [SIDE_DATA] side_data_type=MPEGTS Stream ID [/SIDE_DATA] [/PACKET] [PACKET] codec_type=audio stream_index=1 pts=118800 pts_time=1.320000 dts=118800 dts_time=1.320000 duration=451 duration_time=0.005011 convergence_duration=N/A convergence_duration_time=N/A size=964 pos=1048704 flags=K_ [SIDE_DATA] side_data_type=MPEGTS Stream ID [/SIDE_DATA] [/PACKET]
Between the packets you can see that dts increments by "450", not "451": dts=118350 => dts=118800 We can compute the duration by ourself from the size: size = 964 . BDPCM Header length is 4 bytes. => samples size = 960 size of one sample = 16 bits/8 * 2 channels = 4 then number of samples = 960/4 = 240 samples duration = 240 * 90000 / 48000 = 450 so, the duration in packet "duration=451" is incorrect ============ Following the code in avcodec:utilc.c get_audio_frame_duration(), we can see, that header sizes were not excluded from the frame size. ============ P.S. The bug is the same for dvd pcm, but it doesn't affect on anything. How to make sure, that "magic constants" 3 and 4 for the streams are constant for all cases: see the decoding code: pcm-bluray.c : 144 pcm-dvd.c : 250 s302m.c : 108 (yes, s302m case is not modified) P.P.S. 1. It looks like for s302m the exclusion of 4 bytes happens (in a hackish way, splitted with protection from division by zero) 2. You can see that code around the patch contains 3 different ways of protection from dividing by zero. And actually for all this streams we can check bps > 8 (isn't it?).
0001-avcodec-fix-wrong-duration-of-packets-dvd-bluray.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel