[Libav-user] Seeking causes the demuxer to skip some packets (after the seek)... why? Bug?
Michael Bradshaw
mbradshaw at sorensonmedia.com
Thu Oct 25 22:02:49 CEST 2012
I have a weird issue that I'm trying to figure out, and I'm not sure
if I'm doing something wrong or if it's a bug in FFmpeg's code, and
I'm hoping someone can help me determine which.
If I demux a file by simply repeatedly calling av_read_frame(), I get
the same output packets as ffprobe -show_packets[1].
However, if I seek using av_seek_frame() to go back to the very
beginning, and then start demuxing with av_read_frame(), I get the
same output audio packets as before, but for some reason it skips the
first two video packets (video packets with timesamps (pts=0,
dts=-6006) and (pts=3003, dts=-3003)). This throws off the decoder and
I end up missing the first few seconds of video because of this. This
happens when I specify a stream_index of 1 (the audio stream, which I
do since its packets are first in the file) or -1 (default stream) (-1
only fails for certain timestamps, namely very large negative
timestamps), but not when I call it with a stream_index of 0 (the
video stream). I get the same results if using avformat_seek_file()
too.
What is the result of calling av_seek_frame() on the other streams?
That is, if I call av_seek_frame() with a stream_index of 1, how are
the other streams affected? The documentation is lacking, and it's
possible I've assumed wrong.
Is this possibly a bug? Or is this kind of behavior acceptable (you
might argue my stream_index wasn't the video stream, so exactly where
it is not specified, in which case I'd argue the documentation
certainly should warn of that)? I've never had the demuxer skip
packets... It starts reading packets from the beginning just fine, but
for some reason skips two video packets.
I've also included
[1] Here is the output of ffprobe -show_packets (I've cut the trailing
packets that aren't relevant):
ffprobe version N-45279-g1a104bf Copyright (c) 2007-2012 the FFmpeg developers
built on Oct 10 2012 19:19:16 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-pthreads
--enable-runtime-cpudetect --enable-avisynth --enable-bzlib
--enable-frei0r --enable-libass --enable-libcelt
--enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libfreetype --enable-libgsm --enable-libmp3lame
--enable-libnut --enable-libopenjpeg --enable-librtmp
--enable-libschroedinger --enable-libspeex --enable-libtheora
--enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs
--enable-libxvid --enable-zlib
libavutil 51. 74.100 / 51. 74.100
libavcodec 54. 65.100 / 54. 65.100
libavformat 54. 31.100 / 54. 31.100
libavdevice 54. 3.100 / 54. 3.100
libavfilter 3. 19.102 / 3. 19.102
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 16.100 / 0. 16.100
libpostproc 52. 1.100 / 52. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SIMPSONS_D2-CallOfTheSimpsons.m4v':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42isomavc1
encoder : HandBrake 0.9.5 2011010300
Duration: 00:23:06.51, start: 0.000000, bitrate: 1944 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
720x480 [SAR 118:135 DAR 59:45], 1774 kb/s, 25.50 fps, 29.97 tbr, 90k
tbn, 180k tbc
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz,
stereo, s16, 164 kb/s
Stream #0:2(und): Subtitle: mov_text (text / 0x74786574)
[PACKET]
codec_type=audio
stream_index=1
pts=0
pts_time=0.000000
dts=0
dts_time=0.000000
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=6
pos=168
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=1024
pts_time=0.021333
dts=1024
dts_time=0.021333
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=21
pos=174
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=2048
pts_time=0.042667
dts=2048
dts_time=0.042667
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=10
pos=195
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=3072
pts_time=0.064000
dts=3072
dts_time=0.064000
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=10
pos=205
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=4096
pts_time=0.085333
dts=4096
dts_time=0.085333
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=10
pos=215
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=5120
pts_time=0.106667
dts=5120
dts_time=0.106667
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=10
pos=225
flags=K
[/PACKET]
[PACKET]
codec_type=audio
stream_index=1
pts=6144
pts_time=0.128000
dts=6144
dts_time=0.128000
duration=1024
duration_time=0.021333
convergence_duration=N/A
convergence_duration_time=N/A
size=10
pos=235
flags=K
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=0
pts_time=0.000000
dts=-6006
dts_time=-0.066733
duration=N/A
duration_time=N/A
convergence_duration=N/A
convergence_duration_time=N/A
size=36509
pos=245
flags=K
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=3003
pts_time=0.033367
dts=-3003
dts_time=-0.033367
duration=N/A
duration_time=N/A
convergence_duration=N/A
convergence_duration_time=N/A
size=35
pos=36754
flags=_
[/PACKET]
[PACKET]
codec_type=video
stream_index=0
pts=9009
pts_time=0.100100
dts=0
dts_time=0.000000
duration=N/A
duration_time=N/A
convergence_duration=N/A
convergence_duration_time=N/A
size=32245
pos=36789
flags=_
[/PACKET]
More information about the Libav-user
mailing list