Log in

View Full Version : Encoding interlaced videos with MeGui


Hobojobo
11th September 2013, 12:23
I grabbed some VHS videos with virtualdub.
The vids are in 720x576 interlaced, lossless in avi-container on my HDD.
I want to transcode them with MeGui to x264, to play them in a blu-ray-player.


I take the x264:blu-ray high quality profile:

program --level 4.1 --crf 20.0 --keyint 24 --b-pyramid strict --ref 4 --slices 4 --qpmin 10 --qpmax 51 --vbv-bufsize 30000 --vbv-maxrate 40000 --aud --nal-hrd vbr --output "output" "input"

Do I have to tell MeGui, that the video is interlaced?
I looked through the settings. I did not find anything.
Or do I have to do manually?

Thanks.

Hobojobo
11th September 2013, 12:58
I took another look through the settings.
Under frame-type in the x264 config dialog I found the interlaced Mode options. :rolleyes:

I run the job with

program --level 4.1 --crf 20 --keyint 24 --b-pyramid strict --ref 4 --slices 4 --qpmin 10 --qpmax 51 --vbv-bufsize 30000 --vbv-maxrate 40000 --aud --nal-hrd vbr --tff --output "output" "input"

Now I get a warning:

interlace + weightp is not implemented.

Does MeGui take care of it? Or do I have to do that?

SeeMoreDigital
11th September 2013, 14:13
I grabbed some VHS videos with virtualdub.
The vids are in 720x576 interlaced, lossless in avi-container on my HDD.Out of interest. What video format did you capture it in and are you 100% sure it's actually interlaced?

EDIT: Do you want to generate an interlaced encode?

sneaker_ger
11th September 2013, 14:57
interlace + weightp is not implemented.

Does MeGui take care of it? Or do I have to do that?

x264 turns off weightp automatically in this case, you don't have to take care of it.

I want to transcode them with MeGui to x264, to play them in a blu-ray-player.

Are you aiming for a spec-compliant AVCHD/Blu-Ray structure?
1. If yes: your command-line does not follow all the rules (http://forum.doom9.org/showthread.php?t=154533), unless MeGUI silently does more than you have posted here. Might also make sense to reduce level/vbv and instead increase keyint and remove slices. Note that DVD medias require lower vbv values.
2. If no: you are restricting more than needed, unnecessarily reducing compression.

hello_hello
11th September 2013, 16:38
Are you using an old version of MeGUI and/or are you using the old, obsolete x264 encoder presets? If you are using the old presets you should delete them. They've been replaced by the "target playback device" option in the x264 encoder configuration. With a target playback device selected, the encoder configuration shouldn't let you change any of the x264 advanced settings where doing so isn't compatible with the selected device.

If you open the x264 configuration, load the defaults, choose CRF20 and select Blu-ray as the target playback device, you should end up with a command line which looks like this:

program --level 4.1 --bluray-compat --crf 20.0 --open-gop --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --output "output" "input"

I don't think I've ever re-encoded video without de-interlacing it, but adding an interlaced mode (TFF or BFF) should give you this:

program --level 4.1 --bluray-compat --crf 20.0 --open-gop --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --tff --output "output" "input"

Even though "--pic-struct" can be selected under the Misc tab, doing so has no effect on the command line. I assume it's covered by "--bluray-compat". Similarly....
"--b-pyramid", "--ref", "--keyint", "--aud", "--nal-hrd", "--qpmin" and "--qpmax" shouldn't be required either and the encoder configuration probably won't let you change most of them anyway if Blu-ray is selected as the target playback device.

If you're encoding for a Bluray player capable of playing MKV/MP4 files, I've never met one which won't happily play High Profile, Level 4.1 encoded with the default x264 settings, although I always de-interlace when encoding, especially since discovering QTGMC (http://avisynth.org/mediawiki/QTGMC). It's slow, but it'll de-interlace to full frame rate (50fps or 60fps), 99% of the time the output video will look better than the source, and it'll do a better job de-interlacing than your player/TV will. I just thought I'd mention it if the goal is maximum quality.

Hobojobo
11th September 2013, 17:28
Thank you for your answers. :stupid:

The material is interlaced, it is captured from VHS via a TerraTec G1, a USB Grabber.

A 45 min-VHS-C tape ends up in a 20 GB avi-file.
Now I want to compress it.
I chose x264 over mpg2 (quenc) because of the better quality, given a certain size.
I wanted to keep the interlace. I am interested in video encoding, but I am not an expert at all.
A blu-ray player can can handle it during playback.

I erased the profiles, and use the x264 config dialog, as you told me to do.

program --level 4.1 --bluray-compat --crf 20 --open-gop --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --tff --output "output" "input"

I am still getting the "interlace +weightp not implemented" warning.

I am doing some tests right now.

sneaker_ger
11th September 2013, 17:33
I am still getting the "interlace +weightp not implemented" warning.

As I said: that is nothing to worry about, x264 will automatically take care of it. The message is just an information, not really an error.

Hobojobo
11th September 2013, 18:03
@sneaker_ger

Ok. I got it.;)

@hello_hello

I am giving QTGMC a shot.
I am going with the presets. Or do I have to go into tweaking to get reasonable results?

Hobojobo
11th September 2013, 18:45
I encoded a 51 sec-clip.

1. interlaced clip,
program --level 4.1 --bluray-compat --crf 20 --open-gop --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --tff --output "output" "input"

compressed to 41 MB

2. same clip, using QTGMC( Preset="Slow" )
program --level 4.1 --bluray-compat --crf 20 --open-gop --slices 4 --vbv-bufsize 30000 --vbv-maxrate 40000 --output "output" "input"

compressed to 24 MB

3. same clip, using QTGMC( Preset="Placebo" ), very slow
same as above
compressed to 18 MB

The deinterlaced clip looks good. 18,24 vs 41 MB is quite difference, isn't it?

I think I am going with QTGMC. :)

Hobojobo
11th September 2013, 20:43
Arrrhhh!

The clips look very good.
But...

I want to play the clips on any standard blu-ray-player.
720x576p is not blu-ray conform, I found out.

Does it make sense to upscale to 720p before encoding to make the video blu-ray conform?
What would be the correct way to do that?

hello_hello
12th September 2013, 07:35
On QTGMC.... I pretty much always use the default settings for de-interlacing myself. ie QTGMC()
If memory serves me correctly, that's preset "slower". On occasion I reduce the sharpening a tad, although the difference is very subtle QTGMC(sharpness=0.7)
I've fiddled with some of QTGMC's settings but mostly stick with the defaults.
I've also discovered the joy of using QTGMC in progressive mode as a "pseudo" noise filter recently. I guess it's a different topic but the more I use it that way the harder I'm finding it to re-encode progressive video without it, unless the source is fairly "clean".

If you're wanting to author a Blu-ray compliant disc I can't help you there. I've never authored one in my life. The players here play MKV/MP4 files so that's all I ever use. I generally resize to square pixels during the process though, as unfortunately support for anamorphic video in MKV/MP4 isn't all that standard, so I play it safe.

Upscaling to 720p doesn't sound too silly an idea to me. It's not a big leap from 768x576 (or 786x576 if ITU resizing is used) to 1280x720 with black bars, it would allow you to crop any crud in the process, and wouldn't require forgoing QTGMC's goodness, but maybe someone who actually knows what they're talking about when it comes to authoring Blu-ray discs will come along and offer some cleverness.....

If it was me I'd possibly be tempted to re-encode it twice. Once to make a 50p MKV or MP4 using QTGMC, and a second time for Blu-ray players which don't play those sorts of files, although most do. Maybe the second time it could just be re-encoded as a standard DVD video disc so it'll play in anything. Just a thought...

Hobojobo
12th September 2013, 10:48
I am going to encode the material twice. That is exactly what I thought.


Once to make a 50p MKV or MP4 using QTGMC...

Should I go for 50p? When I deinterlace the clip, it will be 720x576 progressive 25p.
What is the benefit of 50p? Smoother playback?
How can I make the vid 50p?

hello_hello
12th September 2013, 11:54
QTGMC de-interlaces to full frame rate (50 or 60 fps). To de-interlace to half frame rate, it's just a matter of telling AVISynth to drop every second frame once QTGMC has done it's thing.

QTGMC()
SelectEven()

As you can imagine, keeping all the frames will result in smoother motion. There's some small samples here (http://forum.videohelp.com/threads/354092-Converting-video-frame-rates?p=2225116&viewfull=1#post2225116). QTGMC vs yadif at 25fps and 50fps. I think MeGUI calls the latter "Yadif (with Bob)" or something similar. Check out the motion when the camera pans about two thirds in. If you're in a hurry, Yadif at 50fps isn't terrible, but QTGMC is definitely better, especially when it comes to the harder to de-interlace bits. Compare the window blinds in the background when the camera moves.

Anyway, if you add QTGMC() to an MeGUI script via the script creator, and use the preview button, you should see the frame count at the top of the preview window double.

I know QTGMC is slow and a lot of people use it with a multithreaded version of AVIsynth but I've never bothered myself. Instead I just run two encodes at a time where possible to keep the CPU busy. Or, I'll make two copies of the same script, then add Trim() (or use MeGUI's AVS cutter under the Tools menu) so each copy is encoding around half the video, run them at the same time, then append the output files together with MKVMergeGUI when it's done.

hello_hello
12th September 2013, 12:41
PS. Personally I wouldn't encode the video at 720x576. That relies on it being displayed using the correct 4:3 aspect ratio on playback. If it isn't, it'll be displayed as though it contains square pixels, which means it'll be a little horizontally squished.

I used anamorphic encoding for DVD video all the time, but neither of the TV's with built in media players in the house obey aspect ratios in MKV/MP4 files, and one of the Blu-ray players also ignores them, so I gave up and now I resize everything to square pixel dimensions. The samples I linked to above were resized to 640x480 and the QTGMC versions will probably still appear to have more detail than the original. Obviously when encoding to author a DVD or Blu-ray video disc, it's a different story.

Hobojobo
12th September 2013, 22:45
Thank you for all the input.

My plan:
I am encoding the videos twice, avc using x264 and mpg2 using HCEnc to put on DVD.
In both cases I take QTGMC to deinterlace. :)