Board logo

标题: [文本处理] 求助批处理批量视频转GIF哪里不对? [打印本页]

作者: jiangyver    时间: 6 天前 10:29     标题: 求助批处理批量视频转GIF哪里不对?

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set ffmpegPath=D:\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe[quote]软件路径[/quote]
  4. set inputFolder=%~dp0
  5. set outputFolder=%inputFolder%GIFs
  6. if not exist %outputFolder% mkdir %outputFolder%
  7. for %%i in (%inputFolder%.mp4) do (
  8.     echo Converting %%i...
  9.     %ffmpegPath% -i %%i -ss 000000 -t 000500 -vf scale=320-1flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse %outputFolder%%%~ni.gif
  10.     echo Converted %%i to %outputFolder%%%~ni.gif
  11. )
  12. echo All MP4 files have been processed.
复制代码

作者: Five66    时间: 6 天前 18:44

试试将12行滤镜链里的
  1. scale=320-1flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse
复制代码
换成
  1. "scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse[out]" -map "[out]"
复制代码

作者: fzp070    时间: 4 天前 13:39

稍微调整了下,在我这可以转换gif文件。320的图太小了,换成了720。楼主试试看吧
  1. @echo off
  2. color 3f
  3. title FFmpeg批量视频转GIF
  4. setlocal enabledelayedexpansion
  5. set ffmpegPath=D:\ffmpeg-master-latest-win64-gpl-shared\bin\ffmpeg.exe&rem 软件路径
  6. set inputFolder=%~dp0
  7. set outputFolder=%inputFolder%GIFs
  8. if not exist "%outputFolder%" mkdir "%outputFolder%"
  9. for %%i in ("%inputFolder%*.mp4") do (
  10.     echo 转换【%%~ni.mp4】...
  11.     if exist "%outputFolder%\%%~ni.gif" echo.&echo ---注:视频已有GIF文件,程序退出!--- &goto end
  12.     "%ffmpegPath%" -i "%%i" -y -ss 000000 -t 000500 -vf scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse "%outputFolder%\%%~ni.gif">nul 2>nul
  13.     echo.&echo 已转换 "%%~ni.mp4" to "%%~ni.gif"
  14. )
  15. echo.&echo 所有 MP4 文件均已处理。
  16. :end
  17. TIMEOUT /T 5 /NOBREAK
  18. exit
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2