简体   繁体   English

Windows CMD 批处理脚本 FFmpeg

[英]Windows CMD Batch Script FFmpeg

I have created a batch file (.bat) that uses FFmpeg to transcode various videos (with *.mov or *.mp4 file name extension) from an input folder to an output folder (with extension *.mkv) as batch process (Windows 10 environment).我创建了一个批处理文件 (.bat),它使用 FFmpeg 将输入文件夹中的各种视频(带有 *.mov 或 *.mp4 文件扩展名)转码到 output 文件夹(扩展名 *.mkv)作为批处理(Windows 10 环境)。 File names (without extension) from the input folder should be copied to the newly created output file names (that have the new file extension *.mkv).输入文件夹中的文件名(无扩展名)应复制到新创建的 output 文件名(具有新文件扩展名 *.mkv)。

@echo off

set CMD=ffmpeg -c:v ffv1 -level 3 -g 1 -coder 1 -context 1 -pix_fmt + -slices 24 -slicecrc 1 -report -c:a pcm_s24le

FOR /R input_folder %%G IN (*.mov,*.mp4) DO (
   echo %%G
   call set outputfile=%%~nG%.mkv
   call set inputfile=%%~nG%%~xG
   echo %CMD% -y output_folder/%outputfile% -i %inputfile%
)

But this script does not work as expected, ie nothing happens.但是这个脚本没有按预期工作,即没有任何反应。 Do you perhaps have an idea how to fix this?你可能知道如何解决这个问题吗? Thanks in advance!提前致谢!

Here's an example showing my suggestions from the comments, with the addition of the file deletion as requested in the comments too.这是一个示例,显示了我从评论中提出的建议,并根据评论中的要求添加了文件删除。 This assumes that ffmpeg returns an errorlevel of 0 upon success, (you don't want to delete them if the processing failed), and that there is an existing directory named output_folder , in the current working directory.这假设 ffmpeg 在成功时返回错误级别0 (如果处理失败,您不想删除它们),并且在当前工作目录中有一个名为output_folder的现有目录。

@Echo Off
SetLocal EnableExtensions
Set "CMD=ffmpeg.exe -c:v ffv1 -level 3 -g 1 -coder 1 -context 1 -pix_fmt +"
Set "CMD=%CMD% -slices 24 -slicecrc 1 -report -c:a pcm_s24le"

For /R "input_folder" %%G In (*.mov *.mp4) Do (
    Echo %%G
    %CMD% -y "output_folder\%%~nG.mkv" -i "%%G"
    If Not ErrorLevel 1 Del /A /F "%%G"
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM