[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 idwma 于 2021-9-9 16:01 编辑
  1. setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b/s/a-d "%~dp0*.mp4"') do (
  3. for /f "tokens=2,3 delims=,: " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do set /a str=(%%a*60+%%b)/9
  4. set BianLiang=!str!
  5. if 1==1 (
  6. :loop
  7. set /a n+=1
  8. ffmpeg.exe" -i "%%i" -ss 00:!BianLiang!:00 -frames:v 1 "%%~dpni0!n!.png"
  9. set /a BianLiang=!str!+!BianLiang!
  10. if not "!n!"=="9" goto :loop
  11. )
  12. set n=
  13. )
复制代码

TOP

本帖最后由 idwma 于 2021-9-9 17:13 编辑

回复 3# Batcher


    这样呀那改成用秒来算
  1. setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b/s/a-d "%~dp0*.mp4"') do (
  3. for /f "tokens=2 delims=: " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "lasttimestamp"') do set /a str=%%a/10
  4. set BianLiang=!str!
  5. if 1==1 (
  6. :loop
  7. set /a n+=1
  8. ffmpeg.exe" -i "%%i" -ss !BianLiang! -frames:v 1 "%%~dpni0!n!.png"
  9. set /a BianLiang=!str!+!BianLiang!
  10. if not "!n!"=="9" goto :loop
  11. )
  12. set n=
  13. )
复制代码

TOP

回复 6# thp2008
  1. setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b/s/a-d "%~dp0*.mp4"') do (
  3. for /f "tokens=2 delims=: " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "lasttimestamp"') do set /a str=%%a/10
  4. set BianLiang=!str!
  5. if 1==1 (
  6. set file=%%i
  7. set out=%%~dpni
  8. :loop
  9. set /a n+=1
  10. ffmpeg -i "!file!" -ss !BianLiang! -frames:v 1 "!out!0!n!.png"
  11. set /a BianLiang=!str!+!BianLiang!
  12. if not "!n!"=="9" goto :loop
  13. )
  14. set n=
  15. )
复制代码

TOP

回复 8# thp2008


    有的视频没有lasttimestamp信息,尴尬

TOP

本帖最后由 idwma 于 2021-9-9 20:45 编辑

回复 8# thp2008
  1. setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b/s/a-d "*.mp4"') do (
  3. for /f "tokens=2,3,4 delims=:. " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
  4. set hh=%%a
  5. set mm=%%b
  6. set ss=%%c
  7. )
  8. if "!hh:~0,1!"=="0" (set /a hh=!hh:~-1!*3600) else (set /a hh=!hh!*3600)
  9. if "!mm:~0,1!"=="0" (set /a mm=!mm:~-1!*60) else (set /a mm=!mm!*60)
  10. set /a str=!hh!+!mm!+!ss!
  11. set /a BianLiang=!str!/10
  12. set str=!BianLiang!
  13. for /l %%d in (1,1,9) do (
  14. ffmpeg -i "%%i" -ss !BianLiang! -frames:v 1 "%%~dpni0%%d.png"
  15. set /a BianLiang=!str!+!BianLiang!
  16. )
  17. )
复制代码
1

评分人数

    • thp2008: 正常运行,解决问题,感谢!技术 + 1

TOP

回复 11# thp2008
  1. setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in ('dir /b/s/a-d "*.mp4"') do (
  3. for /f "tokens=2,3,4 delims=:. " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
  4. set hh=%%a
  5. set mm=%%b
  6. set ss=%%c
  7. )
  8. if "!hh:~0,1!"=="0" (set /a hh=!hh:~-1!*3600) else (set /a hh=!hh!*3600)
  9. if "!mm:~0,1!"=="0" (set /a mm=!mm:~-1!*60) else (set /a mm=!mm!*60)
  10. set /a str=!hh!+!mm!+!ss!
  11. set /a BianLiang=!str!/10
  12. set str=!BianLiang!
  13. for /l %%d in (1,1,9) do (
  14. ffmpeg -i "%%i" -ss !BianLiang! -frames:v 1 "%%~dpni0%%d.png"
  15. set /a BianLiang=!str!+!BianLiang!
  16. )
  17. echo "%%~dpni01.png" >filelist.txt
  18. echo "%%~dpni02.png" >>filelist.txt
  19. echo "%%~dpni03.png" >>filelist.txt
  20. echo "%%~dpni04.png" >>filelist.txt
  21. echo "%%~dpni05.png" >>filelist.txt
  22. echo "%%~dpni06.png" >>filelist.txt
  23. echo "%%~dpni07.png" >>filelist.txt
  24. echo "%%~dpni08.png" >>filelist.txt
  25. echo "%%~dpni09.png" >>filelist.txt
  26. "%~dp0MagickFull\magick.exe" montage @filelist.txt -geometry +0+0 -background #00000000 "%%~dpni-YuLan.jpg"
  27. del filelist.txt /q
  28. del "%%~dpni01.png" /q
  29. del "%%~dpni02.png" /q
  30. del "%%~dpni03.png" /q
  31. del "%%~dpni04.png" /q
  32. del "%%~dpni05.png" /q
  33. del "%%~dpni06.png" /q
  34. del "%%~dpni07.png" /q
  35. del "%%~dpni08.png" /q
  36. del "%%~dpni09.png" /q
  37. )
复制代码

TOP

回复 14# thp2008


    把时间放在前面会快很多
ffmpeg -ss !BianLiang! -i "%%i" -frames:v 1 "%%~dpni0%%d.png"
1

评分人数

    • thp2008: 我按着你说的改了一下,速度飞快,谢谢!技术 + 1

TOP

回复 19# thp2008
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. cd /d "%~dp0"
  4. for /f "delims=" %%i in ('dir /b /s /a-d "*.mp4" "*.mkv"') do (
  5. if not exist "%%~dpni-YuLan.jpg" (
  6.     for /f "tokens=2,3,4 delims=:. " %%a in ('ffmpeg -i "%%i" 2^>^&1 ^| find "Duration:"') do (
  7.         set hh=%%a
  8.         set mm=%%b
  9.         set ss=%%c
  10.     )
  11.     if "!hh:~0,1!"=="0" (set /a hh=!hh:~-1!*3600) else (set /a hh=!hh!*3600)
  12.     if "!mm:~0,1!"=="0" (set /a mm=!mm:~-1!*60) else (set /a mm=!mm!*60)
  13.     set /a str=!hh!+!mm!+!ss!
  14.     set /a BianLiang=!str!/10
  15.     set str=!BianLiang!
  16.     for /l %%d in (1,1,9) do (
  17.         ffmpeg -ss !BianLiang! -i "%%i" -frames:v 1 "TempABC0%%d.jpg"
  18.         set /a BianLiang=!str!+!BianLiang!
  19.     )
  20.     (for /l %%x in (1,1,9) do (
  21.         echo "TempABC0%%x.jpg"
  22.     ))>"filelist.txt"
  23.     "%~dp0MagickFull\magick.exe" montage @filelist.txt -geometry +0+0 -background #00000000 "Temp999-Full.jpg"
  24.      move /y "Temp999-Full.jpg" "%%~dpni-YuLan.jpg"
  25.     del /q /f filelist.txt "TempABC0*.jpg"
  26. )
  27. )
复制代码
1

评分人数

TOP

返回列表