问题
[swscaler @ 0000019531bb00c0] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'temp_frames/frame%08d.jpg':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
encoder : Lavf60.11.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
Metadata:
creation_time : 2023-09-29T13:37:07.000000Z
handler_name : ?Mainconcept Video Media Handler
vendor_id : [0][0][0][0]
encoder : Lavc60.26.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[image2 @ 000001951c61b980] Could not open file : temp_frames/frame00000001.jpg
[vost#0:0/mjpeg @ 000001951c603e80] Error submitting a packet to the muxer: I/O error
[out#0/image2 @ 000001951cb8ee80] Error muxing a packet
[out#0/image2 @ 000001951cb8ee80] video:389kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
frame= 1 fps=0.0 q=1.0 Lsize=N/A time=00:00:00.24 bitrate=N/A speed=1.03x
Conversion failed!
我注意到,按照针对类似问题的建议,对“%”字符使用转义码“%%”可以解决问题:
ffmpeg -i video.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 tmp_frames/frame%%08d.jpg
但是,即使在拖放批处理文件中使用该命令也会出现相同的问题:
setlocal enabledelayedexpansion
REM Check if an MP4 file was dragged onto the script
if "%~1"=="" (
echo Drag an MP4 file onto this script to begin frame extraction.
pause
exit /b
)
REM Extract frames from the MP4 file
ffmpeg -i "%~1" -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 temp_frames/frame%%08d.jpg
echo Extraction complete.
pause
这本质上是相同的代码,但它在批处理文件中无法按预期工作。任何人都可以深入了解为什么会出现此问题以及如何在批处理文件上下文中解决它?
使用单个 % 作为输出文件名并将其放在双引号中。
setlocal enabledelayedexpansion
REM Check if an MP4 file was dragged onto the script
if "%~1"=="" (
echo Drag an MP4 file onto this script to begin frame extraction.
pause
exit /b
)
REM Extract frames from the MP4 file
ffmpeg -i "%~1" -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 "temp_frames/frame%08d.jpg"
echo Extraction complete.
pause