Log in

View Full Version : H.264 MKV that has VFR (variable frame rate)


g00gy
5th April 2007, 01:15
Ive been trying to encode this MKV file into a DVD format but it has h.264. ive extracted the h.264 file from the mkv with mkv extract and converted it into AVI with AVC2AVI. But it is never in sync. So i came to the conclusion that this file has (VFR variable frame rate). I have never encountered such a thing before and only heard it recently. how do i deal with this problem is it impossible.

Please help im really perplexed about what action i should take to encode this file succesfully into a MPEG-2.


P.S. is there a way to convert AAC files.

giandrea
5th April 2007, 02:23
Ive been trying to encode this MKV file into a DVD format but it has h.264. ive extracted the h.264 file from the mkv with mkv extract and converted it into AVI with AVC2AVI. But it is never in sync. So i came to the conclusion that this file has (VFR variable frame rate). I have never encountered such a thing before and only heard it recently. how do i deal with this problem is it impossible.

Please help im really perplexed about what action i should take to encode this file succesfully into a MPEG-2.


P.S. is there a way to convert AAC files.

I had the same problem as you, only that I am on Mac and don't have Avisynth. Search the forum for VFR and you will find the answer. As for me... I still haven't come out with a solution... -_-

issa
5th April 2007, 02:32
I think if you have avisynth, ffdshow & haali filter installed, you can
using avs script as input file. In the script, the source input command will look like "DirectShowSource("file.mkv",fps=29.97,convertfps=true)", the fps=29.97 just for example, use whatever frame rate that you think the video had.

Blue_MiSfit
5th April 2007, 02:39
This looks like a rule 6 violation to me...

g00gy
5th April 2007, 10:08
Yeah im searching i think ive found the solution. mkv2vfr im gonna try it out.

This looks like a rule 6 violation to me...

I dont see how its been violated. there has been no word of warez or any illegal activity.

g00gy
5th April 2007, 17:24
MKV2VFR gives me an error it says "no video tracks found"!?

anyone know the problem?

fields_g
5th April 2007, 17:57
I've been involved in VFR conversations in the past. If you look around, you will see your solution in 3 forms.

1) Convert the framerate to a common multiple (eg 24/30 ->120)
2) Pick the most common and convert the sections that do match that rate.
3) Maintain the VFR by using timecode file and the MKV file container.

In the past I tried #3 and got it to work properly. However since I like the ease of MeGUI and would rather do a 1-pass CQ encode and don't mind having mp4 compatibility, I have moved to method #2 by having MeGUI AVC creator detect my source as "Hybrid film/interlaced. Mostly Film" and hard set the deinterlace to TIVTC. I've found (and mentioned in other threads) that even though TIVTC +TDeint(EDI) theoretically should be a better option, I do have a few scenes that don't deinterlace and others that have some very strange artifacts. Otherwise, I see no difference. When doing this, MeGUI makes a script similar to:
DGDecode_mpeg2source("C:\Documents and Settings\user\Desktop\stuff.d2v")
tfm(order=1).tdecimate(hybrid=1)
#crop
#resize
#denoise


It work rather nicely. My suggestion. Play with some scripts. Preview them. Go through them frame by frame in various framerate sections and check what it is doing. After being comfortable with that, then encoding will be easy.

g00gy
5th April 2007, 18:06
thankyou for your suggestion.

but im trying to get the timecode with MKV2VFR.
this is the syntax "mkv2vfr matroska_file avi_file vfr_file" so i write the name of the file and the avi file to be created and the VFR file to be created. but it gives me a message saying "no video tracks found". but my MKV does have a video track...

ive searched on google and this forum for a long time and im still confused.

fields_g
5th April 2007, 18:15
I did this with a two pass approach. I think there is a 1 pass, but didn't explore that too much. This is what I tried in the past that seemed to work:

First Pass:
mpeg2source("E:\VIDEO\VIDEO_TS\video.d2v")
tfm(d2v="E:\VIDEO\VIDEO_TS\video.d2v",output="E:\VIDEO\VIDEO_TS\tfm.txt")
tdecimate(mode=4,tcfv1=false,output="E:\VIDEO\VIDEO_TS\tdec.txt")

# this next line assumes the source is dvd 720x480
# and crops it down to 32x32 to save processing time
# since we're only interested in letting tfm/tdecimate
# gather info and not the actual result

crop(344,224,-344,-224)

Second Pass:
mpeg2source("E:\VIDEO\VIDEO_TS\video.d2v")
tfm(d2v="E:\VIDEO\VIDEO_TS\video.d2v",input="E:\VIDEO\VIDEO_TS\tfm.txt")

# If your source is not anime or cartoon then add
# vfrDec=0 into the line below
tdecimate(mode=5,hybrid=2,tcfv1=false,vfrDec=0,input="E:\VIDEO\VIDEO_TS\tdec.txt",tfmIn="E:\VIDEO\VIDEO_TS\tfm.txt",mkvOut="E:\VIDEO\VIDEO_TS\timecodes.txt")

# add other processing below, such as filtering
# cropping, resizing, color correction, etc...


I ran the first pass in VirtualDubMod or something that just played it, closed it, then ran the second pass into x264. Finally muxed video, audio, and timecodes into MKV. Does this help out at all?

g00gy
5th April 2007, 18:19
im sorry but this is even more confusing. are you telling me that virtual dub can deal with VFR? becuase i dont even know how to get timecode since mkv2VFR is not working. all i want is to extract a H.264 file from an MKV file whilst also keeping the video as it was. becuase when i use mkvextract to extract the video it comes out; out of sync.

I assume your telling me how to encode a file. but how can i encode it if its within a MKV?

foxyshadis
5th April 2007, 18:49
thankyou for your suggestion.

but im trying to get the timecode with MKV2VFR.
this is the syntax "mkv2vfr matroska_file avi_file vfr_file" so i write the name of the file and the avi file to be created and the VFR file to be created. but it gives me a message saying "no video tracks found". but my MKV does have a video track...

ive searched on google and this forum for a long time and im still confused.

But not a vfw video track. You can use mkvextract instead, which will give you the timecodes, but will not give you an avi; you still have to use directshowsource on the original. (Or try out AVCSource on the raw.)

Get your video. Do stuff to it. Don't worry about sync. When finished, mux it back in to mkv or mp4 with the audio and timecodes, and magically sync is restored. If you're cutting it up, well, things will get a bit difficult, but by referencing the timecodes you can find out where to cut the audio. Or you can cut the audio based on a video with convertfps=true, and cut the video with convertfps=false, to make both happy.

g00gy
5th April 2007, 20:38
mux it back in to mkv or mp4 with the audio and timecodes

but i want to convert it into either divx xvid or mpeg2 so i can play it on my dvd player. so i cant make it back into mkv.

P.S. im new to "timecodes" do all encoding software support them and will i be able to create a divx, xvid or mpeg2 with them?

fields_g
5th April 2007, 22:12
yea... sorry to lead you astray...

In short, I don't have your answer, however, I might be able to help a little. Divx or Xvid in a dvd player? You are talking in an AVI container? As far as I know, AVI doesn't support VFR. If AVI is the method that you choose, it will need a conversion to CFR.

If you choose to maintain VFR, I believe your solution will need to beMPEG2 in the end.

g00gy
5th April 2007, 23:16
so do you have any idea on how to extract H.264 from an mkv whilst keeping the VFR in tact. and how do i create the mpeg2 with the VFR do i use a timecode.

please someone help this is all so confusing and ive been trying to do this for a long time.

foxyshadis
6th April 2007, 00:54
For NTSC, create this avisynth script and load it into your mpeg2 encoder:
DirectShowSource("file.mkv",fps=59.94,convertfps=true)
LanczosResize(720,480) # addborders if needed
Separatefields().SelectEvery(4,0,3).Weave()

Encode as interlaced, TFF, with the proper aspect ratio. For PAL, just make the rate 50 and the height 576.

g00gy
6th April 2007, 10:31
For NTSC, create this avisynth script and load it into your mpeg2 encoder:
DirectShowSource("file.mkv",fps=59.94,convertfps=true)
LanczosResize(720,480) # addborders if needed
Separatefields().SelectEvery(4,0,3).Weave()

Encode as interlaced, TFF, with the proper aspect ratio. For PAL, just make the rate 50.

so this will convert my mkv or H.264. but it will be difficult for me to encode it if i cant extract it from the mkv with VFR. Let me just highlight that the first thing i want to do is extract the H.264 from the mkv with VFR so i can encode into mpeg2 without losing sync.

foxyshadis
6th April 2007, 13:14
DirectShowSource("file.mkv",fps=59.94,convertfps=true) <-- converts to CFR.

Don't extract! Don't make extra unnecessary work for yourself! Avisynth, or rather directshowsource, already has a method to bring VFR into CFR, convertfps. (The convertfps() function is totally unrelated.) You only extract if you're going back to a VFR container and don't want to recreate the whole VFR project. You're not, you only want to create a hybrid DVD, which my script will do given any file, no matter what framerate it has.

g00gy
6th April 2007, 20:13
DirectShowSource("file.mkv",fps=59.94,convertfps=true) <-- converts to CFR.

Don't extract! Don't make extra unnecessary work for yourself! Avisynth, or rather directshowsource, already has a method to bring VFR into CFR, convertfps. (The convertfps() function is totally unrelated.) You only extract if you're going back to a VFR container and don't want to recreate the whole VFR project. You're not, you only want to create a hybrid DVD, which my script will do given any file, no matter what framerate it has.

Ok im a huge noob so please excuse my simple questions :)

So i should use the script you suggested to convert my mkv video file?

1.but what program should i use to convert?
2.which mpeg2 encoder to use?
3.how do i make the script?

Adub
7th April 2007, 04:44
1.HCenc
2.HCenc
3.Check out Avisynth's main website for a tutorial on beginning script usage. Basically paste the script into notepad, adjust the source to your file, save as "filename.avs", open in HCenc and you are good to go!

Edit: Oh, and make sure you have Avisynth installed!

g00gy
7th April 2007, 12:04
well its converting now... thanks to all of you. However I had to add more to the script like add YV12 or something like that since thats what HCenc recomended. but i just realized that this MKV has two audios one english the other japanese so which one is it converting and how can i change what it convert?

EDIT: Actually im gonna start it up at night becuase his will probably take a couple of hours

foxyshadis
7th April 2007, 14:09
Whichever one's default. You can load it into virtualdub and press play to listen. HCenc won't touch audio though, so you have the chance to extract the tracks separately and convert the one you want to AC3 yourself.

g00gy
7th April 2007, 16:32
so if i want audio in mpeg2 it must be ac3? how can i change the default first audio track so that HCenc picks the english.

Because if i seperatley convert the audio and re dub the video then i might lose sync due to VFR.

BTW why does HCenc only let me save my files as "m2v" is that also mpeg2?

foxyshadis
7th April 2007, 22:31
HCenc won't pick anything, it'll totally ignore the audio. m2v is the video stream half of the dvd. BeHappy is one method of converting audio; your choices are mp2, ac3, dts, and lpcm, though ac3 is generally the preferred format. The audio that does end up in the avisynth will be chosen by the splitter; if it's haali's, it'll be based on your language settings.

Since this is now CFR, demuxing audio won't hurt sync, except for the possibility of an offset at the start of the track.

Adub
7th April 2007, 23:22
Chances are that you will have to convert the audio separately. When you do so, that is when you will choose which track to convert. Or both, I suppose.

g00gy
8th April 2007, 01:57
Since this is now CFR, demuxing audio won't hurt sync, except for the possibility of an offset at the start of the track.

So CFR has no VFR?

killerhex
8th April 2007, 02:03
i use megui to encode the video only using automated 2 pass with a suitable bitrateand remux it with the audio and subs no desync yet

i encode to xvid

g00gy
8th April 2007, 11:48
HCenc just froze on the second pass! its not doing anything. its still responding but its not encoding. what gives.

Malow
11th April 2007, 00:45
a forum member modified the dgpulldown, so, we can make an mpeg2-vfr.

no need for "processing" or modifying framerate.

extract avi/timecode, convert to mpeg2, add "variable pulldown" and author.

http://forum.doom9.org/showthread.php?t=110256