Created
July 5, 2017 22:10
-
-
Save ultramango/bfee661b59333ef3ffcb7a6824eb6565 to your computer and use it in GitHub Desktop.
Process video frames using ffmpeg with external command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Test video filename | |
TESTVIDEO="testvideo.mp4" | |
OUTVIDEO="output.mp4" | |
# Test video duration in seconds | |
TESTDURATION=5 | |
TESTVIDEOSIZEW=1280 | |
TESTVIDEOSIZEH=720 | |
BYTESPERPIXEL=3 | |
TESTVIDEOSIZE="${TESTVIDEOSIZEW}x${TESTVIDEOSIZEH}" | |
FFMPEGLOGLEVEL="-loglevel quiet" | |
create_test_video() { | |
echo "Creating test video ${TESTVIDEO}" | |
ffmpeg ${FFMPEGLOGLEVEL} -y -f lavfi -i testsrc=duration=${TESTDURATION}:size=${TESTVIDEOSIZE}:rate=30 -f mp4 ${TESTVIDEO} | |
} | |
all_in_one() { | |
# pv tool could be used to monitor progress | |
let READSIZE=${TESTVIDEOSIZEH}*${TESTVIDEOSIZEW}*${BYTESPERPIXEL} | |
echo "Trying in one go..." | |
ffmpeg ${FFMPEGLOGLEVEL} -y -i ${TESTVIDEO} -pix_fmt rgb24 -f rawvideo - | \ | |
split -b ${READSIZE} --filter="convert -size ${TESTVIDEOSIZE} -depth 8 rgb:- png:- | convert png:- -rotate 180 png:-" | \ | |
ffmpeg ${FFMPEGLOGLEVEL} -y -f image2pipe -r 25 -vcodec png -i - -vcodec libx264 ${OUTVIDEO} | |
} | |
create_test_video | |
all_in_one | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment