Log in

View Full Version : HDTV 1080i to dvd - AVIsynth & TMPGEnc express 4.0


eas4uk
21st May 2007, 21:53
Hi

I'm having some difficulty trying to convert an episode of the Tudors from HDTV mpeg2 source to dvd. It is a 1920 x 1080i

I originally tried Nero Vision Express - the quality of the picture is fine however it is very jerky when the camera pans around.

I have since tried to convertxtodvd - this is certainly better in with the camera pans but is still not perfect by any means.

I am now trying TMPGEnc and AVIsynth scripts (I am a definte newb with these so help will be gratefully received in this department)

So far I have demuxed video and audio from the .ts using DGindex

I have then used the following scripts in AVIsynth

LoadPlugin("C:\Documents and Settings\DGIndex\DGDecode.dll")
LoadPlugin("C:\Documents and Settings\DGIndex\Decomb.dll")
MPEG2Source("K:\My Videos 5\The Tudors\Ep 1.d2v")
AssumeTFF() #if TFF, AssumeBFF() if BFF
Telecide()
Decimate()
LanczosResize(720,480)

and opened the script in TMPGEnc Express 4.0

I have tried all sorts of settings in TMPGEnc but if anything with each effort of encoding I'm sure the output is getting worse.

Can anyone give me any pointers?

What should the clip settings be when I first import the script?
What deinterlace filter should be set at the source stage?
What settings should I be using under format?

Im getting very lost with all this now and seem to be going round in circles.

ps I'm not bothered about encoding times - I appreciate quality of the final output more (CPU is C2D e6600 2gb ram etc...)

eswrite
30th May 2007, 12:08
Your script looks fairly similar to what I do, except I mux my video/audio using QuEnc/AviSynth (something most frown upon). I have found that unless I spoon-feed DVD-compatible MPEG2 files into the DVD authoring application (glorious TMPEnc included: I have DVD Author and Editor), my results will, well... suck. I use QuEnc to generate these files. Below is my latest script code. See the following links:

.ts to DVD: http://forum.doom9.org/showthread.php?t=91560

QuEnc: http://www.doom9.org/index.html?/mpg/quenc.htm
For QuEnc, use bitrate = 5000, maxbitrate = 9000, pulldown


##################################################################################
##
## Script: i_hdmux2dvd.avs
##
## Description: HD to DVD conversion from DGIndex de-muxed video & audio.
##
##################################################################################
LoadPlugin("C:\Program Files\Video Tools\DGIndex\DGDecode.dll")
LoadPlugin("C:\Program Files\Video Tools\VDubMod\AviSynth 2.5\plugins\NicAudio.dll")

function mux2dvd(string mpg_src, string audio_src, float audio_dly)
{
### Load HDTV video
vhd=MPEG2Source(mpg_src) # <== replace with your .d2v file name [1]
srcHeight=vhd.height()
is720p = srcHeight < 800 ? true : false

###-Test: shows threshold at 25; above it, interlaced frames show up
#return Video.Telecide(order=1, guide=1, post=3, vthresh=25, show=true)

### Use NicAC3Source for AC3 file: replace file name from your .ac3 file [2]
#ahd = DirectShowSource (audio_src, video = false)
ahd = NicAC3Source(audio_src)
AudioDub(vhd,ahd)
DelayAudio(audio_dly) # <== set value from 'DELAY' in sound file name (DELAY/1000) [3]

### For Source AR of 1.778:1 -- 16:9 Wide-Ssreen
#-Apply IVTC for telecined source
vt=Telecide(order=1, guide=1, post=2, vthresh=25)
#-Select every other frame when input is 720p
vs = is720p ? vt.SelectEven() : vt
vs.Decimate(cycle=5) # for 24fps

#-Resize to DVD resolution
v_out = Lanczos4Resize(720,480)#.Subtitle(is720p ? "720p" : "1080i")

### Output is at 24 fps: must do pulldown post-process (i.e., DGPulldown)
#-For DVD creation need 29.97fps interlaced
return v_out
}

