#!/usr/bin/env bash which ffmpeg if [ $# -lt 1 ] ; then echo "Usage: ${0} INPUT" echo "Example input can be generated with: " echo " ffmpeg -v verbose -filter_complex 'testsrc2=r=25:s=640x480:d=470[out]' -map '[out]' -c:v libx264 -preset superfast test_clip.mp4" exit 1 fi INPUT="${1}" COPY_OUTPUT="${INPUT}_copy.mp4" IMG2_OUTPUT="${INPUT}_img2.jpg" echo "Input: ${INPUT}" # if you get ooms, feel free to utilize ulimit # (ulimit -v 5000000 && ) /usr/bin/time -v \ ffmpeg \ -y -ignore_unknown \ -v verbose \ -i "${INPUT}" \ -c copy -map 0 \ -t 470 \ "${COPY_OUTPUT}" \ -filter_complex '[0:0]split=1[thumb_in];[thumb_in]trim=start=420:end=421,scale=720:-2:threads=1,setsar=1/1,hqdn3d,unsharp[thumb_out]' \ -map "[thumb_out]" \ -vframes 1 \ -f image2 \ "${IMG2_OUTPUT}"