Last active
April 18, 2021 10:57
-
-
Save jpetazzo/1e2348e4ee02d5a4d63eeda6ac7833cc to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
echo "codec args duration time_real time_user time_sys cpu_percent size_input size_output" | |
for F in *.log; do | |
. ./$F | |
echo "$CODEC $ARGS $duration $TIME_REAL $TIME_USER $TIME_SYS $CPU_PERCENT $SIZE_INPUT $SIZE_OUTPUT" | |
done |
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
#!/bin/sh | |
# This needs a short video file (test.mp4), it will decode it to | |
# raw video (warning: this will use A LOT of disk space!) then | |
# it will try to encode it with a variety of codecs, to compare | |
# their speed, CPU usage, and overall efficiency. | |
# I wrote this script when I was trying to find out what would | |
# be a good "mezzanine codec" to transfer 1080p/30fps video over | |
# gigabit Ethernet as efficiently as possible, where "efficiency" | |
# here means: low CPU usage on the sending side and low latency. | |
# I ended up using HDMI out and an HDMI capture dongle (😅) but | |
# further testing seemed to show that H264 ultrafast/zerolatency | |
# could actually deliver even better results than the codecs I | |
# tested here. 🤷 | |
init() { | |
ffmpeg -i test.mp4 -c:v rawvideo -c:a copy test.nut | |
} | |
test_codec() { | |
KEY=$(echo "$*" | sha256sum | cut -c1-8) | |
CODEC=$1 | |
shift | |
ARGS="$@" | |
LOG=test-$KEY.log | |
OUT=test-$KEY.nut | |
[ -f $OUT ] && return | |
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1 test.nut > $LOG | |
printf "CODEC=%s\nARGS=\"%s\"\n\n" "$CODEC" "$*" >> $LOG | |
pv -cN input test.nut \ | |
| /bin/time -a -f "TIME_REAL=%e\nTIME_USER=%U\nTIME_SYS=%S\nCPU_PERCENT=%P\n" -o $LOG ffmpeg -i - -an -c:v $CODEC $ARGS -f nut - \ | |
| pv -cN output > $OUT | |
stat test.nut --format "SIZE_INPUT=%s" >> $LOG | |
stat $OUT --format "SIZE_OUTPUT=%s" >> $LOG | |
echo | |
cat $LOG | |
} | |
test_codec ffv1 | |
test_codec ffvhuff | |
test_codec prores | |
test_codec mjpeg | |
test_codec mjpeg -qscale:v 1 | |
test_codec mjpeg -qscale:v 2 | |
test_codec mpeg1video | |
test_codec mpeg1video -qscale:v 1 | |
test_codec mpeg1video -qscale:v 2 | |
test_codec mpeg2video | |
test_codec mpeg2video -qscale:v 1 | |
test_codec mpeg2video -qscale:v 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment