Last active
August 29, 2015 14:01
-
-
Save jcayzac/d78bc9723d8b8e2fd525 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# assuming SAR is 1:1, | |
SRC=Foo.mp4 | |
SRC_WIDTH=1916 | |
SRC_HEIGHT=852 | |
DST_WIDTH=720 | |
DST_HEIGHT=480 | |
DST_ASPECT=16/9 | |
DST_FPS=24000/1001 | |
DST_RATE=4100k | |
# the height of the video inside the frame | |
DST_VIDEO_HEIGHT=$(printf '%.0f' $(bc -l <<<"($SRC_HEIGHT) * ($DST_HEIGHT) * ($DST_ASPECT) / ($SRC_WIDTH)")) | |
# if it's odd, make it even | |
(( !(DST_VIDEO_HEIGHT & 1) )) || ((++DST_VIDEO_HEIGHT)) | |
# vertical offset to the video inside the frame | |
DST_VIDEO_Y=$(( (DST_HEIGHT-DST_VIDEO_HEIGHT) / 2 )) | |
ffmpeg -threads 8 -i "$SRC" -cpuflags +avx -vf "scale=w=$DST_WIDTH:h=$DST_VIDEO_HEIGHT:interl=-1,pad=width=$DST_WIDTH:height=$DST_HEIGHT:x=0:y=$DST_VIDEO_Y:color=black" -c:v mpeg2video -f dvd -s ${DST_WIDTH}x$DST_HEIGHT -aspect $DST_ASPECT -r $DST_FPS -pix_fmt yuv420p -g 15 -b:v $DST_RATE -maxrate 8000000 -minrate 0 -bufsize 1835008 -packetsize 2048 -pass 1 -an -y tmp.mpg | |
ffmpeg -threads 8 -i "$SRC" -cpuflags +avx -vf "scale=w=$DST_WIDTH:h=$DST_VIDEO_HEIGHT:interl=-1,pad=width=$DST_WIDTH:height=$DST_HEIGHT:x=0:y=$DST_VIDEO_Y:color=black" -c:v mpeg2video -c:a copy -f dvd -s ${DST_WIDTH}x$DST_HEIGHT -aspect $DST_ASPECT -r $DST_FPS -pix_fmt yuv420p -g 15 -b:v $DST_RATE -maxrate 8000000 -minrate 0 -bufsize 1835008 -packetsize 2048 -pass 2 -y output.mpg | |
VIDEO_FORMAT=NTSC dvdauthor -o dvd -t output.mpg | |
VIDEO_FORMAT=NTSC dvdauthor -o dvd -T | |
mkisofs -dvd-video -udf -V "Foo" -o dvd.iso dvd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment