Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th November 2009, 15:28   #1  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,440
Handbrake CLI for batch encoding

Hey guys,

I'm building out a workflow for batch encoding on linux.

I'm quite interested in Handbrake - as it seems to be pretty good at automatically handling the various idiosyncrasies with DVDs - i.e. aspect ratios, deinterlacing / IVTC etc...

Basically, I'm trying to figure out something that can be easily scripted, ideally to the point where I can simply specify input (a VOB), output, resolution, and bitrate, and have the app automatically deinterlace / ivtc as necessary, resize to appropriate square pixel resolution, and then encode in 2 passes using x264 into an MP4 container with the first audio track in the VOB encoded to AAC.

I have a feeling this can be done with a single command, using Handbrake.

If not, could anyone else suggest something else? It would be quite simple to do this all via ffmpeg etc, but handling deinterlacing / IVTC / crop / resize properly seems like it would be tricky for a batch flow, without knowing correct settings ahead of time.

I'm not expecting perfect results, of course. I also don't plan on having really exotic sources - like field blended or other brutal standards conversions. Most of the content will be fairly recent independent films, and I'm guessing most will be NTSC DVDs with either soft pulldown, or vanilla 3:2.

Any input would be greatly appreciated Simplicity is THE operative word here.

Thanks in advance,
~MiSfit
Blue_MiSfit is offline   Reply With Quote
Old 14th November 2009, 15:50   #2  |  Link
froggy1
ffx264/ffhevc author
 
froggy1's Avatar
 
Join Date: May 2007
Location: Belgium
Posts: 1,455
write a Bash script. This can be easily done
__________________
ffx264--ffhevc--ffxvid
froggy1 is offline   Reply With Quote
Old 14th November 2009, 16:38   #3  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
hadnbrake has already a good command line support

just use it.. nothing fancy, but quite usefull

Code:
[andres@lucillex ~][andres@lucillex ~]$ HandBrakeCLI --help
Syntax: HandBrakeCLI [options] -i <device> -o <file>

### General Handbrake Options------------------------------------------------

    -h, --help              Print help
    -u, --update            Check for updates and exit
    -v, --verbose <#>       Be verbose (optional argument: logging level)
    -C, --cpu               Set CPU count (default: autodetected)
    -Z. --preset <string>   Use a built-in preset. Capitalization matters, and if the preset name has spaces, surround it with double quotation marks
    -z, --preset-list       See a list of available built-in presets
         --dvdnav            Use dvdnav (Experimental)

### Source Options-----------------------------------------------------------

    -i, --input <string>    Set input device
    -t, --title <number>    Select a title to encode (0 to scan only, default: 1)
    -L, --longest           Select the longest title
    -c, --chapters <string> Select chapters (e.g. "1-3" for chapters  1 to 3, or "3" for chapter 3 only, default: all chapters)
        --angle <number>    Select the DVD angle
        --previews <#:B>    Select how many preview images are generated (max 30),   and whether or not they're stored to disk (0 or 1).  (default: 10:0)
    --start-at-preview <#>  Start encoding at a given preview.
    --stop-at     <unit:#>  Stop encoding at a given frame, duration (in seconds),  or pts (on a 90kHz clock)
### Destination Options------------------------------------------------------

    -o, --output <string>   Set output file name
    -f, --format <string>   Set output format (mp4/mkv, default: autodetected from file name)
    -m, --markers           Add chapter markers (mp4 and mkv output formats only)
    -4, --large-file        Use 64-bit mp4 files that can hold more than   4 GB. Note: Breaks iPod, PS3 compatibility.
    -O, --optimize          Optimize mp4 files for HTTP streaming
    -I, --ipod-atom         Mark mp4 files so 5.5G iPods will accept them