#############################################################
# File: hdtv_mux-resize_01.avs
# Sample for .avs using above script: processing "National Treasure" .ts from
# MyHD capture.

Import("C:\Program Files\Video Tools\VDubMod\include\i_hdmux2dvd.avs")

v_out = mux2dvd("D:\Our Videos\National Treasure\Demuxed\0520-2000_00-01.d2v", "D:\Our Videos\National Treasure\Demuxed\0520-2000_00-01 PID 034 T01 3_2ch 384Kbps DELAY -431ms.ac3", -0.431) # <== set value from 'DELAY' in sound file name (DELAY/1000)

### Output is at 24 fps: must do pulldown post-process (i.e., DGPulldown)
#-For DVD creation need 29.97fps interlaced
return v_out

REM #############################################################
REM ## File: mux2mpg.bat
REM ## Batch file to run QuEnc against the 15 comercial-less segments I generated
REM ## using DGIndex...

"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_01.avs -o "D:\Our Videos\National Treasure\Processed\nt01.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_02.avs -o "D:\Our Videos\National Treasure\Processed\nt02.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_03.avs -o "D:\Our Videos\National Treasure\Processed\nt03.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_04.avs -o "D:\Our Videos\National Treasure\Processed\nt04.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_05.avs -o "D:\Our Videos\National Treasure\Processed\nt05.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_06.avs -o "D:\Our Videos\National Treasure\Processed\nt06.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_07.avs -o "D:\Our Videos\National Treasure\Processed\nt07.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_08.avs -o "D:\Our Videos\National Treasure\Processed\nt08.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_09.avs -o "D:\Our Videos\National Treasure\Processed\nt09.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_10.avs -o "D:\Our Videos\National Treasure\Processed\nt10.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_11.avs -o "D:\Our Videos\National Treasure\Processed\nt11.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_12.avs -o "D:\Our Videos\National Treasure\Processed\nt12.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_13.avs -o "D:\Our Videos\National Treasure\Processed\nt13.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_14.avs -o "D:\Our Videos\National Treasure\Processed\nt14.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_15.avs -o "D:\Our Videos\National Treasure\Processed\nt15.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close

cubdukat
2nd June 2007, 06:53
Your script looks fairly similar to what I do, except I mux my video/audio using QuEnc/AviSynth (something most frown upon). I have found that unless I spoon-feed DVD-compatible MPEG2 files into the DVD authoring application (glorious TMPEnc included: I have DVD Author and Editor), my results will, well... suck. I use QuEnc to generate these files. Below is my latest script code. See the following links:

.ts to DVD: http://forum.doom9.org/showthread.php?t=91560

QuEnc: http://www.doom9.org/index.html?/mpg/quenc.htm
For QuEnc, use bitrate = 5000, maxbitrate = 9000, pulldown


##################################################################################
##
## Script: i_hdmux2dvd.avs
##
## Description: HD to DVD conversion from DGIndex de-muxed video & audio.
##
##################################################################################
LoadPlugin("C:\Program Files\Video Tools\DGIndex\DGDecode.dll")

function mux2dvd(string mpg_src, string audio_src, float audio_dly)
{
### Load HDTV video
vhd=MPEG2Source(mpg_src) # <== replace with your .d2v file name [1]
srcHeight=vhd.height()
is720p = srcHeight < 800 ? true : false

###-Test: shows threshold at 25; above it, interlaced frames show up
#return Video.Telecide(order=1, guide=1, post=3, vthresh=25, show=true)

### Use NicAC3Source for AC3 file: replace file name from your .ac3 file [2]
ahd = DirectShowSource (audio_src, video = false)
AudioDub(vhd,ahd)
DelayAudio(audio_dly) # <== set value from 'DELAY' in sound file name (DELAY/1000) [3]

### For Source AR of 1.778:1 -- 16:9 Wide-Ssreen
#-Apply IVTC for telecined source
vt=Telecide(order=1, guide=1, post=2, vthresh=25)
#-Select every other frame when input is 720p
vs = is720p ? vt.SelectEven() : vt
vs.Decimate(cycle=5) # for 24fps

#-Resize to DVD resolution
v_out = Lanczos4Resize(720,480)#.Subtitle(is720p ? "720p" : "1080i")

### Output is at 24 fps: must do pulldown post-process (i.e., DGPulldown)
#-For DVD creation need 29.97fps interlaced
return v_out
}

