View Full Version : Encoding to h264 from VHS tape
knari
17th January 2015, 17:11
Hi. I have some rips from my VHS camera. Honestly the quality isn't too good but I want to store these videos as a history of my family. And now I decided to encode them into h264. For this I use megui. Video is interlaced.
And I have two questions:
There are a lot of different presets in megui, I cannot understand what is better to use for such origin of the video. Could you please advise or show me a link to similar topic here?
I tried to use some presets, including "x264: Bluray - 2pass" and "x264: Unrestricted 2pass Insane". But I see some strange problem in the resulting video. It looks like FPS is lower than in the origin. In the origin all movements are smooth but in the resulting video I can recognize that it's not so smooth. Does anybody know what is a reason of the problem?
Thank you in advance.
Emulgator
17th January 2015, 20:02
Post two short samples of your source and the encode.
knari
17th January 2015, 21:20
Original: https://dl.dropboxusercontent.com/u/6089180/10avi0001_cut_ep1.avi
Result: https://dl.dropboxusercontent.com/u/6089180/10avi0001_cut_ep1.avi-muxed.mkv
Emulgator
18th January 2015, 00:48
The source is PAL-DV 720x576@25i, so interlaced.
Your encode ended up being 696x562@25p, Framerepeats all over the place.
I don't know what script you invoked, but it looks horrible.
Do not crop-resize and then deinterlace, or you do harm this content.
Keep interlaced as interlaced or if you must have it progressive, bob up to 50p.
It depends what device shall play the reencode.
If it is DVD, keep parameters.
I would (Q)TGMC to 50p, crop-resize to 720x576 and reinterlace to 25i. Looks cleaner.
My suggestion would be to aim for a progressive blu-ray,
so (Q)TGMC to 50p, crop-resize to 960x720,
add black pillars to 1280x720 and encode as 1280x720@50p Blu-ray.
5 lines Avisynth script may helps lots here.
MeGUI on its own will not optimize for that.
knari
18th January 2015, 10:35
I am a newbie to all these things, this is why I use megui and presets.
This is AviSynth script used:
# Set DAR in encoder to 27 : 20. The following line is for automatic signalling
global MeGUI_darx = 27
global MeGUI_dary = 20
LoadPlugin("C:\Program Files (x86)\megui\tools\ffms\ffms2.dll")
FFVideoSource("D:\video\rip\10avi0001_cut_ep1.avi", fpsnum=25, fpsden=1, threads=1)
#deinterlace
crop(16, 4, -8, -8)
#resize
#denoise
And this are params for x264 produced by a preset:
program --pass 2 --bitrate 2180 --stats ".stats" --slow-firstpass --deblock -1:-1 --bframes 4 --b-adapt 2 --b-pyramid none --ref 16 --qpmin 10 --qpmax 51 --merange 32 --me tesa --direct auto --subme 8 --partitions all --trellis 2 --no-dct-decimate --output "output" "input"
Emulgator
18th January 2015, 13:14
For which device the encode shall be ?
DVD player, BD player, Mobile phone (which), PC only ?
I will suggest a script.
knari
18th January 2015, 18:44
Mostly for PC. Or for media player like WD TV Live, but it shows almost everything (I didn't see any file it doesn't show).
Asmodian
19th January 2015, 08:08
FFMS2 (http://avisynth.nl/index.php/FFmpegSource) has issues with interlaced H.264, I would try AVISource() instead. You also need to tell x264 if it is interlaced bottom field first (--bff) or top field first (--tff). I would stick to 8 refs or below for portability, over 8 doesn't gain you much and is one thing devices might not like.
AVISource("D:\video\rip\10avi0001_cut_ep1.avi")
program --bff --pass 2 --bitrate 2180 --stats ".stats" --slow-firstpass --deblock -1:-1 --bframes 4 --b-adapt 2 --b-pyramid none --ref 8 --qpmin 10 --qpmax 51 --merange 32 --me tesa --direct auto --subme 8 --partitions all --trellis 2 --no-dct-decimate --output "output" "input"
knari
19th January 2015, 12:04
Thank you, Asmodian. But what do you think about the preset I use? Perhaps it's too good for such quality of the source video.
Asmodian
19th January 2015, 21:15
It is not a fast preset but as always; as slow as you can stand is good.
knari
20th January 2015, 10:25
For which device the encode shall be ?
DVD player, BD player, Mobile phone (which), PC only ?
I will suggest a script.
I would be appreciate if you suggest some script for my goals.
Emulgator
23rd January 2015, 16:22
Coming this weekend.
knari
23rd January 2015, 16:35
Thank you
Emulgator
25th January 2015, 20:20
you will need some plugins:
TGMC beta2.
I did not play around with colour, I thought I would leave this up to you.
Only for colour:
Smooth Adjust, CheapColorTemp.
Otherweise comment these lines out ( A # at the steart of a line comments this line out, disables it)
This one gives 4:3 on 1280x720x50p with black pillars, ready for AVCHD/BD on 16:9
#knari-fix BD
SetMemoryMax=768 ## Set to 30..50% of available RAM
SAHist=0 ## SAHist=0: SmoothAdjust-Histograms will be off, 1:SmoothAdjust-Histograms will be shown
SAWidth=1280
SAHeight=768
SAShow= SAHist==0 ? false : true
TGMC=4 ## 0: TGMC OFF | 1: TGMC beta1 | 2: TGMC beta1mod | 3: TGMC beta1u | 4: TGMC beta2 | 5: QTGMC | -1: Bob
TGMCDec=0 ## 0: Keep Bobbing (doubles framerate) | 1: SelectOdd | 2: SelectEven | 3: Merge | 4: SelectEvery(4,0,3)
TGMCReInt=0 ## 0: No Reinterlace | 1: Reinterlace
FreeProgResizer="133-AVCHD1280"
DirectShowSource("E:\1_SOURCE\10avi0001_cut_ep1.avi")
IsYV12 ? NOP : ConvertToYV12(IsFieldBased)
TGMC==4 ? ConvertToYV12(interlaced=true).TempGaussMC_beta2(EdiMode="NNEDI3", tr2=3, sharpness=1.8) : \
SmoothCurve(show=SAShow, interp=100, limiter=false, screenW=SAWidth, screenH=SAHeight, \
Ycurve="0-16;18-20;31-30;127-115;200-180;220-195;230-202;240-212;248-220;255-230", \
Ucurve="0-0;90-80;127-126;150-140;255-255", \
Vcurve="0-0;90-80;127-127;191-191;255-255")
CheapColorTemp(-5,-8,-5)
PALw1= 1280 PALh1= 720
FreeProgResizer=="133-AVCHD1280" ? Lanczos4Resize(960, 720, 0, 0, -0, -0).AddBorders(160, 0, 160, 0, color=$000000) : NOP
TGMCDec==1 ? SelectOdd : TGMCDec==2 ? SelectEven : TGMCDec==3 ? Merge(SelectEven(), SelectOdd()) : \
TGMCDec==4 ? SelectEvery(5, 1, 2) : NOP
TGMCReInt==1 ? Separatefields.Selectevery(4,0,3).Weave : NOP
return(last)
This one gives 720x576x25i ready for DVD
#knari-fix DVD
SetMemoryMax=768 ## Set to 30..50% of available RAM
SAHist=0 ## SAHist=0: SmoothAdjust-Histograms will be off, 1:SmoothAdjust-Histograms will be shown
SAWidth=1280
SAHeight=768
SAShow= SAHist==0 ? false : true
TGMC=4 ## 0: TGMC OFF | 1: TGMC beta1 | 2: TGMC beta1mod | 3: TGMC beta1u | 4: TGMC beta2 | 5: QTGMC | -1: Bob
TGMCDec=0 ## 0: Keep Bobbing (doubles framerate) | 1: SelectOdd | 2: SelectEven | 3: Merge | 4: SelectEvery(4,0,3)
TGMCReInt=1 ## 0: No Reinterlace | 1: Reinterlace
FreeProgResizer="1-PAL0720"
DirectShowSource("E:\1_SOURCE\10avi0001_cut_ep1.avi")
IsYV12 ? NOP : ConvertToYV12(IsFieldBased)
TGMC==4 ? ConvertToYV12(interlaced=true).TempGaussMC_beta2(EdiMode="NNEDI3", tr2=3, sharpness=1.8) : \
SmoothCurve(show=SAShow, interp=100, limiter=false, screenW=SAWidth, screenH=SAHeight, \
Ycurve="0-16;18-20;31-30;127-115;200-180;220-195;230-202;240-212;248-220;255-230", \
Ucurve="0-0;90-80;127-126;150-140;255-255", \
Vcurve="0-0;90-80;127-127;191-191;255-255")
CheapColorTemp(-5,-8,-5)
PALw1= 720 PALh1= 576
FreeProgResizer=="1-PAL0720" ? Lanczos4Resize(PALw1, PALh1, 14, 4, -6, -0).AddBorders((720-PALw1)/2, (576-PALh1)/2, (720-PALw1)/2, (576-PALh1)/2, color=$000000) : NOP
TGMCDec==1 ? SelectOdd : TGMCDec==2 ? SelectEven : TGMCDec==3 ? Merge(SelectEven(), SelectOdd()) : \
TGMCDec==4 ? SelectEvery(5, 1, 2) : NOP
TGMCReInt==1 ? Separatefields.Selectevery(4,0,3).Weave : NOP
Emulgator
27th January 2015, 23:20
knari, you were asking about .dlls in PM, because it didn't work on your side
(here it works, in MeGUI and in Simple x264 Launcher).
All these dlls and scripts you find mentioned and downloadable here in these forum when using search.
First you got to install Avisynth 2.6.0.4
TGMC is a .avsi script that has to reside in the plugins folder of this Avisynth installation.
You download this script from this forum and put it there. TGMC needs certain plugins in the same folder to work with.
You can read the TGMC.avsi script in Notepad or Editor, it will tell.
You just download plugins that you need (there are hundreds available) and put these manually into Avisynth plugins folder.
To check if a filter chain works or not you use VirtualDub or AvsPmod.
Any script you call will inform you when and which plugin is missing.
You will see the resulting frames before starting to encode.
TGMC has threads here in this forum. The other plugins as well.
In the end MeGUI will just eat the script, initialise the encoder and invoke Avisynth.
Avisynth builds a filter chain from the script chaining the necessary plugins
finally delivering prefiltered frames to the encoder when he demands some.
knari
29th January 2015, 18:49
Thank you, Emulgator. I found all the plugins and encoded my sample I sent to you by using our knari-DVD version of the script. But I have some questions:
1) I see, that in the script you crop video: Lanczos4Resize(PALw1, PALh1, 14, 4, -6, -0). But then it is resized to 720x576. Is it possible to save only cropped version without resizing it. For me it's ok if it will be something like 704x570.
2) Also the resulting video has 5:4 aspect, when the original was 4:3. How to keep the original aspect?
3) I tried to open both video in MPC video player. It is obviously visible that the resulting video has interlacing nature. At the same time I don't see it in the original video (time 00:38-00:42, for example). What can be improved here?
My result is here: https://dl.dropboxusercontent.com/u/6089180/test.mp4
Emulgator
5th February 2015, 17:00
1.: You can set cropping to 0,0,0,0, but you lose reusability of your encode on any disc/standalone playback device like DVD/BD.
2.: You add --sar 12:11 to x264 commandline.
3.: The DVD script keeps interlacing as this is what the source delivers.
If you want to keep all that temporal information intact and go progressive, I made the option of 50p for you, the BD script.
And if you want to force 25p, then you may call any mediocre deinterlacer, but this is where you came from and you were not happy with.
knari
5th February 2015, 17:18
Thank you for the reply.
1) What is the best solution if I want to crop, but not resize?
2) Why 12:11? It doesn't look similar to 4:3
hello_hello
9th February 2015, 11:12
12:11 is the pixel aspect ratio. DVDs don't use square pixels, hence they can be either 4:3 or 16:9 while the resolution is always 720x576.
720 x 12 / 11 = 786
786 / 576 = 1.365
It's a little wider than 4:3 (1.333:1) because only 704x576 makes the 4:3 aspect ratio (8 pixels down each side don't count).
You can use straight 4:3 resizing by selecting 4:3 as the input aspect ratio in MeGUI's script creator rather than "ITU 4:3".
There's a list of PARs here. MeGUI uses the second lot when the input aspect ratio is "ITU", but the ITU and mpeg4 PATs are virtually the same. https://www.doom9.org/showthread.php?p=1058927#post1058927
Normally when you enable anamorphic encoding in MeGUI's script creator it shows the display aspect ratio at the top of the script (as per your post #5). If you crop it'll change accordingly. MeGUI uses the DAR in the script along with the output resolution to calculate the correct pixel aspect ratio. As a general rule you wouldn't set a pixel aspect ratio in the encoder configuration yourself and you'd let MeGUI take care of it, however as you're using Emulgator's script and it does the cropping/resizing you'd probably not enable anamorphic encoding in the script creator and set the pixel aspect ratio to 12:11 in the encoder configuration manually as Emulgator suggested. It's actually called SAR rather than PAR (sample aspect ratio) and the option is "Force SAR" under the miscellaneous tab in the x264 encoder configuration.
Not wanting to take anything away from Emulgator's good work, but maybe try starting out simple. Either enable anamorphic encoding in the script creator, or don't and enable resizing instead to resize to square pixels, then when you've adjusted the cropping and resizing, replace the #deinterlace line in the script with QTGMC(). From there you can play around with the other filtering Emulgator suggested, but it might be a simpler starting point if you're new to it all.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.