Advertisement
Guest User

Untitled

a guest
Dec 30th, 2022
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. ###
  2.  # Convert any video file to a DVD-ready MPG.
  3.  #
  4.  # This not only converts any file to ~4.7GB it also outputs it to
  5.  # NTSC in MPG format at 720p resolution.
  6.  #
  7.  # @see https://unix.stackexchange.com/a/598360
  8.  #
  9.  # @since Dec 30, 2022
  10.  ##
  11. todvd () {
  12.  
  13.     local file="$1"
  14.     local target_size_mb=4650 # DVD = 4700 MB
  15.     local target_size=$(( $target_size_mb * 1000 * 1000 * 8 )) # target size in bits
  16.     local length=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file"`
  17.     local length_round_up=$(( ${length%.*} + 1 ))
  18.     local total_bitrate=$(( $target_size / $length_round_up ))
  19.     local audio_bitrate=$(( 128 * 1000 )) # 128k bit rate
  20.     local video_bitrate=$(( $total_bitrate - $audio_bitrate ))
  21.  
  22.     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"
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement