PDA

View Full Version : Framerate problem


ficofico
26th November 2007, 22:06
I've a problem with my program encoding (that convert symbian video in mp4/mpeg2)
Videos are mp4 variable framerate.
To catch the framerate I use mediainfo, that give me accurate result, for example:

Frame rate : 22.609 fps
Minimum frame rate : 6.079 fps
Maximum frame rate : 41.209 fps

The framerate it's true, because if I encode with this setting, the video seem to go well, but in some part, video isn't in synchronize with audio.

For example if I use this script:

setmemorymax(1024)
FFmpegSource("originale.mp4",seekmode = 1,ppquality = 6)
assumefps(mediainfo framerate)
converttoYv12()
MotionProtectedFPS(60, iterate = 12)


The result it's not in synch, but even if I cancel string with Motionprotectedfps, result it's better, but not in synch.

After days & days of experiment, I've found that if I encode the original video with Super( video converter) at 25 or 30 fps before and after with my program, audio and video running well in synchronize.

But.... if I look at the log file of Super, I can see that the framerate it's the same of mine catching with mediainfo : (super probably use mediainfo too to find framerate)

Frame rate : 22.609 fps
Minimum frame rate : 6.079 fps
Maximum frame rate : 41.209 fps


Why if the framerate it's exactly the same, my encoding and super encoding give me different result ?:thanks:

IanB
26th November 2007, 22:38
Avisynth does not support Variable Framerate (VFR).

Super knows how to do a reasonable VFR to Constant Framerate (CFR). It will have duplicated frames in the 6.079 parts and discarded frames in the 41.209 part.

The AssumeFramerate(22.609) tells avisynth that every frame has 44.23milliseconds duration and matches 44.23ms of audio with it.

Frames that are 6.079fps should have 164.5ms of audio, frames that are 41.209fps should have 24.27ms of audio. So you see at any point in your stream the audio video sync is fluctuating wildly. Only at the begining and the end are they in sync.

DirectShowSource() has an option ConvertFPS=True to alleviate this issue. The author of FFMpegSource() has strong negative opinions about such VFR to CFR conversions.

There are many hacks available to preprocess/postprocess VFR material that use timecode files, etc to achieve good results.

:search: try VFR CFR mpeg4 timecode

ficofico
26th November 2007, 23:41
Thanks IanB, I've read this wiki [URL="http://avisynth.org/mediawiki/VFR#encoding_to_vfr_.28mkv.29"]WIKI[/URL ]
and I've tried to do something, but i havem't understand how can I use timecode in avisynth.
I've muxed (now with megui, but I'm searching for a command line) the originale mp4 file into an mkv container. After with this string:

mkv2vfr.exe input.mkv output.avi timecodes.txt

I've generated the avi file and timecodes.... And now?

:script: How can i use this information for avisynth encoding using FFmpegSource and not directshowsource? very thanks....

[P]ako
27th November 2007, 00:40
Do trims, for example:


FFmpegSource("originale.mp4")
trim(1,3000).AssumeFPS(29.9699).ChangeFPS(23.976)
++ trim(3001,3500).AssumeFPS(11.9940).ChangeFPS(23.976) \
++ trim(3501,10000).AssumeFPS(23.2958).ChangeFPS(23.976) \
++ trim(10001,10500).AssumeFPS(42.9625).ChangeFPS(23.976) \

ficofico
27th November 2007, 10:19
but i have to do this in batch mode, how can i trim all file? i've senn that it's possible to recode to avi 120 fps, but I had trouble with this process... Any suggestion?

ficofico
1st December 2007, 09:23
I need your aid.....

I've tried all the solution that my brain it's able to suppose, but I wasn't luky.

I've discovered here this command line program, time2avs, that can make an avs script starting from timecode v1
I've modified the avs file in this way:

Timecode-avs example script (ficofico2.interfree.it/timecode.avs)
Unfortunately, my videos are always slow, too slow!!! and video at the end it's too fast, like forwarding in dvd's !!

This it's the original video

