View Full Version : Virtualdub FPS error
juGGaKNot
23rd September 2013, 18:12
Hi guys.
I use Matroska.vdplugin (http://sourceforge.net/projects/fcchandler/files/Virtualdub%20Matroska%20plugin/) to open mkv files in vdub and convert them to uncompressed audio/video
I do get 5 extra green frames at the start of the video and i have to remove them and resync the audio but everything works fine.
By mistake i noticed that vdub uses a different FPS when opening the mkv ( on a small file it used 21 fps instead of 23.976, on a larger file only .2 fps less )
It looks ok but i'm wondering if i should let it use the fps it wants or override to the mkv FPS.
Is this normal ? If not what should i use for mp4 and mkv to uncompressed video ?
Cheers.
Guest
23rd September 2013, 18:20
Hi'm wondering if i should let it use the fps it wants or override to the mkv FPS. Yes, override it to the correct FPS.
Is this normal ? If not what should i use for mp4 and mkv to uncompressed video ? Obviously it is not normal. An option for you is DGDecNV which can decode MP4 and MKV and serve the frames via Avisynth. If you want to use VirtualDub for further encoding, you can open the Avisynth script in VirtualDub.
juGGaKNot
23rd September 2013, 19:13
An option for you is DGDecNV which can decode MP4 and MKV and serve the frames via Avisynth.
Ok, will look it up. I do this because sony vegas does not open the h264 files and i want to edit them.
Thnx.
LE : i used an avisynth script
DirectShowSource("c:\a.mkv", audio=true)
Instead of the plugin and it reads the fps right now, also no 5 green frames at the start of the video/audio sync problems.
Is this also viable ?
Guest
23rd September 2013, 20:48
Sure, it's fine for straight linear decode. If your script requires robust random access, however, you may find DirectShowSource() to be problematic.
Overdrive80
24th September 2013, 01:22
Ok, will look it up. I do this because sony vegas does not open the h264 files and i want to edit them.
Thnx.
LE : i used an avisynth script
Instead of the plugin and it reads the fps right now, also no 5 green frames at the start of the video/audio sync problems.
Is this also viable ?
I think that you should use:
Look below. Edited for avoiding confusion.
sneaker_ger
24th September 2013, 09:39
The splice operation is not suited for combining video and audio, AudioDub() is:
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
Gavino
24th September 2013, 09:54
Also, calling FFAudioSource after FFVideoSource causes the ffms2 index to be rebuilt, taking twice as long (see ffms2 docs), so call FFAudioSource first, as sneaker_ger does.
raffriff42
24th September 2013, 14:35
Try using fpsnum/fpsden if needed:A=ffvideosource("c:\a.mkv", threads=1, fpsnum=24000, fpsden=1001).assumefps(24000,1001)
B=FFAudioSource("c:\a.mkv")
AudioDub(A, B)
Overdrive80
24th September 2013, 14:54
The splice operation is not suited for combining video and audio, AudioDub() is:
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
Ups!! Is true. I´m stupid.http://img690.imageshack.us/img690/4425/6ld.gif
I dont know in what I am thinking. Sorry.
juGGaKNot
24th September 2013, 17:37
The splice operation is not suited for combining video and audio, AudioDub() is:
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
So this script ( manually edit .assumefps first to match video), open in vdub and save as avi ? ( i cut the mkv before using mkvmerge so no aditional cutting in vdub, just save as avi )
Try using fpsnum/fpsden if needed
For interlaced videos ?
raffriff42
24th September 2013, 18:13
> For interlaced videos ?
It may help to give FFVideoSource the proper framerate if you happen to know it - whatever that frame (or field) rate may be.
This can be done either by spec'ing frame rate in FFVideoSource or in AssumeFPS, or both. According to the docs (http://ffmpegsource.googlecode.com/svn/trunk/doc/ffms2-avisynth.html), FFVideoSource(fpsnum/fpsden) is only(?) used for VFR to CFR conversions, and may have no effect on CFR sources. If your source is CFR but FFVideoSource is reading the frame rate incorrectly, AssumeFPS should fix it.
juGGaKNot
24th September 2013, 18:53
AssumeFPS should fix it.
So mediainfo on the mkv, AssumeFPS in the avs with the right fps.
The other question remains : manually edit .assumefps first to match video, open the script in vdub and save as avi ?
Guest
24th September 2013, 19:41
The other question remains : manually edit .assumefps first to match video, open the script in vdub and save as avi ? Sure, if you are trying to make an AVI.
juGGaKNot
25th September 2013, 17:16
Sure, if you are trying to make an AVI.
Yep, uncompressed audio and video to edit in vegas.
Thnx to everyone.
sneaker_ger
25th September 2013, 17:53
You can probably open AviSynth scripts in Vegas without the intermediate file, either through a plug-in or a virtual file system (http://www.turtlewar.org/avfs/).
juGGaKNot
25th September 2013, 17:58
You can probably open AviSynth scripts in Vegas without the intermediate file, either through a plug-in or a virtual file system (http://www.turtlewar.org/avfs/).
Very interesting, will try.
LE :
Source Duration : 21s 443ms
Duration_FirstFrame : 4ms
Frame rate mode : Variable
Frame rate : 23.976 fps
Minimum frame rate : 23.833 fps
Maximum frame rate : 23.976 fps
With loadplugin("C:\ffms\FFMS2.dll")
B=FFAudioSource("c:\a.mp4")
A=ffvideosource("c:\a.mp4").assumefps(24000,1001)
AudioDub(A, B)
i get Duration : 21s 438ms
Frame rate : 23.976 fps
With loadplugin("C:\ffms\FFMS2.dll")
B=FFAudioSource("c:\a.mp4")
A=ffvideosource("c:\a.mp4", threads=1, fpsnum=24000, fpsden=1001).assumefps(24000,1001)
AudioDub(A, B)
I get Duration : 21s 563ms
Frame rate : 23.976 fps
So not the original duration on a vfr video.
LE2 : Also on cfr mkv file same thing.
Overdrive80
25th September 2013, 21:10
If your source is VFR, when you use:
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
I think that you is obtaining a CFR (Constant frame rate). If I am wrong that somebody correct me.
sneaker_ger
25th September 2013, 21:45
You are wrong. Any VFR->CFR conversion has to be done in the source filter because AviSynth does not know VFR and thus cannot pass on any timecodes following filters could work with. Using fpsnum and fpsden in ffvideosource is the easiest way out.
raffriff42
25th September 2013, 22:10
That's what I would have thought, too, since fpsnum/fpsden was supposedly created to handle VFR.
Question is, how do we know the source duration you were given is correct? I'd like to see some test sources with published durations.
Gavino
25th September 2013, 23:53
If your source is VFR, when you use:
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
I think that you is obtaining a CFR (Constant frame rate). If I am wrong that somebody correct me.
It depends what you mean.
Yes, you will get a constant frame rate (here 24000/1001 fps), because Avisynth does not support anything else.
However, it will simply play all the original frames one after the other at that rate, which will alter the duration if the source is really VFR. By contrast, using fpsnum/fpsden will take the timecodes into account and repeat or delete frames to preserve (as far as possible) the original timings while giving a constant frame rate output.
Overdrive80
26th September 2013, 02:35
It depends what you mean.
Yes, you will get a constant frame rate (here 24000/1001 fps), because Avisynth does not support anything else.
However, it will simply play all the original frames one after the other at that rate, which will alter the duration if the source is really VFR. By contrast, using fpsnum/fpsden will take the timecodes into account and repeat or delete frames to preserve (as far as possible) the original timings while giving a constant frame rate output.
I was referring to that video played will have a constant rate ignoring timescodes, and creating a non-smooth playback. Or not?
Gavino
26th September 2013, 11:00
I was referring to that video played will have a constant rate ignoring timescodes, and creating a non-smooth playback.
Yes, exactly.
juGGaKNot
26th September 2013, 17:23
As i said in the LE2 i tried a CRF mkv and i still got different duration..
LE : Tried a couple more cfr mkv files, same thing, 100-300ms off depending on length ( 1 minute video 300 ms off, 14 seconds video 100 ms off )
sneaker_ger
26th September 2013, 17:58
I cannot reproduce the issue. Can you upload a sample?
juGGaKNot
26th September 2013, 18:23
I cannot reproduce the issue. Can you upload a sample?
3g internet ( with very bad signal ) so not really ...
Different videos anyway, some are from this year, some are 8 years old.
Could it be because i used mkvmerge to split the video first ? In vdub on the frame rate control i do have the
change so video and audio duration match
box at 23.987 and not 23.976 as original
Also the new file has audio "Interleave, duration : 42 ms (1.01 video frame)" if that helps ( don't really know what that does )
sneaker_ger
26th September 2013, 18:24
Leave the vdub setting at "No change".
juGGaKNot
26th September 2013, 18:31
Leave the vdub setting at "No change".
I do, that was just an observation.
i tried without audio, just
loadplugin("C:\ffms\FFMS2.dll")
ffvideosource("c:\a.mkv").assumefps(24000,1001)
still not the same.
Also tried direct stream copy and not full render, the direct stream copy and full render durations are the same but still different from original.
sneaker_ger
26th September 2013, 18:40
ffvideosource without fpsnum and fpsden is not suited for VFR->CFR, as explained earlier. There will almost always be a slight difference (< length of one video frame) because the duration has to be a multiple of the length of a video frame. It's only a problem if it gets too big.
juGGaKNot
26th September 2013, 18:44
It's only a problem if it gets too big.
All the new samples are cfr mkv, i did not use the vfr mp4 i used yesterday.
Also, if i remove .assumefps(24000,1001) from the script and open it in vdub i get 23.974 fps and not 23.976 as mediainfo says.
Also tried directshowsource, same thing, duration not as original ( or FFMS2 ).
Lets try something else, can you give me a sample that works on your setup? 5mb size maximum if possible.
sneaker_ger
26th September 2013, 19:05
Before digging further into this:
1. Make sure you are using the latest ffms2 version. I'm currently on 2.19 (https://github.com/FFMS/ffms2/releases/download/2.19/ffms2-2.19.7z).
2. Always post your exact script
3. Always post exactly what you were expecting to happen and what happened instead.
It's kinda hard to follow you otherwise.
A CFR sample with 745 frames, 24/1.001 fps (~=31.073s):
http://www.file-upload.net/download-8117445/cfr_sample.mkv.html
juGGaKNot
26th September 2013, 19:17
I used 217 and 218 rc1, updated to 219.
It's fine on your sample.
Ok, i guess i have to upload a sample, uploading sucks on this internet.
juGGaKNot
26th September 2013, 19:36
Your sample is ok, as i said, my sample : sample.mkv (http://www.speedyshare.com/fSjnk/sample.mkv)
Duration : 6s 6ms
ffms 2.19 20130917
loadplugin("C:\ffms\FFMS2.dll")
B=FFAudioSource("c:\a.mkv")
A=ffvideosource("c:\a.mkv").assumefps(24000,1001)
AudioDub(A, B)
open in vdub, audio full processing mode default, video full processing mode default, save as avi.
Duration : 5s 923ms
Can you replicate this ?
sneaker_ger
26th September 2013, 19:55
Without delay the video track length is 5s 936.ms, if you normalize it to 24/1.001 it should be ~5s 923ms. ffms2's detects 23947/1001. The info of the h.264 stream is odd (time_scale=5000000, num_units_in_tick=104271, instead of 48000/1001). The mkv timecodes aren't clean either: 84ms delay + additional drift of 13ms over the course of the file (5s 923ms + 84ms = 6s 7ms, which would roughly fit the 6s 6ms). All in all 6s 19ms (+0.708333ms) according to the mkv timings.
/edit:
Changed explanation a bit.
juGGaKNot
26th September 2013, 20:08
6s 6ms is not the length of the video track. Its length is actually 5s 936ms, if you normalize it to 24/1.001 it should be ~5s 923ms. ffms2's detects 23947/1001. The info of the h.264 stream is odd (time_scale=5000000, num_units_in_tick=104271, instead of 48000/1001). The mkv timecodes aren't clean either: 84ms delay + additional drift of 13ms over the course of the file.
Bottom line, will the output look like the original ? I deal with multiple files everyday and i will run into files like this one for sure.
For example, you can find the sample file in this video (http://www.youtube.com/watch?v=WSnuHPwesiQ) at 05.25, it looks very good, no lag or skipped frames. It was made avi using the old Matroska.vdplugin and the uncompressed avi has 23.955 fps and not 23.976 as original
Will using ffms to get the right framerate be better ?
6s 6ms is the complete file/container.
On some files i get the same on the mkv and on the avi, that's why i was thinking there is something wrong.
If it's normal than ok :)
sneaker_ger
26th September 2013, 20:23
Will using ffms to get the right framerate be better?
ffms2 cannot get the fps correct automatically if the file is not strictly cfr. Even just a delay makes it technically vfr. AviSynth is not suited for this kind of conversion, neither is VirtualDub. I recommend working with the fpsnum and fpsden parameters to get a stricly cfr file so that you have no problems working with non-vfr software/containers.
juGGaKNot
26th September 2013, 20:37
I recommend working with the fpsnum and fpsden parameters to get a stricly cfr file
Ok, but how would i do this in practice ? mediainfo will say the file is cfr and the fpsnum and fpsden i force will be wrong, no ?
I see in one of your posts "ffms2's detects 23947/1001", can i use ffms2 to detect the frame rate ?
So my work will be like :
1 - use ffms2 to detect the frame rate
2 - modify fpsnum, fpsden and assumefps
3 - load the script in vdub
LE : Or should i not use it to get the fps, just convert the file to cfr first ( using the fps i get from mediainfo ? )
sneaker_ger
26th September 2013, 20:48
There is no easy way out, you would theoretically have to analyze the timecodes of all your files. Neither ffms2 or MediaInfo will give you the necessary informations reliably (maybe MediaInfo does in full analyze mode? Not sure). If you have a very slight deviation from the standard frame rates you can use AssumeFPS to smooth it out. If you have a delay you can either use fpsnum and fpsdem or use AssumeFPS and handle the delay separately (later at the muxing stage). If you have a truly VFR file and are aiming for CFR frameworks/softwares/containers (AviSynth/AVI/VirtualDub) using the fpsnum and fpsden is an easy workaround. You wouldn't usually combine fpsnum/fpsden and AssumeFPS but only use one of them depending on the problem at hand.
juGGaKNot
26th September 2013, 20:59
...
I see. I just noticed the problem by mistake not from actual sync problems so it should be ok.
Well thnx for your time.
Close thread i guess, i'm sure i'll be back after i read the avfs docs and try it out.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.