I want to generate thumbnails using ffmpeg
, but it seems there exists a bug.
I have written the below code to make this bug reproducible.
#!/usr/bin/env bash
## setup
lab_home="/tmp/playground"
\mkdir -p "$lab_home" && \cd "$lab_home"
\ffmpeg -f lavfi -i testsrc -t 30 -pix_fmt yuv420p -loglevel quiet sample-01.mp4
\ffmpeg -f lavfi -i testsrc -t 30 -pix_fmt yuv420p -loglevel quiet sample-02.mp4
## bug
\find "$lab_home" -type f -name "*.mp4" -print0 |\
while read -r -d $'\0' video; do
\echo "$video"
\ffmpeg -i "$video" \
-y -f rawvideo \
-pix_fmt bgra \
-c:v rawvideo \
-frames:v 1 \
-loglevel quiet \
-vf "scale=iw*min(1\,min(192/iw\,108/ih)):-2,pad=192:108:(192-iw)/2:(108-ih)/2:color=0x00000000" \
"${video}.thumbnail"
done
## clean
#\rm -rf sample-01.mp4 sample-02.mp4 sample-01.mp4.thumbnail sample-02.mp4.thumbnail
why the output is:
/tmp/playground/sample-02.mp4
tmp/playground/sample-01.mp4
instead of
/tmp/playground/sample-02.mp4
/tmp/playground/sample-01.mp4
Remove or comment out the ffmpeg
command work as expected.
User contributions licensed under CC BY-SA 3.0