#!/bin/bash #################################################################### # process a single movie: convert from MKV to MP4, set bitrate and # # frame rates depending on class, or use quality factor, remove # # subtitles and other extraneous streams # # # # last updated 07-03-2020 # #################################################################### # MAKEMKVCON FOR IMAGES # makemkvcon mkv iso:./ConspiracyTheory1997.img all temp # makemkvcon mkv file:[folderpath] all temp # -map 0:v -map 1:a # -ss: 00:05:00 -t: 00:05:00 # -channel_layout '5.1' # -metadata title="I [VHS] (1984)" -metadata year="1984" -metadata class="VHS" # If you use quality, let the viewer know what crf you used: -metadata crf="10" # recommended values by handbrake (aXXo) are 17–28 for x264 # -crf nn: variable quality percentages # -crf 0 = 100%, 1 ~ 98%, 5 ~ 90%, 8 ~ 84%, 10 ~ 80%, 13 ~ 75%, 18 ~ 65%, 23 ~ 55%, 28 ~ 45%, 51 = 0% # convert to 44,100 128k stereo: -ac 2 -ar 44100 -ab 128k # convert to 128k mono: -ac 1 -ab 128k # concatenate # in.txt file contents # this is a comment #file '/path/to/file1' #file '/path/to/file2' #file '/path/to/file3' #ffmpeg -f concat -safe 0 -i in.txt -c copy "WitchSoldiers.mp3"; # Combining multi-file already encoded movies or miniseries #ffmpeg -i Lavoie.mp4 -ss: 00:49:51 -t: 00:43:47 -c copy Lavoie.mp4 # resyncing audio (fixing virtualdub error but you don't have Handbrake) # test #ffmpeg -i "/Volumes/Aslan/Movies/Joy [UHD] [SOUNDNOTSYNCEDSLIGHTLY] (2015).mp4" -itsoffset 0.22 -i "/Volumes/Aslan/Movies/Joy [UHD] [SOUNDNOTSYNCEDSLIGHTLY] (2015).mp4" -map 0:v -map 1:a -ss: 00:05:00 -t: 00:05:00 -c copy "a2.mp4" # allofit #ffmpeg -i "/Volumes/Aslan/Movies/Joy [UHD] [SOUNDNOTSYNCEDSLIGHTLY] (2015).mp4" -itsoffset 0.22 -i "/Volumes/Aslan/Movies/Joy [UHD] [SOUNDNOTSYNCEDSLIGHTLY] (2015).mp4" -map 0:v -map 1:a -c copy "/Volumes/Aslan/Movies/Joy [UHD] [SOUNDNOTSYNCEDSLIGHTLY] (2015)2.mp4" # Film (before 1972) # "the young teacher", a south korean indy, was the first movie to be released on VHS videotape. # So, any movies that were released before 1971 were first transcribed from film to VHS, then from VHS to DVD. # Any movies that were not professionaly transcribed might need special processing in this section. # It's recommended to use quality factors (crf) rather than constant bitrates; they will be small anyway (or should be). # VHS (1972 - 1995) # These are old enough that they can be converted straight through, removing any foreign language audio tracks. # I rarely use ffmpeg command line directly for these except in special cases or I want to add metadata; # Handbrake can do these. # Sometimes need to be converted to mono or MP3. # Multiple AVIs are common in this class and need to be concatenated; Handbrake can't do that (yet). # -map 0:0 -map 0:1 -channel_layout '5.1' -ar 44100k -ab 128k #ffmpeg -i movie.mkv -sn "Completed/whatever [VHS] (year).mp4" #ffmpeg -f concat -safe 0 -i in.txt "Completed/Marathon Man [VHS] (1976).mp4"; # DVD (480p) (1995 - ~2002-ish) # Handbrake can do most of these using quality encoding. # If you want to add metadata later just use ffmpeg command line with -c copy. # -vf scale=720:480 -map 0:0 -map 0:1 -channel_layout '5.1' # -sn -metadata title="" -metadata year="" -metadata class="DVD" -metadata crf="10" #ffmpeg -i "themarine_hd_2006.mkv" -sn -metadata title="The Marine [HD] (2006)" -metadata year="2006" -metadata class="HD" -metadata crf="13" -crf 13 -vf scale=1280:720 -channel_layout '5.1' "Completed/The Marine [HD] (2006).mp4"; # for multi-disk dvd concatenations with edits. Best practice: run these commands one at a time #ffmpeg -i "AnneAvonlea1_1987.mp4" -t: 00:01:34 -c copy "AnneAvonlea1_1987_1.mp4" #ffmpeg -i "AnneAvonlea2_1987.mp4" -ss: 00:01:34 -c copy "AnneAvonlea2_1987_1.mp4" #ffmpeg -i "Bible1_2.mkv" -sn -crf 13 -map 0:0 -map 0:1 -channel_layout '5.1' "Bible1_2.mp4" #ffmpeg -i "Bible1_3.mkv" -sn -crf 13 -map 0:0 -map 0:1 -channel_layout '5.1' "Bible1_3.mp4" #ffmpeg -f concat -safe 0 -i in.txt -metadata title="Anne of Green Gables - of Avonlea [VHS] (1987)" -metadata year="1987" -metadata class="VHS" -metadata crf="18" -c copy "Anne of Green Gables - of Avonlea [VHS] (1987).mp4" # HD (720p - 1080p) (2002 - ~2009-ish) # Any movie released after 2008 should be tested for audio problems on your hardware player first before # processing the full movie. # -b:v 6M -crf 10 -vf scale=1280:720 -map 0:0 -map 0:2 -channel_layout '5.1' -ss: 00:03:00 -t: 00:05:00 # -sn -metadata title="" -metadata year="" -metadata class="HD" -metadata crf="10" #ffmpeg -i "Secondhand Lions [HD] (2003).mkv" -sn \ # -metadata title="Secondhand Lions [HD] (2003)" -metadata year="2003" -metadata class="HD" -metadata crf="13" \ # -crf 13 -vf scale=1280:720 \ # -channel_layout '5.1' "Completed/Secondhand Lions [HD] (2003).mp4"; # HD2K (1080p) (2009 - 2014) # Any movie released 2010 or later should be checked for the Cinavia watermark first with CinDe, # then a small sample tested on your viewing hardware, before processing the full movie. # Sometimes I see these in 10-bit color as they have been downgraded from UHD4K, I call those "HD2K10" # -c:v libx265 -r 30 -b:v 10M -vf scale=1920:1080 # -map 0:0 -map 0:2 -channel_layout '5.1' -ss: 00:03:00 -t: 00:05:00 # -sn -metadata title="" -metadata year="" -metadata class="HD2K" -metadata crf="10" #ffmpeg -i "RED II [HD2K] (2013).mkv" -sn -metadata title="RED II [HD2K] (2013)" \ # -metadata year="2013" -metadata class="HD2K" \ # -r 30 -b:v 15M \ # -channel_layout '5.1' \ # -map 0:0 -map 0:2 \ # "Completed/RED II [HD2K] (2013).mp4"; # "2K" (1080p) (2012 - 2014) # These are rare, but still out there # -b:v 10M -vf scale=2048:1080 -map 0:0 -map 0:2 -channel_layout '5.1' -ss: 00:03:00 -t: 00:05:00 # -sn -metadata title="" -metadata year="" -metadata class="2K" #ffmpeg -i "Jumper20081080p.mkv" -sn -b:v 7.3M -r 30 -vf scale=2048:1080 "/Volumes/Aslan/Movies/Jumper [2K] (2008).mp4"; # UHD (2160p x264 8-bit) (2014 - ~2018) # UHD and higher classes can take all night to process, so test them thoroughly first # -r 30 -b:v 16M -vf scale=3840:2160 -map 0:0 -map 0:2 -channel_layout '5.1' -ss: 00:03:00 -t: 00:00:45 # -c:v libx264 -sn -metadata title="" -metadata year="" -metadata class="UHD" #UHD4K (2160p x265 10-bit) (>= ~2018) # Most of these will be in 10-bit color x265 and will take even longer to process than plain UHDs. # Plus they have the highest probability of having cinavia. Test samples before full length processing highly recommended. # -c:v libx265 -r 30 -b:v 16M -vf scale=3840:2160 -map 0:0 -map 0:2 -channel_layout '5.1' -ss: 00:03:00 -t: 00:00:45 # -sn -metadata title="" -metadata year="" -metadata class="UHD4K10" #ffmpeg -i "/Volumes/Aslan 2/MoviesToBeProcessed/Beauty And The Beast [UHD4K10] (2017).mkv" -sn \ # -metadata title="Beauty And The Beast [UHD4K10] (2017)" -metadata year="2017" -metadata class="UHD4K10" \ # -r 30 -c:v libx265 -crf 17 -metadata crf="17" \ # -map 0:0 -map 0:3 -channel_layout '5.1' \ # -ss: 00:00:00 -t: 00:00:00 \ # "/Volumes/Aslan 2/MoviesToWatch/Beauty And The Beast [UHD4K10] (2017) test.mp4"; # CREATE AUDIO SAMPLE FOR CINAVIA CHECK from movies released after 2009 (yes, CinDe can detect cinavia with only audio) #ffmpeg -i "/Volumes/Aslan 2/MoviesToBeProcessed/47 Meters Down [HD2K] (2017).mkv" -sn -ss: 00:10:00 -t: 00:20:00 test1.mp3 && #ffmpeg -i "/Volumes/Aslan 2/MoviesToBeProcessed/Arrival [HD2K] (2016).mkv" -sn -ss: 00:10:00 -t: 00:20:00 test2.mp3 && #ffmpeg -i "/Volumes/Aslan 2/MoviesToBeProcessed/Beauty And The Beast [UHD4K10] (2017).mkv" -sn -ss: 00:10:00 -t: 00:20:00 test3.mp3; #ffmpeg -i "/Volumes/Aslan 2/MoviesToBeProcessed/Hacksaw Ridge [UHD4K10] (2016).mkv" -sn -ss: 00:10:00 -t: 00:20:00 test4.mp3 && # RIP DIRECTLY FROM DVD # https://www.makemkv.com/developers/usage.txt # makemkvcon mkv disc:0 all temp # ================================================================================================================= open .