Opened 5 years ago

Closed 5 years ago

#17 closed defect (invalid)

FFPlay set different pts from ffmpeg for AVFilterBufferRef

Reported by: chinshou Owned by: michael
Priority: normal Component: ffmpeg
Version: Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Sorry I did not used the latest FFmpeg.

I found this problem with version 26383 get from ffmpeg on windows autobuild site.

ffplay set the pts for AVFilterBufferRef struct with output from guess_correct_pts function which is very small for example 67, 133 ,etc for the first several frames.

But ffmpeg will set the pts for AVFilterBufferRef with very large rescaled value which is calculated by output_packet function's function following process.

if(pkt->pts != AV_NOPTS_VALUE)

pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);

I added the log output code to vf_rotate's end_frame function like below.

static void end_frame(AVFilterLink *link)
{

RotContext? *rot = link->dst->priv;
AVFilterBufferRef *in = link->cur_buf;
AVFilterBufferRef *out = link->dst->outputs[0]->out_buf;
int i, j, plane;

#if 1

av_log(0, AV_LOG_ERROR, "rotate pts:%I64d\n", in->pts );

#endif

...

}

and used the command

ffmpeg -i 1.avi -vf "rotate" 2.avi
ffplay -vf "rotate" 1.avi

confirmed the problem

best regards
ChinShou?

Change History (4)

comment:1 in reply to: ↑ description Changed 5 years ago by saste

Replying to chinshou:

Sorry I did not used the latest FFmpeg.

I found this problem with version 26383 get from ffmpeg on windows autobuild site.

ffplay set the pts for AVFilterBufferRef struct with output from guess_correct_pts function which is very small for example 67, 133 ,etc for the first several frames.

But ffmpeg will set the pts for AVFilterBufferRef with very large rescaled value which is calculated by output_packet function's function following process.

[...]

and used the command

ffmpeg -i 1.avi -vf "rotate" 2.avi
ffplay -vf "rotate" 1.avi

confirmed the problem

Sorry but I can't understand which is the problem. Can you show me a failing command?
Timebases may be re-scaled within filters, but that shouldn't be an issue as they are scaled
back at the end of the filterchain.

Also don't forget that timestamp values need to be rescaled accordingly to their timebases:
picref_time = picref->pts * av_q2d(inlink->time_base);

Last edited 5 years ago by saste (previous) (diff)

comment:2 Changed 5 years ago by chinshou

Following is the ffplay output


FFplay version git-774208b, Copyright (c) 2003-2011 the FFmpeg developers

built on Feb 18 2011 23:53:23 with gcc 4.4.2
configuration: --enable-memalign-hack --arch=x86 --target-os=mingw32 --cross-prefix=i686-mingw32- --cc=i686-mingw32-gcc --enable-shared --disable-static --enable-memalign-hack --target-os=mingw32 --enable-libnut --enable-libvpx --disable-decoder=libvpx --disable-encoder=aac --enable-librtmp --enable-libschroedinger --enable-avisynth --enable-gpl --enable-version3 --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaac --enable-libfreetype --enable-pthreads --enable-libvorbis --enable-nonfree --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libxvid --enable-libx264 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-avfilter --enable-runtime-cpudetect --enable-libopenjpeg --extra-libs='-lx264 -lpthread -lrtmp -lpolarssl -lws2_32 -lwinmm '
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0

[flv @ 006acb00] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from '1.flv':

Metadata:

metadatacreator : modify by youku.com in 20090909
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
canSeekToEnd : false
duration : 263
datasize : 6140797
videosize : 4965962
videocodecid : 7
width : 320
height : 240
framerate : 15
videodatarate : 146
audiosize : 1136391
audiocodecid : 10
audiosamplerate : 22050
audiosamplesize : 16
stereo : true
audiodatarate : 32
filesize : 6142236
lasttimestamp : 263
lastkeyframetimestamp: 261
lastkeyframelocation: 6111316

Duration: 00:04:22.73, start: 0.000000, bitrate: 182 kb/s

Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 149 kb/s, 15 tbr, 1k tbn, 30 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 32 kb/s

