0

我正在尝试设置一个简单的批处理文件来使用手刹来压缩视频。我安装了 Handbrake,发现我需要单独安装 HandbrakeCLI。我下载HandBrakeCLI.exe并放置在C:\. 然后我做了一个预设并使用GUI. 然后我这样打电话handbrake

@echo off
for %%f in (*.mpg) do (
    C:\HandBrakeCLI -i 'C:\Users\rv\Desktop\Newfolder\%%f' -o 'C:\encode\%%f.mp4'
)
pause

我收到以下错误,告诉我文件类型无法识别:

[10:19:30] dvd: not a dvd - trying as a stream/file instead
[10:19:30] hb_stream_open: open 'C:\Users\rv\Desktop\Newfolder\126_812-714A_812-713_111914_san.mpg' 
failed
[10:19:30] scan: unrecognized file type
[10:19:30] libhb: scan thread found 0 valid title(s)
No title found.

关于为什么命令行版本突然无法打开文件的任何想法?相同的文件可以在 中打开GUI并进行转换。

我尝试重新安装所有内容并删除预设文件夹,即使这似乎不是问题。


更新:这是对我有用的最终代码。

@echo off
set /A count_complete = 0
set /A count_total = 0
pushd %~dp0
for /R %%f in (*.mp2, *.mpg, *.vob, *.avi, *.wmv, *.mov, *.m4v, *.mpeg, *.mp4) do (
   set /A count_total+=1
)
for /R %%f in (*.mp4) do (
   echo Count is currently %count% of %count_total%
   C:\HandBrakeCLI --preset-import-gui C:\Users\xxx\Desktop\customencode.json -Z "CustomCompress" -i "%%f" -o "%%~dpf%%~nf_conv.mp4"
    if exist "%%~dpf%%~nf_conv.mp4" (
        del "%%f"
        ren "%%~dpf%%~nf_conv.mp4" "%%~nf.mp4"
        set /A count_complete+=1
    ) 
)
for /R %%f in (*.mp2, *.mpg, *.vob, *.avi, *.wmv, *.mov, *.m4v, *.mpeg) do (
   echo Count is currently %count% of %count_total%
   C:\HandBrakeCLI --preset-import-gui C:\Users\xxxxx\Desktop\customencode.json -Z "CustomCompress" -i "%%f" -o "%%~dpf%%~nf_conv.mp4"
    if exist "%%~dpf%%~nf_conv.mp4" (
        del "%%f"
        ren "%%~dpf%%~nf_conv.mp4" "%%~nf.mp4"
        set /A count_complete+=1
    )
)
popd
echo Count is: %count% out of %count_try% attempted.
pause
4

1 回答 1

1

我需要使用双引号而不是单引号。像这样:

@echo off
for %%f in (*.mpg) do (
C:\HandBrakeCLI -i "C:\Users\rv\Desktop\Newfolder\%%f" -o "C:\encode\%%f.mp4"
)
pause
于 2018-11-26T16:15:16.743 回答