[FFmpeg-trac] #3182(avformat:new): A/V desync when transcoding MPEG-TS streams if an audio track disappears
FFmpeg
trac at avcodec.org
Fri Nov 29 20:20:24 CET 2013
#3182: A/V desync when transcoding MPEG-TS streams if an audio track disappears
----------------------------------+--------------------------------------
Reporter: aurelien | Type: defect
Status: new | Priority: normal
Component: avformat | Version: git-master
Keywords: mpeg-ts | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
----------------------------------+--------------------------------------
Hi,
I have some streams that for some unknown reasons (I don't have control on
them since it's mainly DVB-S streams) lose audio from time to time.
In some cases a new PMT with only a video track can be found or the audio
packets could just disappear.
This can last a few seconds or multiple hours (delay for the broadcaster
to fix the problem I guess).
In both cases get_input_packet() from process_input() won't see packets
with stream_index=audio anymore.
ffmpeg will keep encoding the video frames.
The problem is with av_interleaved_write_frame() in write_frame(). This
functions waits for all streams to have at least one packet before writing
to the output.
In this case it will buffer video packets (thus leaking) until another
audio packet comes ; and then it will start to write the video packets
again but they won't match the audio packets.
I crafted (once again) a sample 'bbb_gap_sound.ts' by deleting some audio
packets from an MPEG-TS stream (I don't have a sample where the PMT
changes).
It's from Big Buck Bunny so there are only music and noises but it's quite
easy to spot the A/V desync (the audio disappears at ~37s).
How to reproduce:
{{{
ffmpeg -i bbb_gap_sound.ts -acodec libfdk_aac -b:a 64k -ac 2 -ar 44100
-vcodec libx264 -b:v 800k -s 320x240 /tmp/bbb_encoded.ts
ffmpeg version N-58591-ga677fb6 Copyright (c) 2000-2013 the FFmpeg
developers
built on Nov 29 2013 17:58:08 with gcc 4.7 (Debian 4.7.2-5)
configuration: --prefix=/home/aurelien/local --enable-postproc --enable-
nonfree --enable-gpl --enable-libfaac --enable-shared --enable-libx264
--extra-cflags=-I/home/aurelien/local/include --extra-
ldflags=-L/home/aurelien/local/lib --enable-version3 --disable-
optimizations --enable-libfreetype --disable-stripping --enable-libaacplus
--enable-libfdk-aac
libavutil 52. 55.100 / 52. 55.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.102 / 55. 21.102
libavdevice 55. 5.102 / 55. 5.102
libavfilter 3. 91.100 / 3. 91.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
[h264 @ 0x16a9aa0] non-existing PPS referenced
[h264 @ 0x16a9aa0] non-existing PPS 0 referenced
[h264 @ 0x16a9aa0] decode_slice_header error
[h264 @ 0x16a9aa0] no frame!
[... non-existing PPS messages skipped ...]
[mpegts @ 0x16a5a00] PES packet size mismatch
Input #0, mpegts, from 'bbb_gap_sound.ts':
Duration: 00:01:58.26, start: 211.763244, bitrate: 988 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p, 320x240, 24 fps, 24 tbr, 90k tbn, 48 tbc
Stream #0:1[0x101](eng): Audio: aac ([15][0][0][0] / 0x000F), 44100
Hz, stereo, fltp, 64 kb/s
[libx264 @ 0x16abb40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x16abb40] profile High, level 2.0
Output #0, mpegts, to '/tmp/bbb_encoded.ts':
Metadata:
encoder : Lavf55.21.102
Stream #0:0: Video: h264 (libx264), yuv420p, 320x240, q=-1--1, 800
kb/s, 90k tbn, 24 tbc
Stream #0:1(eng): Audio: aac (libfdk_aac), 44100 Hz, stereo, s16, 64
kb/s
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:1 -> #0:1 (aac -> libfdk_aac)
Press [q] to stop, [?] for help
[mpegts @ 0x16a5a00] PES packet size mismatchme=00:01:53.16 bitrate=
616.6kbits/s dup=32 drop=0
[h264 @ 0x228af80] error while decoding MB 4 13, bytestream (-40)
[h264 @ 0x228af80] concealing 85 DC, 85 AC, 85 MV errors in P frame
frame= 2839 fps=601 q=-1.0 Lsize= 14116kB time=00:01:58.20 bitrate=
978.2kbits/s dup=33 drop=0
video:12165kB audio:565kB subtitle:0 global headers:0kB muxing overhead
10.884066%
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3182>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list