rotate pts:67
rotate pts:133
rotate pts:200
rotate pts:267
rotate pts:333
rotate pts:400
rotate pts:467
rotate pts:533
rotate pts:600
...

Following is the ffmpeg output


FFmpeg version git-774208b, Copyright (c) 2000-2011 the FFmpeg developers

built on Feb 18 2011 23:53:23 with gcc 4.4.2
configuration: --enable-memalign-hack --arch=x86 --target-os=mingw32 --cross-prefix=i686-mingw32- --cc=i686-mingw32-gcc --enable-shared --disable-static --enable-memalign-hack --target-os=mingw32 --enable-libnut --enable-libvpx --disable-decoder=libvpx --disable-encoder=aac --enable-librtmp --enable-libschroedinger --enable-avisynth --enable-gpl --enable-version3 --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaac --enable-libfreetype --enable-pthreads --enable-libvorbis --enable-nonfree --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libxvid --enable-libx264 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-avfilter --enable-runtime-cpudetect --enable-libopenjpeg --extra-libs='-lx264 -lpthread -lrtmp -lpolarssl -lws2_32 -lwinmm '
libavutil 50.36. 0 / 50.36. 0
libavcore 0.16. 1 / 0.16. 1
libavcodec 52.108. 0 / 52.108. 0
libavformat 52.93. 0 / 52.93. 0
libavdevice 52. 2. 3 / 52. 2. 3
libavfilter 1.74. 0 / 1.74. 0
libswscale 0.12. 0 / 0.12. 0

[flv @ 0072add0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from '1.flv':

Metadata:

metadatacreator : modify by youku.com in 20090909
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
canSeekToEnd : false
duration : 263
datasize : 6140797
videosize : 4965962
videocodecid : 7
width : 320
height : 240
framerate : 15
videodatarate : 146
audiosize : 1136391
audiocodecid : 10
audiosamplerate : 22050
audiosamplesize : 16
stereo : true
audiodatarate : 32
filesize : 6142236
lasttimestamp : 263
lastkeyframetimestamp: 261
lastkeyframelocation: 6111316

Duration: 00:04:22.73, start: 0.000000, bitrate: 182 kb/s

Stream #0.0: Video: h264, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 149 kb/s, 15 tbr, 1k tbn, 30 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 32 kb/s

[buffer @ 005fdf70] w:320 h:240 pixfmt:yuv420p
Output #0, avi, to '23.avi':

Metadata:

metadatacreator : modify by youku.com in 20090909
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
canSeekToEnd : false
duration : 263
datasize : 6140797
videosize : 4965962
videocodecid : 7
width : 320
height : 240
framerate : 15
videodatarate : 146
audiosize : 1136391
audiocodecid : 10
audiosamplerate : 22050
audiosamplesize : 16
stereo : true
audiodatarate : 32
filesize : 6142236
lasttimestamp : 263
lastkeyframetimestamp: 261
lastkeyframelocation: 6111316
ISFT : Lavf52.93.0
Stream #0.0: Video: mpeg4, yuv420p, 395x395 [PAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 15 tbn, 15 tbc
Stream #0.1: Audio: mp2, 44100 Hz, stereo, s16, 64 kb/s

Stream mapping:

Stream #0.0 -> #0.0
Stream #0.1 -> #0.1

Press [q] to stop encoding
rotate pts:67000
rotate pts:133000
rotate pts:200000
rotate pts:267000
rotate pts:333000
rotate pts:400000
rotate pts:467000
rotate pts:533000
rotate pts:600000
rotate pts:667000
rotate pts:733000
rotate pts:800000
rotate pts:867000
rotate pts:933000
................

You will see that the pts output from ffmpeg rotate filter is 1000 times of ffplay rotate filter output.

It will cause problem for some filters which reply on pts such as subtitle filter.

regards
ChinShou?

comment:3 Changed 5 years ago by chinshou

The command used to generate the log are

ffmpeg -i 1.avi -vf "rotate" 2.avi
ffplay -vf "rotate" 1.avi

comment:4 Changed 5 years ago by michael

  • Resolution set to invalid
  • Status changed from new to closed

As far as i can tell you ignore the timebase, thus the bug is in your code. See sastes reply on how to use the timebase.

Note: See TracTickets for help on using tickets.