#############################################################
# File: hdtv_mux-resize_01.avs
# Sample for .avs using above script: processing "National Treasure" .ts from
# MyHD capture.

Import("C:\Program Files\Video Tools\VDubMod\include\i_hdmux2dvd.avs")

v_out = mux2dvd("D:\Our Videos\National Treasure\Demuxed\0520-2000_00-01.d2v", "D:\Our Videos\National Treasure\Demuxed\0520-2000_00-01 PID 034 T01 3_2ch 384Kbps DELAY -431ms.ac3", -0.431) # <== set value from 'DELAY' in sound file name (DELAY/1000)

### Output is at 24 fps: must do pulldown post-process (i.e., DGPulldown)
#-For DVD creation need 29.97fps interlaced
return v_out

REM #############################################################
REM ## File: mux2mpg.bat
REM ## Batch file to run QuEnc against the 15 comercial-less segments I generated
REM ## using DGIndex...

"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_01.avs -o "D:\Our Videos\National Treasure\Processed\nt01.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_02.avs -o "D:\Our Videos\National Treasure\Processed\nt02.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_03.avs -o "D:\Our Videos\National Treasure\Processed\nt03.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_04.avs -o "D:\Our Videos\National Treasure\Processed\nt04.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_05.avs -o "D:\Our Videos\National Treasure\Processed\nt05.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_06.avs -o "D:\Our Videos\National Treasure\Processed\nt06.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_07.avs -o "D:\Our Videos\National Treasure\Processed\nt07.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_08.avs -o "D:\Our Videos\National Treasure\Processed\nt08.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_09.avs -o "D:\Our Videos\National Treasure\Processed\nt09.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_10.avs -o "D:\Our Videos\National Treasure\Processed\nt10.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_11.avs -o "D:\Our Videos\National Treasure\Processed\nt11.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_12.avs -o "D:\Our Videos\National Treasure\Processed\nt12.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_13.avs -o "D:\Our Videos\National Treasure\Processed\nt13.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_14.avs -o "D:\Our Videos\National Treasure\Processed\nt14.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close
"C:\Program Files\Video Tools\VDubMod\QuEnc" -i hdtv_mux-resize_15.avs -o "D:\Our Videos\National Treasure\Processed\nt15.mpg" -b 5000 -maxbitrate 9000 -hq -audiocodec ac3 -audiobitrate 256 -auto -close




Here's the scripts I use. Both are variants of nwgat's scripts to convert HDTV to H.264, with necessary modifications for DVD.

(1080i)

SetMemoryMax(512)

#LoadPlugin lines not needed if you copy Dlls to Avisynth plugins #folder
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\TIVTC.dll")
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\ColorMatrix.dll")
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\Decomb521.dll")

MPEG2Source("F:\Video\RawCaptures\ER--The Honeymoon Is Over-FIXED.d2v")

ColorMatrix(d2v="F:\Video\RawCaptures\ER--The Honeymoon Is Over-FIXED.d2v")#Maintains correct colors #when downsizing HD

#ConvertToYv12()# Not needed, but Certain Encoders Want it
#Telecide(1,guide=1)
#Decimate(cycle=5)
tfm(order=-1,mode=0,d2v="F:\Video\RawCaptures\ER--The Honeymoon Is Over-FIXED.d2v")
#SelectEven()#Brings 59.94 down to 29.97
Tdecimate() #Brings 29.97 down to 23.976

BilinearResize(720,480)

#Crop(8,8,-8,-8)

ConverttoYUY2 #Needed for CCE Encoder and ConvertToRGB24 for TMPGEnc

(720p)

SetMemoryMax(512)

#LoadPlugin lines not needed if you copy Dlls to Avisynth plugins #folder
LoadPlugin("c:\Program Files\AVISynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\Tivtc.dll")
LoadPlugin("C:\Program Files\AVISynth 2.5\plugins\colormatrix.dll")


MPEG2Source("F:\Video\RawCaptures\24--Day 6 (Season Finale).d2v")

ColorMatrix(d2v="F:\Video\RawCaptures\24--Day 6 (Season Finale).d2v")#Maintains correct colors #when downsizing HD

#ConvertToYv12()# Not needed, but Certain Encoders Want it

SelectEven()#Brings 59.94 down to 29.97
Tdecimate() #Brings 29.97 down to 23.976

LanczosResize(720,480)
Sharpen(0.42)

#Crop(8,8,-8,-8)

ConverttoYUY2() #Needed for CCE Encoder

Generally I'll run a stream through VideoReDoPlus to strip out unnecessary streams and cut out commercials, then I run it through DGDecode to generate a d2v file, which I plug into one of the scripts.

I either use CCE SP 2.70 or HCEnc for encoding. TMPGEnc is just way too slow when dealing with 1080i conversions, even with a dual-core processor like I have. The 720p scripts are a whole lot faster.

I also keep the Dolby Digital stream separate until the end because I have never been able to figure out a way to work it into the scripts without the MPEG-2 encoder choking on it. After the render I usually mux it in TMPGEnc Xpress or in TMPGEnc DVD Author, if I'm really lazy.

If anyone can spot any way I could tweak things to speed up rendering times, feel free to share. The less time the system has to spend rendering, the better, since it maxes out both cores on CCE, and the system has been known to restart during an encode for some weird reason.

eswrite
3rd June 2007, 17:15
@cubdukat:
I might try out your scripts. I just realized (duh) that muxing in AviSynth turns my 5.1 audio into 2.0 -- at least that's what TmpgEnc and TmpgDVD Author tell me. My problem is that when I bring in video and audio separately into either of these two Tmpg applications, I see no way to specify an audio delay (I know the delay from DGIndex's output), resulting in output with out-of-sync video and audio.

45tripp
3rd June 2007, 19:26
tmpg X
source settings,
"cut-edit" tab
bottom left corner:
"audio gap correction"

eswrite
3rd June 2007, 22:19
Thanks, Immersion, but apparently I am having a heck of a time locating the same/similar option in my version of TmpEnc MPEG Editor (2.0) or in my version of TmpEnc DVD Author 2.0.

Fortunately, I discovered how to mux AC3 5.1 ch audio in AVISynth: I have to use NicAC3Source (in NICAudio.dll). The results are quite good. I have edited my script above.

NHRaider
7th June 2007, 11:13
Thanks, Immersion, but apparently I am having a heck of a time locating the same/similar option in my version of TmpEnc MPEG Editor (2.0) or in my version of TmpEnc DVD Author 2.0.

Fortunately, I discovered how to mux AC3 5.1 ch audio in AVISynth: I have to use NicAC3Source (in NICAudio.dll). The results are quite good. I have edited my script above.

TMPGEnc Express does not output 5.1 so you should assume all of their product lines will be the same.

They only outputs stereo. I have had discussions with their support staff and the bottom line is that they are not licensed to output anything but stereo...

eas4uk
25th June 2007, 23:00
Thanks for all the comments - got this one cracked

My next question, which is a little OT for this thread is how to convert WMVHD to DVD

Is it best to convert to MPEG2 straight from WMV or convert to AVI first - I appreciate I need to keep the reencoding to a minimum to preserve quality
(Can you demux wmv?)
Is there a way avisynth can do this, and if so if its a 1280 x 720 progressive source, will i need to IVTC, 3:2 pulldown, decomb etc?

Guest
25th June 2007, 23:25
Please start a new thread for new problems; don't kitchen sink this one.

And don't ask what's best -- it violates forum rules!