VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. I used the Win7 powershell to make a batch file (ps1) that converted my avi files from the DV camera directly to DVD compatible mpg files. It takes as many avi files as is in one folder and produces an mpg for each avi. Save the quote below into a ps1 file.

    cd e:\Shared
    $files=get-childitem ./DV *.avi
    foreach($file in $files) {
    write-host File name: $file

    # file name
    $name = $file.tostring().trimend(".avi")
    write-host Movie name: $name

    # construct avs file
    "AVISource(`"E:\Shared\DV\$name.avi`")" | Out-File -Encoding ASCII avs/$name.avs

    # construct ini file for hc
    Get-Content default/default.ini |
    ForEach-Object { $_ -replace "__INFILE__", "E:\Shared\avs\$name.avs" } |
    ForEach-Object { $_ -replace "__OUTFILE__", "E:\Shared\OUTPUT\$name.m2v" } |
    ForEach-Object { $_ -replace "__LOGFILE__", "E:\Shared\OUTPUT\log\$name.log" } |
    Set-Content hcini/$name.ini -encoding ASCII

    # hc encode files
    write-host Encoding video...
    $prog = "E:\MyProgs\HC025\HCenc_025.exe"
    $args = "-ini E:\Shared\hcini\$name.ini"
    start-process $prog -ArgumentList $args -wait

    # extract wave audio from avi files
    write-host Extracting wave audio...
    $prog = "e:\myprogs\wavi106\wavi.exe"
    $args = "e:\shared\avs\$name.avs e:\shared\wav\$name.wav"
    start-process $prog -ArgumentList $args -wait

    # convert wav to ac3 with 48 kHz SR for DVD compatibility
    write-host Encoding ac3 audio...
    $prog = "E:\myprogs\ffmpeggui03c\ffmpeggui03c\ffmpeg.exe"
    $args = "-i e:\shared\wav\$name.wav -acodec ac3 -ac 2 -ar 48000 -ab 192k e:\shared\aac\$name.ac3"
    start-process $prog -ArgumentList $args -wait

    # multiplex m2v and ac3 to mpg
    write-host Muxing video and audio...
    $prog = "e:\myprogs\mplex.exe"
    $args = "-f 8 -b 224 -o E:\shared\output\$name.mpg E:\shared\output\$name.m2v E:\shared\aac\$name.ac3"
    start-process $prog -ArgumentList $args -wait
    }
    The default.ini file used has these contents:

    *INFILE __INFILE__
    *OUTFILE __OUTFILE__
    *LOGFILE __LOGFILE__
    *MAXBITRATE 9500
    *PROFILE best
    *ASPECT 4:3
    *AUTOGOP 15
    *CQ_MAXBITRATE 5.000
    *DC_PREC 10
    *DVSOURCE
    *NOSCD
    *CLOSEDGOPS
    *INTRAVLC 2
    *MATRIX mpeg
    *LUMGAIN 1
    *PRIORITY normal
    *WAIT 0
    All the folders used must be created before the script is executed. The programs used are hcenc, wavi, ffmpeg and mplex (windows compilation).
    Last edited by findus; 19th Dec 2011 at 17:56. Reason: Changed to ac3 encoding in one lossy step with ffmpeg.
    Quote Quote  
  2. Thanks for sharing interesting stuff.

    # convert wav to aac
    $name32 = [string]::join("", ($name, "_32"))
    $prog = "E:\MyProgs\NeroAACCodec-1.5.1\win32\neroaacenc.exe"
    $args = "-if e:\shared\wav\$name.wav -of e:\shared\aac\$name32.aac"
    start-process $prog -ArgumentList $args -wait
    i can appreciate if you can discuss specific reason for wav --> aac -->ac3
    coz
    i c no reason for wav --> aac -->ac3, i wud rather prefer wav --> ac3.

    # resample aac audio to 44.1 kHz to enable mpg compability
    $prog = "E:\myprogs\ffmpeggui03c\ffmpeggui03c\ffmpeg.exe"
    $args = "-i e:\shared\aac\$name32.aac -acodec ac3 -ac 2 -ar 44100 -ab 192k e:\shared\aac\$name.ac3"
    start-process $prog -ArgumentList $args -wait
    i wud rather go for DVD compatibility
    $args = "-i e:\shared\aac\$name32.aac -acodec ac3 -ac 2 -ar 48000 -ab 448k e:\shared\aac\$name.ac3"
    Quote Quote  
  3. Thanks for the feedback.

    If the wav --> ac3 step can be made in one step it would be better, I just found the tools to do these steps and it worked. Does neroaacenc or ffmpeg do the one step conversion? The arguments used would be appreciated in that case.

    You are right about the 48 kHz sample rate for DVD compatibility. I am not sure about the bit rate though. This guide uses 192 kbps for example.
    Quote Quote  
  4. Thanks for the feedback.

    If the wav --> ac3 step can be made in one step it would be better, I just found the tools to do these steps and it worked. Does neroaacenc or ffmpeg do the one step conversion? The arguments used would be appreciated in that case.
    i suggested wav-to-ac3 to avoid lossy two times conversions, and...
    here you have two options...
    1) use SSRC (resample to 48KHz) + Aften (AC-3 Encoder, read help documentation for cli-parameters) - aften produces better qua;ity ac-3 from wav.
    2) use ffmpeg directly on wav like...
    $args = "-if e:\shared\wav\$name.wav -acodec ac3 -ac 2 -ar 48000 -ab 448k e:\shared\aac\$name.ac3"
    last time, it was a long long ago, ffmpeg - ac-3 conversion was bit buggy, may be solved in recent release.

    You are right about the 48 kHz sample rate for DVD compatibility. I am not sure about the bit rate though. This guide uses 192 kbps for example.
    As long as your re-sampling frequency is 48000 Hz, you can select any bitrate 192k, 224k, 384k or 448k for DVD.

    # multiplex m2v and ac3 to mpg
    $prog = "e:\myprogs\mplex.exe"
    $args = "-f 3 -o E:\shared\output\$name.mpg E:\shared\output\$name.m2v E:\shared\aac\$name.ac3"
    start-process $prog -ArgumentList $args -wait
    }
    pls. check mplex documentation.
    for DVD compatibility
    $args = "-f 8 -b 224k -o E:\shared\output\$name.mpg E:\shared\output\$name.m2v E:\shared\aac\$name.ac3"
    i mean -f 8 instead of -f 3, plus video buffer -b|--video-buffer at-least 224k.

    Regarding HCEnc, default INI
    try *DC_PREC 9 as well instead of *DC_PREC 10, visualize on HD-TV by yourself coz u cud be the best judge than my-self.
    it could be my visual illusion that *DC_PREC 9 look better than *DC_PREC 10 while playing DVD on stand-alone HD-TV.

    keep up good-works!
    Good Luck!
    Last edited by Bonie81; 19th Dec 2011 at 17:06.
    Quote Quote  
  5. Thanks!

    Main post now updated with wav --> ac3 direct conversion with ffmpeg.
    Quote Quote  
  6. no problemo!
    also update mplex commandlines to make it perfect as under:
    $args = "-f 8 -b 224k -o E:\shared\output\$name.mpg E:\shared\output\$name.m2v E:\shared\aac\$name.ac3"
    so final.mpg can be taken directly to DVDAuthoring S/Ws,

    Pls also provide a list of the tools used like HcEnc, FFmpeg, wavi and mplex with a linked back to VideoHelp tools downloads section on the top, with a hope and earnest request to VideoHelp Moderators to include or add wavi.exe and mplex.exe in misc. tools section very shortly.. I can also appreciate if you thank the authors of these tools - HcEnc, FFmpeg, wavi and mplex for their efforts and time developing such nice tools, at the botton-end.

    anyway it is very useful guide, i wud like to thank you for posting as it's your first post in VideoHelp.

    see ya around here on VideoHelp with more guides.
    u r wel-come @ VideoHelp
    Last edited by Bonie81; 19th Dec 2011 at 21:19.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!