diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 9d58731..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -renders/* filter=lfs diff=lfs merge=lfs -text diff --git a/renders/dragon.mp4 b/renders/dragon.mp4 index 64714ba..65549a7 100644 Binary files a/renders/dragon.mp4 and b/renders/dragon.mp4 differ diff --git a/renders/sponza.mp4 b/renders/sponza.mp4 index 981df24..8ce50a8 100644 Binary files a/renders/sponza.mp4 and b/renders/sponza.mp4 differ diff --git a/renders/test.sh b/renders/test.sh index c37330b..cbbc1b9 100755 --- a/renders/test.sh +++ b/renders/test.sh @@ -1,3 +1,23 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cffb5c4319b966658663ee89470c5c8baa45cc503852592fa09c312d3b0f5b30 -size 747 +#!/usr/bin/env bash +set -e + +if [ $# -ne 3 ]; then + echo "Usage: $0 target_size_MB input_file output_file" + exit 1 +fi + +target_size_mb="$1" +input_file="$2" +output_file="$3" + +duration=$(ffprobe -v error -select_streams v:0 -show_entries format=duration \ + -of default=noprint_wrappers=1:nokey=1 "$input_file") +duration=${duration%.*} # remove decimals +target_size_kbit=$((target_size_mb * 8192)) # 1 MB = 8192 kbit +bitrate=$((target_size_kbit / duration)) +clear +echo " bitrate : $bitrate" +ffmpeg -y -i "$input_file" -c:v libx264 -b:v "${bitrate}k" -pass 1 -an -f mp4 /dev/null && \ +ffmpeg -i "$input_file" -c:v libx264 -b:v "${bitrate}k" -pass 2 -c:a aac -b:a 128k "$output_file" +rm -f ffmpeg2pass-0.log* +