### Video Options------------------------------------------------------------

    -e, --encoder <string>  Set video library encoder (ffmpeg,x264,theora)  (default: ffmpeg)
    -x, --x264opts <string> Specify advanced x264 options in the   same style as mencoder: 
                            option1=value1:option2=value2
    -q, --quality <float>   Set video quality (0.0..1.0)
    -Q, --cqp               Use with -q for CQP instead of CRF
    -S, --size <MB>         Set target size
    -b, --vb <kb/s>         Set video bitrate (default: 1000)
    -2, --two-pass          Use two-pass mode
    -T, --turbo             When using 2-pass use the turbo options  on the first pass to improve speed
                            (only works with x264, affects PSNR by about 0.05dB, and increases first pass speed two to four times)
    -r, --rate              Set video framerate (5/10/12/15/23.976/24/25/29.97)
                            Be aware that not specifying a framerate lets HandBrake preserve a source's time stamps,
                            potentially creating variable framerate video
    --vfr, --cfr, --pfr     Select variable, constant or peak-limited frame rate control. VFR preserves the source timing. CFR makes the output constant rate at the rate given by the -r flag (or the source's
                            average rate if no -r is given). PFR doesn't allow the rate to go over the rate specified with the -r flag but won't change the source timing if it's below that rate. If none of these flags are given, the default is --cfr when -r is given and -vfr otherwise

### Audio Options-----------------------------------------------------------

    -a, --audio <string>    Select audio track(s), separated by commas  More than one output track can be used for one
                            input.  ("none" for no audio, "1,2,3" for multiple tracks, default: first one)
    -E, --aencoder <string> Audio encoder(s) (faac/lame/vorbis/ac3/dts) ac3 and dts meaning passthrough Separated by commas for more than one audio track. (default: guessed)
    -B, --ab <kb/s>         Set audio bitrate(s)  (default: 160)  Separated by commas for more than one audio track.
    -6, --mixdown <string>  Format(s) for surround sound downmixing
                            Separated by commas for more than one audio track. (mono/stereo/dpl1/dpl2/6ch, default: dpl2)
    -R, --arate             Set audio samplerate(s) (22.05/24/32/44.1/48 kHz)  Separated by commas for more than one audio track.
    -D, --drc <float>       Apply extra dynamic range compression to the audio,  making soft sounds louder. Range is 1.0 to 4.0  (too loud), with 1.5 - 2.5 being a useful range. Separated by commas for more than one audio track.
    -A, --aname <string>    Audio track name(s), Separated by commas for more than one audio track.

### Picture Settings---------------------------------------------------------

    -w, --width <number>    Set picture width
    -l, --height <number>   Set picture height
        --crop <T:B:L:R>    Set cropping values (default: autocrop)
    -Y, --maxHeight <#>     Set maximum height
    -X, --maxWidth <#>      Set maximum width
    --strict-anamorphic     Store pixel aspect ratio in video stream
    --loose-anamorphic      Store pixel aspect ratio with specified width
    --custom-anamorphic     Store pixel aspect ratio in video stream and  directly control all parameters.
    --display-width         Set the width to scale the actual pixels to
      <number>              at playback, for custom anamorphic.
    --keep-display-aspect   Preserve the source's display aspect ratio  when using custom anamorphic
    --pixel-aspect          Set a custom pixel aspect for custom anamorphic  <PARX:PARY>
                            (--display-width and --pixel-aspect are mutually  exclusive and the former will override the latter)
    --itu-par               Use wider, ITU pixel aspect values for loose and custom anamorphic, useful with underscanned sources
    --modulus               Set the number you want the scaled pixel dimensions
      <number>              to divide cleanly by, for loose and custom  anamorphic modes (default: 16)
    -M  --color-matrix      Set the color space signaled by the output
          <601 or 709>      (Bt.601 is mostly for SD content, Bt.709 for HD,
                             default: set by resolution)

### Filters---------------------------------------------------------

    -d, --deinterlace       Deinterlace video with yadif/mcdeint filter
          <YM:FD:MM:QP>     (default 0:-1:-1:1)
           or
          <fast/slow/slower>
    -5, --decomb            Selectively deinterlaces when it detects combing
          <MO:ME:MT:ST:BT:BX:BY>     (default: 1:2:6:9:80:16:16)
    -9, --detelecine        Detelecine (ivtc) video with pullup filter
                            Note: this filter drops duplicate frames to
                            restore the pre-telecine framerate, unless you
                            specify a constant framerate (--rate 29.97)
          <L:R:T:B:SB:MP>   (default 1:1:4:4:0:0)
    -8, --denoise           Denoise video with hqdn3d filter
          <SL:SC:TL:TC>     (default 4:3:6:4.5)
           or
          <weak/medium/strong>
    -7, --deblock           Deblock video with pp7 filter
          <QP:M>            (default 5:2)
    -g, --grayscale         Grayscale encoding

### Subtitle Options------------------------------------------------------------

    -s, --subtitle <string> Select subtitle track(s), separated by commas
                            More than one output track can be used for one
                            input.
                            ("1,2,3" for multiple tracks.
                            A special track name "scan" adds an extra 1st pass.
                            This extra pass scans subtitles matching the
                            language of the first audio or the language 
                            selected by --native-language.
                            The one that's only used 10 percent of the time
                            or less is selected. This should locate subtitles
                            for short foreign language segments. Best used in
                            conjunction with --subtitle-forced.
    -F, --subtitle-forced   Only display subtitles from the selected stream if
          <string>          the subtitle has the forced flag set. May be used in
                            conjunction with "scan" track to auto-select
                            a stream if it contains forced subtitles.
                            Separated by commas for more than one audio track.
                            ("1,2,3" for multiple tracks.
                            If "string" is omitted, the first trac is forced.
        --subtitle-burn     "Burn" the selected subtitle into the video track
          <number>          If "number" is omitted, the first trac is burned.
        --subtitle-default  Flag the selected subtitle as the default subtitle
          <number>          to be displayed upon playback.  Setting no default
                            means no subtitle will be automatically displayed
                            If "number" is omitted, the first trac is default.
    -N, --native-language   Specifiy the your language preference. When the first
          <string>          audio track does not match your native language then
                            select the first subtitle that does. When used in
                            conjunction with --native-dub the audio track is
                            changed in preference to subtitles. Provide the
                            language's iso639-2 code (fre, eng, spa, dut, et cetera)
        --native-dub        Used in conjunction with --native-language
                            requests that if no audio tracks are selected the
                            default selected audio track will be the first one
                            that matches the --native-language. If there are no
                            matching audio tracks then the first matching
                            subtitle track is used instead.
        --srt-file <string> SubRip SRT filename(s), separated by commas.
        --srt-codeset       Character codeset(s) that the SRT file(s) are
          <string>          encoded in, separted by commas.
                            Use 'iconv -l' for a list of valid
                            codesets. If not specified latin1 is assumed
        --srt-offset        Offset in milli-seconds to apply to the SRT file(s)
          <string>          separted by commas. If not specified zero is assumed.
                            Offsets may be negative.
        --srt-lang <string> Language as an iso639-2 code fra, eng, spa et cetera)
                            for the SRT file(s) separated by commas. If not specified
                            then 'und' is used.
        --srt-default       Flag the selected srt as the default subtitle
          <number>          to be displayed upon playback.  Setting no default
                            means no subtitle will be automatically displayed
                            If "number" is omitted, the first srt is default.
                            "number" is an 1 based index into the srt-file list
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Old 16th November 2009, 16:05   #4  |  Link
txporter
Registered User
 
Join Date: Nov 2009
Posts: 110
Here is a profile that Tivo users of kmttg use for converting to x264 with HandbrakeCLI:
Code:
handbrakeCLI -i inputFile.mpg -f mp4 -p -e x264 -b 5000 -a 1 -E ac3 -x ref=3:mixed-refs=1:bframes=3:
b-pyramid=1:weightb=1:analyse=all:8x8dct=1:me=umh:subq=9:direct=auto:keyint=24:min-keyint=2:
no-fast-pskip=1:no-dct-decimate=1 -v -o outputFile.mp4
It is fairly easy to modify from there using the info that buzzqw posted above. For 2-pass change -b to -2. You can probably strip out the keyint/min-keyint, we use it to provide better seek performance on the Tivo.

Last edited by txporter; 16th November 2009 at 16:06. Reason: adding hard returns to code box
txporter is offline   Reply With Quote
Old 16th November 2009, 16:27   #5  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
one more thing:
all custom x264 parameters use the mencoder notation

BHH
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.