I was trying to write a PowerShell script that would allow me to convert multiple files in a directory to .MKV and .MP4 files. I got the CLI syntax directly from the Encode Log in the Handbrake GUI. When I run it through the GUI, I receive files with subtitles. If I cut and paste the line into a CMD window, I receive files with subtitles. When I try to run it via a PowerShell, the subtitles are omitted.
I am running Handbrake 0.10.2.7286 -64 bit on a Windows 7 machine.
Here is the encode log from the GUI that successfully creates subtitles:
Code: Select all
HandBrake 0.10.2.7286 - 64bit Version
OS: Microsoft Windows NT 6.1.7601 Service Pack 1 - 64bit
CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Ram: 8172 MB,
GPU Information:
ATI Radeon HD 5700 Series - 9.12.0.0
Screen: 1920x1080
Temp Dir: C:\Users\Boombatty\AppData\Local\Temp\
Install Dir: C:\Program Files\Handbrake
Data Dir: C:\Users\Boombatty\AppData\Roaming\HandBrake\HandBrake\0.10.2.7286
-------------------------------------------
CLI Query: -i "C:\DVD movies\Over the Hedge.mkv" -t 1 --angle 1 -c 1-16 -o "C:\Plex\Over The Hedge.m4v" -f mp4 -w 720 --crop 0:2:0:0 --loose-anamorphic --modulus 2 -e x264 -q 20 --vfr -a 1 -E av_aac -6 dpl2 -R Auto -B 160 -D 0 --gain 0 --audio-fallback ac3 --subtitle scan,1,2,3,4,5,6 --subtitle-forced=1 --markers="C:\Users\Boombatty\AppData\Local\Temp\Over The Hedge-1-chapters.csv" --encoder-preset=veryfast --encoder-level="4.0" --encoder-profile=main --verbose=1
[21:15:56] hb_init: starting libhb thread
HandBrake 0.10.2 (2015060900) - MinGW x86_64 - https://handbrake.fr
8 CPUs detected
Opening C:\DVD movies\Over the Hedge.mkv...
[21:15:56] CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
[21:15:56] - Intel microarchitecture Sandy Bridge
[21:15:56] - logical processor count: 8
[21:15:57] OpenCL device #1: Advanced Micro Devices, Inc. Juniper
[21:15:57] - OpenCL version: 1.2 AMD-APP (1084.4)
[21:15:57] - driver version: 1084.4 (VM)
[21:15:57] - device type: GPU
[21:15:57] - supported: YES
[21:15:57] Intel Quick Sync Video support: no
[21:15:57] hb_scan: path=C:\DVD movies\Over the Hedge.mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening C:\DVD movies\Over the Hedge.mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening C:\DVD movies\Over the Hedge.mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(C:\DVD movies\Over the Hedge.mkv) failed
[21:15:57] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[21:15:57] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'C:\DVD movies\Over the Hedge.mkv':
Duration: 01:23:16.32, start: 0.000000, bitrate: N/A
Chapter #0.0: start 0.000000, end 475.308167
Metadata:
title : Chapter 01
Chapter #0.1: start 475.308167, end 616.616000
Metadata:
title : Chapter 02
Chapter #0.2: start 616.616000, end 932.464867
Metadata:
title : Chapter 03
Chapter #0.3: start 932.464867, end 1136.301833
Metadata:
title : Chapter 04
Chapter #0.4: start 1136.301833, end 1440.772667
Metadata:
title : Chapter 05
Chapter #0.5: start 1440.772667, end 1665.330333
Metadata:
title : Chapter 06
Chapter #0.6: start 1665.330333, end 1904.435867
Metadata:
title : Chapter 07
Chapter #0.7: start 1904.435867, end 2058.222833
Metadata:
title : Chapter 08
Chapter #0.8: start 2058.222833, end 2417.081333
Metadata:
title : Chapter 09
Chapter #0.9: start 2417.081333, end 3048.211833
Metadata:
title : Chapter 10
Chapter #0.10: start 3048.211833, end 3470.500367
Metadata:
title : Chapter 11
Chapter #0.11: start 3470.500367, end 3790.453333
Metadata:
title : Chapter 12
Chapter #0.12: start 3790.453333, end 4146.308833
Metadata:
title : Chapter 13
Chapter #0.13: start 4146.308833, end 4438.801033
Metadata:
title : Chapter 14
Chapter #0.14: start 4438.801033, end 4531.193333
Metadata:
title : Chapter 15
Chapter #0.15: start 4531.193333, end 4996.324667
Metadata:
title : Chapter 16
Stream #0.0(eng): Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 9800 kb/s, 29.97 fps, 1k tbn, 59.94 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s (default)
Metadata:
title : Surround 5.1
Stream #0.2(fre): Audio: ac3, 48000 Hz, 5.1, fltp, 384 kb/s
Metadata:
title : Surround 5.1
Stream #0.3(spa): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Stereo
Stream #0.4(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Stereo
Stream #0.5(eng): Subtitle: dvdsub (default)
Stream #0.6(fre): Subtitle: dvdsub
Stream #0.7(spa): Subtitle: dvdsub
Stream #0.8(eng): Subtitle: dvdsub
Stream #0.9(fre): Subtitle: dvdsub
Stream #0.10(spa): Subtitle: dvdsub
[21:15:57] dxva2:DxFindVideoServiceConversion failed
[21:15:57] scan: decoding previews for title 1
[21:15:57] scan: audio 0x1: ac3, rate=48000Hz, bitrate=448000 English (AC3) (5.1 ch)
[21:15:57] scan: audio 0x2: ac3, rate=48000Hz, bitrate=384000 Francais (AC3) (5.1 ch)
[21:15:57] scan: audio 0x3: ac3, rate=48000Hz, bitrate=192000 Espanol (AC3) (2.0 ch) (Dolby Surround)
[21:15:57] scan: audio 0x4: ac3, rate=48000Hz, bitrate=192000 English (AC3) (2.0 ch)
Scanning title 1 of 1, preview 5, 50.00 %[21:15:57] scan: 10 previews, 720x480, 23.976 fps, autocrop = 0/2/0/0, aspect 4:3, PAR 8:9
[21:15:57] libhb: scan thread found 1 valid title(s)
+ title 1:
+ stream: C:\DVD movies\Over the Hedge.mkv
+ duration: 01:23:16
+ size: 720x480, pixel aspect: 8/9, display aspect: 1.33, 23.976 fps
+ autocrop: 0/2/0/0
+ support opencl: yes
+ support hwd: no
+ chapters:
+ 1: cells 0->0, 0 blocks, duration 00:07:55
+ 2: cells 0->0, 0 blocks, duration 00:02:21
+ 3: cells 0->0, 0 blocks, duration 00:05:16
+ 4: cells 0->0, 0 blocks, duration 00:03:24
+ 5: cells 0->0, 0 blocks, duration 00:05:04
+ 6: cells 0->0, 0 blocks, duration 00:03:45
+ 7: cells 0->0, 0 blocks, duration 00:03:59
+ 8: cells 0->0, 0 blocks, duration 00:02:34
+ 9: cells 0->0, 0 blocks, duration 00:05:59
+ 10: cells 0->0, 0 blocks, duration 00:10:31
+ 11: cells 0->0, 0 blocks, duration 00:07:02
+ 12: cells 0->0, 0 blocks, duration 00:05:20
+ 13: cells 0->0, 0 blocks, duration 00:05:56
+ 14: cells 0->0, 0 blocks, duration 00:04:52
+ 15: cells 0->0, 0 blocks, duration 00:01:32
+ 16: cells 0->0, 0 blocks, duration 00:07:45
+ audio tracks:
+ 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
+ 2, Francais (AC3) (5.1 ch) (iso639-2: fra), 48000Hz, 384000bps
+ 3, Espanol (AC3) (2.0 ch) (Dolby Surround) (iso639-2: spa), 48000Hz, 192000bps
+ 4, English (AC3) (2.0 ch) (iso639-2: eng), 48000Hz, 192000bps
+ subtitle tracks:
+ 1, English (iso639-2: eng) (Bitmap)(VOBSUB)
+ 2, French (iso639-2: fra) (Bitmap)(VOBSUB)
+ 3, Spanish (iso639-2: spa) (Bitmap)(VOBSUB)
+ 4, English (iso639-2: eng) (Bitmap)(VOBSUB)
+ 5, French (iso639-2: fra) (Bitmap)(VOBSUB)
+ 6, Spanish (iso639-2: spa) (Bitmap)(VOBSUB)
Reading chapter markers from file C:\Users\Boombatty\AppData\Local\Temp\Over The Hedge-1-chapters.csv
Subtitle Scan Enabled - enabling subtitles if found for foreign language segments
[21:15:57] 2 job(s) to process
[21:15:57] starting job
[21:15:57] sync: expecting 119791 video frames
[21:15:57] job configuration:
[21:15:57] * source
[21:15:57] + C:\DVD movies\Over the Hedge.mkv
[21:15:57] + title 1, chapter(s) 1 to 16
[21:15:57] + container: matroska,webm
[21:15:57] * destination
[21:15:57] + C:\Plex\Over The Hedge.m4v
[21:15:57] + container: MPEG-4 (libavformat)
[21:15:57] + chapter markers
[21:15:57] * video track
[21:15:57] + decoder: mpeg2video
[21:15:57] + bitrate 9800 kbps
[21:15:57] + filters
[21:15:57] + Framerate Shaper (0:27000000:1126125)
[21:15:57] + frame rate: same as source (around 23.976 fps)
[21:15:57] + Crop and Scale (720:478:0:2:0:0)
[21:15:57] + source: 720 * 480, crop (0/2/0/0): 720 * 478, scale: 720 * 478
[21:15:57] + loose anamorphic
[21:15:57] + storage dimensions: 720 * 478, mod 2
[21:15:57] + pixel aspect ratio: 8 / 9
[21:15:57] + display dimensions: 640 * 478
[21:15:57] * Foreign Audio Search: Passthrough, Forced Only
[21:15:57] + subtitle, English (track 5, id 0x5) Picture [VOBSUB]
[21:15:57] + subtitle, English (track 8, id 0x8) Picture [VOBSUB]
[21:16:39] reader: done. 1 scr changes
[21:16:39] work: average encoding speed for job is 0.000000 fps
[21:16:39] render: lost time: 0 (0 frames)
[21:16:39] render: gained time: 0 (0 frames) (0 not accounted for)
[21:16:39] mpeg2video-decoder done: 0 frames, 0 decoder errors, 0 drops
[21:16:39] Subtitle track 5 (id 0x5) 'English': 1124 hits (0 forced)
[21:16:39] Subtitle track 8 (id 0x8) 'English': 1417 hits (0 forced)
[21:16:39] No candidate detected during subtitle scan
[21:16:39] starting job
[21:16:39] sync: expecting 119791 video frames
[21:16:39] job configuration:
[21:16:39] * source
[21:16:39] + C:\DVD movies\Over the Hedge.mkv
[21:16:39] + title 1, chapter(s) 1 to 16
[21:16:39] + container: matroska,webm
[21:16:39] * destination
[21:16:39] + C:\Plex\Over The Hedge.m4v
[21:16:39] + container: MPEG-4 (libavformat)
[21:16:39] + chapter markers
[21:16:39] * video track
[21:16:39] + decoder: mpeg2video
[21:16:39] + bitrate 9800 kbps
[21:16:39] + filters
[21:16:39] + Framerate Shaper (0:27000000:1126125)
[21:16:39] + frame rate: same as source (around 23.976 fps)
[21:16:39] + Crop and Scale (720:478:0:2:0:0)
[21:16:39] + source: 720 * 480, crop (0/2/0/0): 720 * 478, scale: 720 * 478
[21:16:39] + loose anamorphic
[21:16:39] + storage dimensions: 720 * 478, mod 2
[21:16:39] + pixel aspect ratio: 8 / 9
[21:16:39] + display dimensions: 640 * 478
[21:16:39] + encoder: H.264 (libx264)
[21:16:39] + preset: veryfast
[21:16:39] + profile: main
[21:16:39] + level: 4.0
[21:16:39] + quality: 20.00 (RF)
[21:16:39] * subtitle track 1, English (track 5, id 0x5) Picture [VOBSUB] -> Passthrough
[21:16:39] * subtitle track 2, French (track 6, id 0x6) Picture [VOBSUB] -> Passthrough
[21:16:39] * subtitle track 3, Spanish (track 7, id 0x7) Picture [VOBSUB] -> Passthrough
[21:16:39] * subtitle track 4, English (track 8, id 0x8) Picture [VOBSUB] -> Passthrough
[21:16:39] * subtitle track 5, French (track 9, id 0x9) Picture [VOBSUB] -> Passthrough
[21:16:39] * subtitle track 6, Spanish (track 10, id 0xa) Picture [VOBSUB] -> Passthrough
[21:16:39] * audio track 1
[21:16:39] + decoder: English (AC3) (5.1 ch) (track 1, id 0x1)
[21:16:39] + bitrate: 448 kbps, samplerate: 48000 Hz
[21:16:39] + mixdown: Dolby Pro Logic II
[21:16:39] + encoder: AAC (libavcodec)
[21:16:39] + bitrate: 160 kbps, samplerate: 48000 Hz
[21:16:39] reader: first SCR -2970 id 0x0 DTS -2970
[21:16:39] encx264: min-keyint: 24, keyint: 240
[21:16:39] encx264: encoding at constant RF 20.000000
[21:16:39] encx264: unparsed options: level=4.0:ref=1:8x8dct=0:weightp=1:subme=2:mixed-refs=0:trellis=0:vbv-bufsize=25000:vbv-maxrate=20000:rc-lookahead=10
x264 [info]: using SAR=8/9
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x264 [info]: profile Main, level 4.0
Code: Select all
Clear-Host
Write-Host -------------------------------------------------------------------------------
Write-Host Handbrake Batch Encoding
#Creating a variable to store the path to all of the source files that will be encoded.
#Change the text below (inside the quotes) to reflect where your files are located
$inputpath = "C:\DVD movies"
Write-Host
Write-Host Input Path --> $inputpath
#getting the output path for the movies. Change this to what you would like it to say.
$outputpath = "C:\Plex"
Write-Host
Write-Host Output Path --> $outputpath
#grabbing the filenames of all of the movies in the folder you just provided.
$movies = ls $inputpath
#handbrake exe file
$handbrake="C:\Program Files\handbrake\handbrakecli.exe"
#The actual logic of the script.
#starting to loop through each movie in your list of movies
foreach($movie in $movies){
#getting the name of the movie, without the file type added to the end.
$name = $movie.basename
Write-host Movie Name --> $name
#getting the path for the chapters. Change this to what you would like it to say.
$chapterpath = "C:\Users\Boombatty\AppData\Local\Temp" + "\" + $name + "-1-chapters.csv"
Write-Host Chapter Path --> $chapterpath
#checking to see if the current movie has already been converted, and is sitting in the output folder.
#this allows you to run the script repeatedly, without it wasting time converting something that is already done.
if(!(test-path -path "$outputpath\$name.mkv")){
Write-host Ok, no file exists... creating one now...
Write-host
#the actual command used to start handbrake, and encode/compress a movie.
#Adjust these settings as necessary.
#These are what I use when encoding, but YMMV for your application
& $handbrake -i "$inputpath\$movie" -t 1 --angle 1 -o "$outputpath\$name.mkv" -f mkv -w 720 --crop 0:2:0:0 --loose-anamorphic --modulus 2 -e x264 -q 20 --vfr -a 1 -E av_aac -6 dpl2 -R Auto -B 160 -D 0 --gain 0 --audio-fallback ac3 --subtitle scan,1,2,3,4,5,6,7,8,9,10 --subtitle-forced=1 --markers="$chapterpath" --encoder-preset=veryfast --encoder-level="4.0" --encoder-profile=main --verbose=1;
& $handbrake -i "$inputpath\$movie" -t 1 --angle 1 -o "$outputpath\$name.mp4" -f mp4 -w 720 --crop 0:2:0:0 --loose-anamorphic --modulus 2 -e x264 -q 20 --vfr -a 1 -E av_aac -6 dpl2 -R Auto -B 160 -D 0 --gain 0 --audio-fallback ac3 --subtitle scan,1,2,3,4,5,6,7,8,9,10 --subtitle-forced=1 --markers="$chapterpath" --encoder-preset=veryfast --encoder-level="4.0" --encoder-profile=main --verbose=1;
}
else{
write-host File exists... moving on.
Write-host
}
}
Any help is appreciated. Please let me know what additional information is needed.
Respectfully,
Boombatty