diff --git a/modules/video_previews.sh b/modules/video_previews.sh index a250361..0ba0148 100755 --- a/modules/video_previews.sh +++ b/modules/video_previews.sh @@ -37,9 +37,9 @@ create_previews() { get_size() { IFS=',' - read -r width height <<< $(ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0 "${video}") + read -r width height <<< $(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 "${video}") - if [[ $width -gt $height ]]; then + if (( $width >= $height )); then rows=4 cols=5 scale_format="200:-1" else @@ -61,9 +61,10 @@ make_preview() { get_size get_num_frames - filename="$(basename "${video}")" + filename="$preview_dir/$(basename "${video}").webp" + filters="select=not(mod(n\,$frames_per_snapshot)),scale=$scale_format,tile=${rows}x${cols}" - ffmpeg -nostdin -loglevel panic -i "${video}" -frames 1 -q:v 90 -vf "select=not(mod(n\,$frames_per_snapshot)),scale=$scale_format,tile=${rows}x${cols}" "$preview_dir/${filename}.webp" + ffmpeg -nostdin -loglevel panic -i "${video}" -frames 1 -q:v 90 -vf "$filters" "${filename}" } check_dependencies