Opened 10 years ago

Closed 10 years ago

#3221 closed defect (invalid)

best effort time stamp is wrong after av_seek_frame is called.

Reported by: hxuanyu Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

I built the latest ffmpeg libs and ran a test app to test av_seek_frame

Basically what I did is

  1. read packet + decode frame
  2. av_seek_frame to a previous position
  3. continue to read + decode

but seems the best effort time stamps were wrong after seek was called.

Below is part of the log

to play av_divx_24_yuv420p_mp3_44100_2_1.avi
rhbc73 pFormatCtx->start_time = 0
video stream index = 0
rhbc73 Packet [0] dts = 0, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [1] dts = 1, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [2] dts = 2, pts = -9223372036854775808, KEY =0
rhbc73 NO complete frame
rhbc73 Packet [3] dts = 3, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [4] dts = 4, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 0, best effort time stamp = 0
rhbc73 Packet [5] dts = 5, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 1, best effort time stamp = 1
rhbc73 Packet [6] dts = 6, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 2, best effort time stamp = 2
rhbc73 Packet [7] dts = 7, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 3, best effort time stamp = 3
rhbc73 Packet [8] dts = 8, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 4, best effort time stamp = 4
rhbc73 Packet [9] dts = 9, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 5, best effort time stamp = 5
rhbc73 Packet [10] dts = 10, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 6, best effort time stamp = 6
rhbc73 now try to seek to packet where dts = 3
rhbc73 seek succeed, then continue to read
rhbc73 Packet [11] dts = 3, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 7, best effort time stamp = 7
rhbc73 Packet [12] dts = 4, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 8, best effort time stamp = 8
rhbc73 Packet [13] dts = 5, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 9, best effort time stamp = 9
rhbc73 Packet [14] dts = 6, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 10, best effort time stamp = 10
rhbc73 Packet [15] dts = 7, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 3, best effort time stamp = 3
rhbc73 Packet [16] dts = 8, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 4, best effort time stamp = 4
rhbc73 Packet [17] dts = 9, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 5, best effort time stamp = 5
rhbc73 Packet [18] dts = 10, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 6, best effort time stamp = 6

Attachments (4)

main.cpp (3.6 KB ) - added by hxuanyu 10 years ago.
test code
log (506.1 KB ) - added by hxuanyu 10 years ago.
log1 (505.8 KB ) - added by hxuanyu 10 years ago.
main (1).cpp (4.7 KB ) - added by hxuanyu 10 years ago.
please use this to test

Download all attachments as: .zip

Change History (10)

by hxuanyu, 10 years ago

Attachment: main.cpp added

test code

by hxuanyu, 10 years ago

Attachment: log added

comment:2 by DonMoir, 10 years ago

Call avcodec_flush_buffers on any open AVCodecContext before you call seek.

comment:3 by hxuanyu, 10 years ago

Hi I added avcodec_flush_buffers before calling av_seek_frame, but result still seems incorrect, sorry the log format is not so good, you can check attached file log1.

When I seek to dts 3, and continue to read. I expected to get a full frame straight away. But in fact until I read out 5 packets I could get the first full frame.

rhbc73 Packet [0] dts = 0, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [1] dts = 1, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [2] dts = 2, pts = -9223372036854775808, KEY =0
rhbc73 NO complete frame
rhbc73 Packet [3] dts = 3, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [4] dts = 4, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 0, best effort time stamp = 0
rhbc73 Packet [5] dts = 5, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 1, best effort time stamp = 1
rhbc73 Packet [6] dts = 6, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 2, best effort time stamp = 2
rhbc73 Packet [7] dts = 7, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 3, best effort time stamp = 3
rhbc73 Packet [8] dts = 8, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 4, best effort time stamp = 4
rhbc73 Packet [9] dts = 9, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 5, best effort time stamp = 5
rhbc73 Packet [10] dts = 10, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 6, best effort time stamp = 6
rhbc73 now try to see to packet where dts = 3
rhbc73 seek succeed, then continue to read
rhbc73 Packet [11] dts = 3, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [12] dts = 4, pts = -9223372036854775808, KEY =1
rhbc73 NO complete frame
rhbc73 Packet [13] dts = 5, pts = -9223372036854775808, KEY =0
rhbc73 NO complete frame
rhbc73 Packet [14] dts = 6, pts = -9223372036854775808, KEY =0
rhbc73 NO complete frame
rhbc73 Packet [15] dts = 7, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 3, best effort time stamp = 3
rhbc73 Packet [16] dts = 8, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 4, best effort time stamp = 4
rhbc73 Packet [17] dts = 9, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 5, best effort time stamp = 5
rhbc73 Packet [18] dts = 10, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 6, best effort time stamp = 6
rhbc73 Packet [19] dts = 11, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 7, best effort time stamp = 7
rhbc73 Packet [20] dts = 12, pts = -9223372036854775808, KEY =1
rhbc73 ======= got a complete frame, pkt_dts = 8, best effort time stamp = 8
rhbc73 Packet [21] dts = 13, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 9, best effort time stamp = 9
rhbc73 Packet [22] dts = 14, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 10, best effort time stamp = 10
rhbc73 Packet [23] dts = 15, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 11, best effort time stamp = 11
rhbc73 Packet [24] dts = 16, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 12, best effort time stamp = 12
rhbc73 Packet [25] dts = 17, pts = -9223372036854775808, KEY =0
rhbc73 ======= got a complete frame, pkt_dts = 13, best effort time stamp = 13

