Replies: 1 comment
-
一些shell可能不支持 file="input.mp4"
target_size_mb=10
target_size=$(( $target_size_mb * 1000 * 1000 * 8 ))
length=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file"`
length_round_up=$(( ${length%.*} + 1 ))
total_bitrate=$(( $target_size / $length_round_up ))
audio_bitrate=$(( 128 * 1000 ))
video_bitrate=$(( $total_bitrate - $audio_bitrate ))
ffmpeg -i "$file" -b:v $video_bitrate -maxrate:v $video_bitrate -bufsize:v $(( $target_size / 20 )) -b:a $audio_bitrate "${file}-${target_size_mb}mb.mp4" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
ffmpeg是款命令行工具,首先需要安装它。
把上面的“XXX.mp4”替换为你的视频路径,把25替换为你期望的结果大小,然后复制到你的shell中运行即可在相同目录下得到压缩后的视频。
参考:https://unix.stackexchange.com/a/598360
Beta Was this translation helpful? Give feedback.
All reactions