Hi guys,
I am working on a Matroska file I want to convert to PAL DVD (details here) but I am having some troubles with framerate.
MediaInfo seems to output a wrong value (23.220fps), GSpot outputs no value at all, DGAVCIndex says it's 25fps but the 25fps M2V transcoded video is not synchronized with the audio.
The only thing I could think of was to take the number of frames and divide it by the original lenght (in seconds), I got 23.998 fps.
Since this problem may come again in the future my question is:
generally speaking, is there a way/piece of software to positively check the framerate of Matroska files?
+ Reply to Thread
Results 1 to 20 of 20
-
-
only way to get an exact average frame rate, extract the time codes and calculate the frame rate from the time codes
side note: mediainfo isn't always right about whether a stream is vfr or cfr since it only looks at the first few time codes to determine if the stream is vfr or cfr.
If your stream has a frame rate of '23.22fps' there usually is either something wrong with it or the stream is vfr. -
Thanks for replying.
only way to get an exact average frame rate, extract the time codes and calculate the frame rate from the time codes -
mkvextract can be used to extract the time codes.
Timecode extraction:
The sixth mode finds the timecodes of all blocks for a track and outputs a
timecode v2 file with these timecodes.
the rest is simple math,...
don't know a tool that does the whole thing for you, but it's not hard to write assuming you know a programming language. -
Thank you, I'll give it a look as soon as I have the time.
As for your... assuming, you'd better don't.
-
Gspot doesn't work well with MKV, and I'm not surprised MediaInfo has problems with correctly reading VFR video. Most times it just says 'variable'. But since you tried 25 FPS, try 23.976 FPS. Most likely alternative.
I use ConvertXtoDVD most times for MKV>DVD conversion. As an experiment, I just tried to convert a MKV video that shows as variable framerate to a PAL DVD format. It took about 12 minutes on my PC. 190 fps conversion rate for the 1.5 hr video. It looks good quality to me, close in quality to the MKV video version that is about 800 MB. The audio, which was CBR AC3, was perfectly in sync throughout the DVD movie. -
Counting the frames is a good idea. You can do this with mkvinfo.
If your mkv is muxed with simple blocks (default):
Code:mkvinfo -v "video.mkv" |find /c "SimpleBlock (track number 1, 1 frame"
Code:mkvinfo -v "video.mkv" |find /c "Block (track number 1, 1 frame"
Now you can compare this with mediainfo and calculate the frame rate for cfr tracks.
The time codes method is also nice:
Code:mkvextract timecodes_v2 "video.mkv" 0:tcodes.txt awk "{n++}; END {print n,\"frames,\",$1/1000,\"sec,\",n/$1*1000,\"fps\"}" tcodes.txt
And if you need to know all different frame durations:
Code:awk "{f2=f1;f1=$1;if (NR>2) a[f1-f2]++}; END {printf(\"%8s %10s\", \"duration\",\"frames\n\");for (i in a) printf(\"%5s ms %9s \n\",i,a[i])}" tcodes.txt
I used awk from the GnuWin32 project.Last edited by Endoro; 23rd Dec 2013 at 16:03. Reason: Update.
-
Thanks to you too.
Problem is that I am not familiar with MKV files or MKVtoolnix.
But thanks for the precious help that you guys are giving me.
I'll see what I can get out of it asap. -
Here it is:
General
Format : Matroska
Format version : Version 1
File size : 3.08 GiB
Duration : 2h 44mn
Overall bit rate : 2 687 Kbps
Writing application : mkvmerge v2.2.0 ('Turn It On Again') built on Mar 4 2008 13:20:25
Writing library : libebml v0.7.7 + libmatroska v0.8.1
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 2h 44mn
Bit rate : 2 300 Kbps
Width : 1 280 pixels
Height : 544 pixels
Display aspect ratio : 2.35:1
Frame rate mode : Constant
Frame rate : 23.220 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.142
Stream size : 2.58 GiB (84%)
Writing library : x264 core 112
Encoding settings : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=2300 / ratetol=1.0 / qcomp=0.60 / qpmin=3 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00
Default : Yes
Forced : No
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 2h 44mn
Bit rate mode : Constant
Bit rate : 384 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 451 MiB (14%)
Default : Yes
Forced : No -
wow all this wasted time over a crappy encode. just start over and rip it again from the source. you do have the source right? this isn't about some numbskull's warez rip.
--
"a lot of people are better dead" - prisoner KSC2-303 -
MKVCleaver is probably the easiest way to extract MKV timecodes (it requires MKVToolnix be installed to work). Open the MKV, select both the video track and timecodes in the right pane. Use the Settings menu at the top to make sure it's set to "Timecodes/Timecodes Only", then click on extract. The video timecodes will be extracted to a text file.
If the video is constant frame rate 25fps, the timecodes should consistently be 40ms apart, so it'll look like this:
# timecode format v2
0
40
80
120
160
200
240
280
320
If the video is constant frame rate 23.976fps, I'm pretty sure the timecodes should alternate between 42 and 41ms in some sort of repeating pattern (although I can't remember the exact pattern). Like this:
# timecode format v2
0
42
83
125
167
209
250
292
334
375
417
459
501
If you're using a program for viewing text files which tells you the number of lines in the text file, you should be able to get the frame count just by checking which line number the final entry falls on. Subtract 2 from that, to account for the initial "# timecode format v2" entry, and the last entry which I'm pretty sure isn't a new frame.
For example, here's the last few entries from a timecodes file.
The last entry is on line 166151. Subtract two and the video contains 166149 frames.
Just to be certain, I indexed that MKV with ffmsindex and checked the frame count in MeGUI's preview. It agreed on the total number of frames.Last edited by hello_hello; 25th Dec 2013 at 14:57.
-
One thing you might want to try.....
Open the MKV with MKVMergeGUI. Select the video track and under the "format specific options" tab specify a frame rate. ie 23.976 or 25fps.... whatever you think it should be. Click on Start Muxing to output a new MKV. It should have a constant frame rate using the frame rate you specified.
If you do the above and save a new MKV while specifying 23.976 and then again specifying 25fps, does the audio stay in sync for either? If it doesn't stay in sync for either then you've probably eliminated the possibility of the original MKV having a constant 23.976 or 25fps frame rate. -
Thanks hello_hello.
I seem to have solved the problem on this specific file.
Anyway I made some tests, just to understand a little more (for the future).
I first tried the method suggested by selur but I must have made some mistake 'cause I wasn't able to get an output.
Then I went for Endoro's (timecodes) and I got the file I enclose as "test_01".
I don't know why the last line has that strange value, but according to the number of lines, the frame number matches the one I had found on my own.
I made another test with MKVcleaver and I got a completely different output ("test_02"). -
It's vfr . You can use a timecodes v2 to v1 converter to see more easily what is happening . v1 is easier to read for humans
Basically it's speeding up & slowing down in sections . VFR usually means frames are missing from the video (e.g. duplicate frames, dropped on purpose for coding efficiency purposes), so the display time for each frame in that section is longer(fps is lower) , thus the running time is the same compared to the CFR version
v1 timecodes are read like this: It goes start frame, end frame, frame rate . The 1st "assume" line means that frame rate is assumed unless other wise specified (29.97 in your example)
e.g For this example, frames 1-4 have a 18.08fps , 5-109 run at 23.976, etc...
Code:# timecodes format v1 Assume 29.970 1,4,18.981 5,109,23.976 110,113,18.981 114,12398,23.976 12399,12402,18.981 12403,19343,23.976 19344,19347,18.981 19348,54557,23.976 54558,54561,18.981 54562,73336,23.976 73337,73340,18.981 73341,117375,23.976 117376,117379,18.981 117380,117447,23.976 117448,117451,18.981 117452,117456,23.976 117457,117460,18.981 117461,160279,23.976 160280,160283,18.981 160284,160335,23.976 160336,160339,18.981 160340,160343,23.976 160344,160347,18.981 160348,160357,23.976 160358,160361,18.981 160362,163519,23.976 163520,163523,18.981 163524,170147,23.976 170148,170151,18.981 170152,170802,23.976 170803,170806,18.981 170807,171809,23.976 171810,171813,18.981 171814,200877,23.976 200878,200881,18.981 200882,204152,23.976 204153,204156,18.981 204157,206825,23.976 206826,206829,18.981 206830,209368,23.976 209369,209372,18.981 209373,212323,23.976 212324,212327,18.981 212328,236554,23.976
FFVideoSource("video.mkv", timecodes="timecodes_v2.txt")
It looks like the base frame rate of the original, original video was 23.976 (makes sense if this was a theatrical production, film production) . It's only minimally variable in a few small sections if you look at the V1 timecodes. I say this because most sections run at 23.976. Only a few tiny sections run at a different frame rate. A way to approximately (it won't be perfect) insert back those missing frames is with DirectShowSource() and ConvertFPS=true , to convert it back to CFR . Of course going to DVD requires CFR; as DVD-video doesn't support VFR
e.g
Code:DirectShowSource("video.mkv", fps=23.976, convertfps=true)
Last edited by poisondeathray; 29th Dec 2013 at 12:33.
-
@poisondeathray
thank you very much for the precious help.
As I wrote here it looks like I solved this thing simply speeding up the audio from 23.220 to 25.
I tested at several random points and it is synchronized.
If I can go this way, lucky me.
But I will find out if this is the case only by watching it on my SAP.
If, on the contrary, I am not that lucky and I have to go back to work, I'll keep in mind your tips.
Thank you. -
I'm not sure what's going on there. I don't have a VFR video handy to play with.
MKVCleaver does have an option under Settings/VFR Detection which can be enabled or disabled. Maybe that's why. I don't know how it's set by default.
Similar Threads
-
Syncronizing MKVs
By PonyoBellanote in forum Video ConversionReplies: 2Last Post: 5th Oct 2013, 07:48 -
Hardsubbing MKVs
By Zepwich in forum SubtitleReplies: 5Last Post: 19th Aug 2011, 16:07 -
Converting a "variable framerate" to constant framerate?
By vieo in forum Video ConversionReplies: 6Last Post: 2nd Sep 2010, 09:05 -
Joining MKVs
By Maajid in forum Video ConversionReplies: 0Last Post: 1st Aug 2010, 09:21 -
How do I convert xvid framerate 23,967 to xvid framerate 25.000?
By QuickstartDK in forum Newbie / General discussionsReplies: 16Last Post: 4th Nov 2009, 17:57