Last edited 10 years ago by hxuanyu (previous) (diff)

by hxuanyu, 10 years ago

Attachment: log1 added

comment:4 by DonMoir, 10 years ago

Something odd and maybe wrong index_entries list but can't really say.

You will need to do at least this from ffmpeg commamd line:

ffmpeg -i av_divx_24_yuv420p_mp3_44100_2_1.avi -f null -

Add the output of that to this ticket.

in reply to:  4 comment:5 by hxuanyu, 10 years ago

Replying to DonMoir:

Something odd and maybe wrong index_entries list but can't really say.

You will need to do at least this from ffmpeg commamd line:

ffmpeg -i av_divx_24_yuv420p_mp3_44100_2_1.avi -f null -

Add the output of that to this ticket.

Thanks, DonMoir

Here is the output

$ ffmpeg -i av_divx_24_yuv420p_mp3_44100_2_1.avi -f null -
ffmpeg version N-58485-ga12b4bd Copyright (c) 2000-2013 the FFmpeg developers

built on Nov 26 2013 22:01:46 with gcc 4.8.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 55.100 / 52. 55.100
libavcodec 55. 44.100 / 55. 44.100
libavformat 55. 21.102 / 55. 21.102
libavdevice 55. 5.101 / 55. 5.101
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

Input #0, avi, from 'av_divx_24_yuv420p_mp3_44100_2_1.avi':

Duration: 00:01:48.27, start: 0.000000, bitrate: 1162 kb/s

Stream #0:0: Video: mpeg4 (DIVX / 0x58564944), yuv420p, 480x360, 23.98 fps, 23.98 tbr, 23.98 tbn, 1 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 127 kb/s

Output #0, null, to 'pipe:':

Metadata:

encoder : Lavf55.21.102
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 480x360, q=2-31, 200 kb/s, 90k tbn, 23.98 tbc
Stream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

Stream mapping:

Stream #0:0 -> #0:0 (mpeg4 -> rawvideo)
Stream #0:1 -> #0:1 (mp3 -> pcm_s16le)

Press [q] to stop, ? for help
[mpeg4 @ 03712520] looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag
[null @ 036e3aa0] Encoder did not produce proper pts, making some up.
[mp3 @ 036ddd20] incomplete frameA time=00:01:25.89 bitrate=N/A
Error while decoding stream #0:1: Invalid data found when processing input
[mpeg4 @ 03712520] ac-tex damaged at 14 20
[mpeg4 @ 03712520] Error at MB: 634
[mpeg4 @ 03712520] concealing 125 DC, 125 AC, 125 MV errors in I frame
frame= 2701 fps=0.0 q=0.0 Lsize=N/A time=00:01:53.05 bitrate=N/A
video:169kB audio:19476kB subtitle:0 global headers:0kB muxing overhead -100.000109%

by hxuanyu, 10 years ago

Attachment: main (1).cpp added

please use this to test

comment:6 by Michael Niedermayer, 10 years ago

Analyzed by developer: set
Resolution: invalid
Status: newclosed

you need to call avcodec_flush_buffers() after seeking

Note: See TracTickets for help on using tickets.