Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###
- # Convert any video file to a DVD-ready MPG.
- #
- # This not only converts any file to ~4.7GB it also outputs it to
- # NTSC in MPG format at 720p resolution.
- #
- # @see https://unix.stackexchange.com/a/598360
- #
- # @since Dec 30, 2022
- ##
- todvd () {
- local file="$1"
- local target_size_mb=4650 # DVD = 4700 MB
- local target_size=$(( $target_size_mb * 1000 * 1000 * 8 )) # target size in bits
- local length=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file"`
- local length_round_up=$(( ${length%.*} + 1 ))
- local total_bitrate=$(( $target_size / $length_round_up ))
- local audio_bitrate=$(( 128 * 1000 )) # 128k bit rate
- local 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" -vf scale=-1:720 -target ntsc-dvd "${file}-${target_size_mb}MB.mpg"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement