Log in

View Full Version : Video lagging when using H.264/x264


CCS
30th August 2011, 20:56
Hello all!

I like to make short movies from my Source game demos (Team Fortress 2, Left 4 Dead 2). The most stable and reliable method for me is producing TGA images and recording the audio as WAV in game, then compressing and combining the two using Virtual Dub. The outcome is satisfying.

I use the ffdshow video codec (ffdshow tryouts Beta 7; H.264, FourCC: X264, 1 pass - quality) and Lame MP3 (192 kbit/s). The VD version is 1.9.11 32 bit, OS is Win 7 Pro 64 bit.

Everything worked fine, until I upgraded my PC (including reinstalling Windows and updating ffdshow). Now, using all the settings I used before (I think), the audio starts approx. 2 seconds before the video when watching the finished avi, even for clips lasting only 20 seconds or so. When I use another codec like XVID (also via ffdshow), everything is perfectly in sync, although the quality is not as good.

So, does anyone have an idea what I could do about that? I am aware that using avi containers for x264 is not the most modern thing to do, but VD doesn't seem to support mkv and AVIDemux can't open TGA files? Also, it has worked before.

nurbs
30th August 2011, 21:40
The ffdshow guys recommend that you don't use their encoders because there are some problems with them, so your trouble might have something to do with that. They have in fact removed most encoders in more recent versions, including x264 IIRC. Apart from that the x264 version included in the ffdshow tryouts beta 7 is extremely outdated. You are missing at least 18 months of progress using that. For x264 encoding you should either directly use x264.exe (http://x264.nl/), some application that natively supports it or x264vfw if you have to use VirtualDub.

You can use Avisynth (http://sourceforge.net/projects/avisynth2/) as a frameserver if you want to encode the TGA files with x264.exe.

CCS
1st September 2011, 16:35
I tried x264vfw and it works fine! Much better quality than with XVID, and the video lag is gone. I didn't realize even the ffdshow tryouts were this outdated. Thanks for your help!

Just out of curiosity, is there no simple GUI program that supports TGA input and x264 in mkv output? Would I have to use console command programs for that?

nm
1st September 2011, 19:15
Just out of curiosity, is there no simple GUI program that supports TGA input and x264 in mkv output?

Avidemux can read some image formats, but apparently not TGA.

Target Practice
1st September 2011, 23:12
Just out of curiosity, is there no simple GUI program that supports TGA input and x264 in mkv output? Would I have to use console command programs for that?You can use Avisynth (http://sourceforge.net/projects/avisynth2/) as a frameserver if you want to encode the TGA files with x264.exe.MeGUI is an easy to understand GUI for avisynth to x264.

nm
1st September 2011, 23:59
MeGUI is an easy to understand GUI for avisynth to x264.

It probably doesn't set up imagesource automatically though? So you'll need to learn some basics of AviSynth scripting.

TheRyuu
2nd September 2011, 01:29
Just out of curiosity, is there no simple GUI program that supports TGA input and x264 in mkv output? Would I have to use console command programs for that?

Write your avisynth script with AvsP (found in the avisynth section).

Best way to encode using x264 is on the command line (cmd.exe). It's very easy:
x264.exe --crf 18 --preset slower -o X:\path\to\output.mkv X:\path\to\input.avs
You're free to change the crf to whatever you deem to be of acceptable quality and/or size. You can change the preset as well to something faster or slower to what you feel you want (you can do x264 --help to see a list of available presets and basic options).
Mux in the audio with mmg (mkvmergegui available with mkvtoolnix).

That was easy right? :p

Edit:
Also ffmpeg has dshow input now which might be something to look into with your capturing (it might be beneficial to capture to some lossless format instead of the tga's).

CCS
4th September 2011, 19:10
Thanks for the suggestions! I will try them out when my current method doesn't please me anymore for some reason.

The Source engine only supports TGA output. The direct movie conversion on the fly is currently broken, until Valve decides to fix it. I guess I could record my movies using FRAPS or so, but using the TGA method the movie framerate is guaranteed to stay stable. And with lossless conversion there is no difference between ingame graphics and video visible to me. So this will do just fine for now, I think.