I need to get the width and height of an image file using ffprobe and need to store it in variables using batch (Windows) so I can later use those values.
I tried to do this,
@echo off
for /f "tokens=1-2" %%i in ('ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=width,height %1') do set W=%%i & set H=%%j
echo %W%
echo %H%
But fails to execute with
Argument '_' provided as input filename, but 's' was already specified.
p.s. I also tried imagemagick identify in a similar way, but it seems that identify has a bug when returning height for GIF files
I have managed to adjust you script and it's working, you can try this way :
@echo off
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=width %1 >> width.txt
ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height %1 >> height.txt
FOR /f "tokens=5 delims==_" %%i in (width.txt) do @set width=%%i
FOR /f "tokens=5 delims==_" %%i in (height.txt) do @set height=%%i
echo width=%width%
echo height=%height%
del width.txt && del height.txt
pause