FFMPEG - 我试图使用ffmpeg来选择文件夹中的所有.mp4文件,并以文件名作为图像名称截图 [英] FFMPEG - I'm trying to use ffmpeg to select all the .mp4 files in a folder and screenshot them with the file name as the image name

查看:917
本文介绍了FFMPEG - 我试图使用ffmpeg来选择文件夹中的所有.mp4文件,并以文件名作为图像名称截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从来没有处理过.bat文件,所以这对我来说是新的。

I have never dealt with .bat files before so this is new to me.

我正在尝试使用 FFMPEG 来选择文件夹中的所有 .mp4 文件夹,将 .bat 文件放在。然后每隔30分钟将其截图,并输出文件名为+图片编号在 JPEG

I'm trying to use FFMPEG to select all the .mp4 files from a folder I place the .bat file in. Then to get it to screenshot every 30 minutes, and output the files with the input file name + image number in JPEG

这是我到目前为止所想到的:

This is what i came up with so far:

for f in *.mp4; do ffmpeg -i "$f" -vf fps=1/1800 "${f%.mp4}.jpeg";done &&  cp  --copy-contents *.jpeg  ~*outputDirectory* && rm -R *.jpeg

任何帮助将不胜感激。

推荐答案

如果我正在解释?bash?代码正确,这应该做:

If I'm interpreting the ?bash? code correctly this should do:

@Echo off
Set "JPEGdir=%UserProfile%\Outputdirectory"
for %%f in (*.mp4) do ffmpeg -i "%%f" -vf fps=1/1800 "%JPEGdir%\%%~nf_%%d.jpeg"




  • for 变量需要在批处理中以 %% 为前缀(单个在cmd行上)

  • 而不是在源文件夹中创建JPEG,复制和删除,使用目标路径更容易地在目标文件夹中创建它们,只有<一个href =https://ss64.com/nt/syntax-args.html =nofollow noreferrer>文件名不带驱动器,路径和扩展名%%〜n 为新名称,附加ffmpeg函数附加一个数字%d (这个百分号必须用第二个转义)

    • for variables need to be prefixed with %% in a batch (single % on the cmd line)
    • instead of creating the JPEG in the source folder, copy and delete, it's easier to create them straight in the destination folder by using the destination path and only the filename without drive, path and extension %%~n for the new name, appending the ffmpeg function to append a number %d (this percent sign has to be escaped with a second one)
    • 修改添加文件夹创建:

      @Echo off
      Set "JPEGdir=%UserProfile%\Ouputdirectory"
      for %%f in (*.mp4) do (
        If not Exist "%JPEGdir%\%%~nf" MkDir "%JPEGdir%\%%~nf"
        ffmpeg -i "%%f" -vf fps=1/1800 "%JPEGdir%\%%~nf\%%~nf_%%d.jpeg"
      )
      

      我从你的bash代码中导出目标文件夹,如果你想要新的文件夹当前dir代替,只是设置JPEGdir =。

      I derived the destination folder from your bash code, if you want the new folder in the current dir instead, just set "JPEGdir=."

      这篇关于FFMPEG - 我试图使用ffmpeg来选择文件夹中的所有.mp4文件,并以文件名作为图像名称截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