[FFmpeg-user] Mixed telecined non-telecined media to constant frame rate.
Nicholas Robbins
nickrobbins at yahoo.com
Tue Jan 21 20:19:34 CET 2014
> On Tuesday, January 21, 2014 12:37 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> > Nicholas Robbins <nickrobbins <at> yahoo.com> writes:
>
>> Indeed if I don't put in any fps filter I see that I
>> have frames at the following pkt_pts's
>> ...
>> 20020
>> 20053
>> 20087
>> 20120*
>> 20187
>> 20220
>> 20254
>> 20287*
>> 20354
>
> I didn't look at the source but it doesn't seem absurd
> to me (although probably buggy) that this is what
> pullup produces (fieldmatch,decimate are worse imo
> because they simply ignore the input timestamps).
Yeah, if the material was all telescened then, yes this would be perfect, a -r could fix the spacing. I suppose I want a "smooth pts" filter that would smooth out the pts of the frames. I don't know how this information is stored, if it was two arrays oldpts[i] and newpts[i] then something like
newpts[i] = Average(oldpts[i-N+1] ... oldpts[i]) + (oldpts[i]-oldpts[i-N+1])/2 -1 works for some made up numbers.
N would be something like 30 or so I suppose. You would need a smaller timebase for this to work.
Is there a way to set the timebase ? I see at http://ffmpeg.org/ffmpeg-all.html#Codec-Options that there is a time_base option, but I can't figure out how to set it.
> Does it work better with mencoder -ofps 60 or do you
> see the same issues?
Again, stranger and stranger.
$mencoder short.mkv -oac copy -vf pullup -ovc x264 -ofps 60000/1001 -o mencoder.mpg
produces a lot of this:
2 duplicate frame(s)!
Pos: 23.5s 782f (100%) 28.12fps Trem: 0min 3mb A-V:0.003 [412:0]
1 duplicate frame(s)!
Pos: 23.5s 783f (100%) 28.14fps Trem: 0min 3mb A-V:0.007 [412:0]
1 duplicate frame(s)!
Pos: 23.5s 784f (100%) 28.15fps Trem: 0min 3mb A-V:0.010 [412:0]
1 duplicate frame(s)!
Pos: 23.5s 785f (100%) 28.18fps Trem: 0min 3mb A-V:0.013 [412:0]
2 duplicate frame(s)!
Pos: 23.6s 787f (100%) 28.20fps Trem: 0min 3mb A-V:0.003 [411:0]
1 duplicate frame(s)!
Pos: 23.6s 788f (100%) 28.20fps Trem: 0min 3mb A-V:0.007 [411:0]
1 duplicate frame(s)!
Pos: 23.7s 789f (100%) 28.18fps Trem: 0min 3mb A-V:0.010 [411:0]
1 duplicate frame(s)!
Pos: 23.7s 790f (100%) 28.21fps Trem: 0min 3mb A-V:0.013 [411:0]
2 duplicate frame(s)!
Pos: 23.8s 792f (100%) 28.23fps Trem: 0min 3mb A-V:0.003 [410:0]
in the telecined section. ffprobe -show_streams -select_streams s -count_frames mencoder.mpg produces:
Input #0, avi, from 'mencoder.mpg':
Metadata:
encoder : MEncoder SVN-r36370 (Gentoo)-4.7.3
Duration: 00:00:36.04, start: 0.000000, bitrate: 1048 kb/s
Stream #0:0: Video: h264 (High) (h264 / 0x34363268), yuv420p, 720x480 [SAR 427:360 DAR 427:240], SAR 4096:3453 DAR 2048:1151, 59.94 fps, 59.94 tbr, 59.94 tbn, 119.88 tbc
Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 448 kb/s
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1001/120000
codec_tag_string=h264
codec_tag=0x34363268
width=720
height=480
has_b_frames=2
sample_aspect_ratio=4096:3453
display_aspect_ratio=2048:1151
pix_fmt=yuv420p
level=31
timecode=N/A
id=N/A
r_frame_rate=60000/1001
avg_frame_rate=60000/1001
time_base=1001/60000
start_pts=0
start_time=0.000000
duration_ts=2160
duration=36.036000
bit_rate=N/A
nb_frames=2160
nb_read_frames=1052
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
[/STREAM]
Finally
$ ffprobe -show_frames -select_streams v mencoder.mpg | grep "dts=" | cut -d"=" -f2 > tc.txt
(all video frames have pkt_pts=N/A)
and then loading that into a spreadsheet and taking differences of squential frames gives the following pattern in the originally 30fps section 1,2,2,2,2,1,2,2,2,2,1,2....
in the telescened section it produces this 1,2,3,3,1,2,3,3,1,2,3,3,...
looking at it with ffplay, I don't see any duplicated frames.
More information about the ffmpeg-user
mailing list