VIDEO (http://ficofico2.interfree.it/originale.mp4)

In this way some angel can aid me because i've googled and googled and googled for days but it seem that vfr videos aren't impossible to handling well, Thanks.

ficofico
1st December 2007, 09:41
the purpose it's to smooth this videos using motionprotectedfps or MVFlowFps2 manteining the audio - video sync. I've also modified the upper script avs with motionprotectedfps instead changefps , and the video become very smooth, but slow, and even changing the framerate i haven't success

ficofico
1st December 2007, 13:26
:logfile:

buzzqw
1st December 2007, 14:06
As IanB said avisynth isn't well suited for vfr files..

but using mencoder (as super does) the problem is gone

i tried AutoMen, forcing "Change framerate to 25", and the audio/video seems in synch

BHH

ficofico
13th December 2007, 21:54
There's a thing that I haven't understand.
I have a variable framerate video, if I recode into a new cfr video and after use motionprotectedfps, the video became smooth.
If I trim every second and I use motionprotectedfps In this (example way) the video became very slow, why?:thanks:

source=ffmpegsource("originale.mp4",vtrack = -1, atrack = -2)
audio=ffmpegsource("originale.mp4",vtrack = -2, atrack = -1)
video0 = source.trim(0,0).AssumeFPS(7.503752).motionprotectedfps(60, iterate=8)
video1 = source.trim(1,1).AssumeFPS(29.732409).motionprotectedfps(60, iterate=8)
video2 = source.trim(2,2).AssumeFPS(30.060120).motionprotectedfps(60, iterate=8)
video3 = source.trim(3,3).AssumeFPS(25.316456).motionprotectedfps(60, iterate=8)
video4 = source.trim(4,4).AssumeFPS(16.528926).motionprotectedfps(60, iterate=8)
video5 = source.trim(5,5).AssumeFPS(30.991736).motionprotectedfps(60, iterate=8)
video6 = source.trim(6,6).AssumeFPS(29.182879).motionprotectedfps(60, iterate=8)
video7 = source.trim(7,7).AssumeFPS(28.355387).motionprotectedfps(60, iterate=8)
video8 = source.trim(8,8).AssumeFPS(15.353122).motionprotectedfps(60, iterate=8)
video9 = source.trim(9,9).AssumeFPS(30.060120).motionprotectedfps(60, iterate=8)
video10 = source.trim(10,10).AssumeFPS(30.643514).motionprotectedfps(60, iterate=8)
video11 = source.trim(11,11).AssumeFPS(14.895730).motionprotectedfps(60, iterate=8)
video12 = source.trim(12,12).AssumeFPS(30.643513).motionprotectedfps(60, iterate=8)
video13 = source.trim(13,13).AssumeFPS(29.527560).motionprotectedfps(60, iterate=8)
video14 = source.trim(14,14).AssumeFPS(30.060120).motionprotectedfps(60, iterate=8)
video15 = source.trim(15,15).AssumeFPS(30.425963).motionprotectedfps(60, iterate=8)
video16 = source.trim(16,16).AssumeFPS(14.866204).motionprotectedfps(60, iterate=8)
video17 = source.trim(17,17).AssumeFPS(30.769231).motionprotectedfps(60, iterate=8)
video18 = source.trim(18,18).AssumeFPS(29.182879).motionprotectedfps(60, iterate=8)
video19 = source.trim(19,19).AssumeFPS(15.182186).motionprotectedfps(60, iterate=8)
video20 = source.trim(20,20).AssumeFPS(28.985507).motionprotectedfps(60, iterate=8)
audiodub(video,audio)

IanB
13th December 2007, 23:09
Trim(0, 0) is the whole clip. You want Trim(0, -1) which is 1 frame staring at 0.

And you are wasting your time feeding 1 frame clips into motionprotectedfps(), it needs multiple frames to detect motion and interpolate new intervening frames.

It may help you visualize the problem if you think about the duration of each frame in milliseconds instead of the reciprocal which is fps. Draw it on a piece of paper with each frame placed in the correct time position.