Last active
March 16, 2023 12:54
-
-
Save AbsoluteDestiny/ac0551a32646d39b62d773b416737bfc to your computer and use it in GitHub Desktop.
Revisions
-
AbsoluteDestiny revised this gist
May 23, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,7 @@ If framesize matches ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 90M -an outputFile.mov ``` ## UTVideo -
AbsoluteDestiny revised this gist
Mar 17, 2018 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,21 +2,32 @@ ## Convert only a part of the file `--ss` is the start time and `-t` is the duration of the clip. Alternatively you can use `-to` to set the end timestamp of the clip. ### Quick seeking (inaccurate, snaps to nearest keyframe): ``` --ss 00:01:23.123 -i input.mkv -t 20 [... remaining commands] ``` or ``` --ss 00:01:23.123 -i input.mkv -to 00:01:43.123 [... remaining commands] ``` ### Accurate seeking ``` -i input.mkv --ss 00:01:23.123 -t 20 [... remaining commands] ``` or ``` -i input.mkv --ss 00:01:23.123 -to 00:01:43.123 [... remaining commands] ``` ## Split file based on its keyframes ``` -
AbsoluteDestiny renamed this gist
Feb 3, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AbsoluteDestiny revised this gist
Feb 3, 2018 . 1 changed file with 34 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ # FFMpeg Encoding for online sharing # Making h264 mp4 files ## Basic no-brainer encoding options The -crf 18 option here is very high quality. 20 would be lower quality. The default is actually 23. You can also use fractional amounts e.g. 18.5 ``` ffmpeg -i inputfile.avi -pix_fmp yuv420p -c:v libx264 -crf 18 -preset slower -c:a aac -b:a 224k -movflags +faststart output.mp4 ``` This is where I usually start, though for 1080p encodes this often creates a file that's way too big so I then reduce the number and find the sweet spot where it's not too large and not too bad-looking. ## High quality but with some bitrate limits It's possible you may have a target device (like, I dunno, some streaming box) that chokes on high birtates you can set rate limits in addition to keeping your -crf value. ``` ffmpeg -i inputfile.avi -pix_fmp yuv420p -c:v libx264 -crf 18 -maxrate 7M -bufsize 10M -preset slower -c:a aac -b:a 224k -movflags +faststart output.mp4 ``` ## Adding Metadata (Title, Author, etc) ``` ffmpeg [settings above except output.mp4] -metadata title="Video Title" -metadata author="Author Name" output.mp4 ``` # Webm (using VP9) ``` ffmpeg -i inputfile.avi -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 224k output.webm ``` -
AbsoluteDestiny revised this gist
Sep 17, 2017 . 2 changed files with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,22 +31,22 @@ Also, be sure to change `input.mkv` and `outputFile` as needed for your file. If framesize matches ``` -i input.mkv -pix_fmt yuv422p -c:v dnxhd -b:v 175M -an outputFile.mov ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mov ``` ## DNxHD 720p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv422p -c:v dnxhd -b:v 90M -an outputFile.mov ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 90M -an outputFile.mov ``` ## UTVideo 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 charactersOriginal file line number Diff line number Diff line change @@ -194,7 +194,7 @@ You can determine a container format either by specifying it on the commandline ### Encoding DXnHD `-f mxf` or `outputFilename.mxf` or `-f mov` or `outputFilename.mov` ### Encoding UTVideo or MJpeg -
AbsoluteDestiny revised this gist
Aug 10, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,7 @@ or, if you don't care about the file size that much and would rather it encode q -c:v libx264 -crf 14 -preset faster -g 1 ``` 16 is medium quality but lower numbers would be very good quality. The lower the number, the larger the file until you reach lossless. ### ProRes -
AbsoluteDestiny revised this gist
Aug 6, 2017 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,13 @@ ## Split file based on its keyframes ``` -i input.mp4 -f segment -c:v copy -c:a copy -reset_timestamps 1 -map 0 outputFile%d.mp4 ``` ## Split file into time-based segments Example below splits into 5 minute chunks ``` -i input.mp4 -f segment -segment_time 0:05:00 -c:v copy -c:a copy -reset_timestamps 1 -map 0 outputFile%d.mp4 ``` -
AbsoluteDestiny revised this gist
Aug 6, 2017 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,15 +2,16 @@ ## Convert only a part of the file `--ss` is the start time and `-t` is the duration of the clip ### Quick seeking (inaccurate, snaps to nearest keyframe): ``` --ss 00:01:23.123 -i input.mkv -t 20 [... remaining commands] ``` ### Accurate seeking ``` -i input.mkv --ss 00:01:23.123 -t 20 [... remaining commands] -
AbsoluteDestiny renamed this gist
Aug 6, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AbsoluteDestiny revised this gist
Aug 6, 2017 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
AbsoluteDestiny revised this gist
Aug 6, 2017 . 4 changed files with 23 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ # FFMpeg Clipping Commands ## Convert only a part of the file Quick seeking (inaccurate, snaps to nearest keyframe): `--ss` is the start time and `-t` is the duration of the clip ``` --ss 00:01:23.123 -i input.mkv -t 20 [... remaining commands] ``` Accurate seeking ``` -i input.mkv --ss 00:01:23.123 -t 20 [... remaining commands] ``` ## Split file based on its keyframes ``` -i input.mp4 -acodec copy -f segment -vcodec copy -reset_timestamps 1 -map 0 outputFile%d.mp4 ``` -
AbsoluteDestiny revised this gist
Aug 4, 2017 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -59,5 +59,5 @@ else ## MJpeg ``` -i input.mkv -c:v mjpeg -q:v 1 -an outputFile.avi ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -158,7 +158,7 @@ UTVideo, being lossless, can generally handle any input format, so the command i Where qscale is the quantizer to use, 1 being the highest. Still not great quality. For shitty proxy files you can drop qscale to 4 or lower to make small but ugly and fast files. ``` -c:v mjpeg -q:v 1 ``` ## Audio Settings -
AbsoluteDestiny renamed this gist
Aug 4, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AbsoluteDestiny revised this gist
Aug 4, 2017 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ # Where to get FFMpeg ## Windows https://ffmpeg.zeranoe.com/builds/ ## OSX https://evermeet.cx/ffmpeg/ ## Linux https://www.johnvansickle.com/ffmpeg/ -
AbsoluteDestiny revised this gist
Aug 3, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,11 +42,11 @@ else If framesize matches ``` -i input.mkv -pix_fmt yuv422p -c:v dnxhd -b:v 90M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 90M -an outputFile.mxf ``` ## UTVideo -
AbsoluteDestiny revised this gist
Aug 3, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,22 +31,22 @@ Also, be sure to change `input.mkv` and `outputFile` as needed for your file. If framesize matches ``` -i input.mkv -pix_fmt yuv422p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## DNxHD 720p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv422p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv422p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## UTVideo -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -128,7 +128,7 @@ First look up the bitrate you need to set on this table based on the framesize, | 1080p / 24 | DNxHD 175 | 1920 x 1080 | 8 | 24 | 175M | | 1080p / 24 | DNxHD 115 | 1920 x 1080 | 8 | 24 | 115M | | 1080p / 24 | DNxHD 36 | 1920 x 1080 | 8 | 24 | 36M | | **1080p / 23.976** | DNxHD 175 | 1920 x 1080 | 8 | 23.976 | **175M** | | 1080p / 23.976 | DNxHD 115 | 1920 x 1080 | 8 | 23.976 | 115M | | 1080p / 23.976 | DNxHD 36 | 1920 x 1080 | 8 | 23.976 | 36M | | 1080p / 29.7 | DNxHD 45 | 1920 x 1080 | 8 | 29.97 | 45M | -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ # Quick commands for encoding video-only source footage All commands need to start with the path to your copy of `ffmpeg`. E.g. on windows `d:\ffmpegfolder\ffmpeg.exe [command below]` Also, be sure to change `input.mkv` and `outputFile` as needed for your file. ## Lossless h264 -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Quick commands for encoding video-only source footage Change `input.mkv` and `outputFile` as needed for your file. 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Detailed Source Conversion Guide ## Breakdown of an FFMpeg Command -
AbsoluteDestiny revised this gist
Jul 31, 2017 . No changes.There are no files selected for viewing
-
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 6 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,22 +13,19 @@ Change `input.mkv` and `outputFile` as needed for your file. ``` -i input.mkv -pix_fmt yuv420p -c:v libx264 -crf 14 -g 1 -preset faster -an outputFile.mp4 ``` ## Prores HQ ``` -i input.mkv -pix_fmt yuv422p10le -c:v prores_ks -profile:v 3 -vendor ap10 -an outputFile.mov ``` ## Prores Ultra (for VFX and keeping Alpha Channel) ``` -i input.mkv -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 -an outputFile.mov ``` ## DNxHD 1080p 23.976 or 24fps If framesize matches ``` @@ -39,7 +36,7 @@ else -i input.mkv -pix_fmt yuv420p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## DNxHD 720p 23.976 or 24fps If framesize matches ``` -
AbsoluteDestiny revised this gist
Jul 31, 2017 . No changes.There are no files selected for viewing
-
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,10 @@ ffmpeg -i inputfile1.mkv [Source Settings] [Video Settings] [Audio Settings] [Co *Not usually required* - ffmpeg will often choose the correct option for the codec(s) involed but some encoders can support multiple colorspaces so you sometimes need to be specific. Here are some common ones: * `-pix_fmt yuv420p` - same as DVD and BLu-ray footage. Common in most compressed streaming media. Use this for encoding for the web * `-pix_fmt yuv422p` - More chroma samples, used for common intermediate and editing codecs * `-pix_fmt yuv444p` - 'Lossless' colorspace used for high quality editing codec profiles when using raw footage. * `-pix_fmt yuv444p10` - as above but using 10bits for the luma channel instead of 8. Better for VFX work - smoother gradients etc. ### Resizing source video before encoding -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Quick video-only command lines Change `input.mkv` and `outputFile` as needed for your file. ## Lossless h264 ``` -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 2 changed files with 63 additions and 64 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ # Quick video-only command lines ## Lossless h264 ``` -i input.mkv -pix_fmt yuv420p -c:v libx264 -crf 0 -g 1 -an outputFile.mp4 ``` ## Lossy good-enough h264 ``` -i input.mkv -pix_fmt yuv420p -c:v libx264 -crf 14 -g 1 -preset faster -an outputFile.mp4 ``` ## Prores Ultra ``` -i input.mkv -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 -an outputFile.mov ``` ## Prores HQ ``` -i input.mkv -pix_fmt yuv422p10le -c:v prores_ks -profile:v 3 -vendor ap10 -an outputFile.mov ``` ## Prores DNxHD 1080p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## Prores DNxHD 720p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## UTVideo ``` -i input.mkv -c:v utvideo -an outputFile.avi ``` ## MJpeg ``` -i input.mkv -c:v mjpeg -qscale 1 -an outputFile.avi ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -198,67 +198,4 @@ You can determine a container format either by specifying it on the commandline ### Encoding UTVideo or MJpeg `-f avi` or `outputFilename.avi` -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -194,7 +194,7 @@ You can determine a container format either by specifying it on the commandline ### Encoding DXnHD `-f mxf` or `outputFilename.mxf` ### Encoding UTVideo or MJpeg @@ -232,22 +232,22 @@ You can determine a container format either by specifying it on the commandline If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## Prores DNxHD 720p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mxf ``` ## UTVideo -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 133 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,12 @@ ffmpeg -i inputfile1.mkv [Source Settings] [Video Settings] [Audio Settings] [Co ### `-pix_fmt` - forces the colorspace you wish to work in *Not usually required* - ffmpeg will often choose the correct option for the codec(s) involed but some encoders can support multiple colorspaces so you sometimes need to be specific. Here are some common ones: * `yuv420p` - same as DVD and BLu-ray footage. Common in most compressed streaming media. Use this for encoding for the web * `yuv422p` - More chroma samples, used for common intermediate and editing codecs * `yuv444p` - 'Lossless' colorspace used for high quality editing codec profiles when using raw footage. * `yuv444p10` - as above but using 10bits for the luma channel instead of 8. Better for VFX work - smoother gradients etc. ### Resizing source video before encoding @@ -36,7 +37,7 @@ Scale to a particular height, auto-calculate the appropriate width: -vf scale=-1:1080 ``` Scale to fit into a 1920x1080 frame and *add borders* if needed (useful for DXnHD etc): ``` -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" @@ -55,16 +56,18 @@ Here is a summary of the most important codecs for conversion: * `libx264` - The open-source encoder for h264 encoding (mpeg4), usually for web distribution but also can be set as a high quality lossy intermediate codec for editing on some systems. * `prores` and `prores_ks` - ffmpeg's implementation of Apple's ProRes codec. Fairly industry standard for Final Cut usage - works in all pro editing systems. Main downside is the ffmpeg implementation is slow as an encoder so processing source may take longer than other options. * `dxnhd` - Avid's editing codec. Just as well supported as ProRes and encodes faster with ffmpeg, which is a plus. However, this is profile-based so will only allow certain resolution, fps and colorspace combinations. If you source isn't exactly 720p or 1080p or what have you you will need to add borders to be able to convert using this codec. * `utvideo` - Lossless codec, excellent quality but only really supported by Windows version of video editors. Can be sometimes slow to read making quick editing trickier but the compressed size is fairly similar to high quality lossy codecs! * `mjpeg` - low quality traditional format that reads and writes really fast so good as a proxy source for video editors that allow low-quality proxies to be used. ### h264 The main aspects here are `-crf` which controlls quality (0 being lossless and 22 being the default). `-g` controls GOP length so setting this to 1 makes every frame a keyframe which is ideal for editing. Lossless h264 ``` -c:v libx264 -crf 0 -g 1 ``` Lossy encoding with every frame a keyframe @@ -76,35 +79,37 @@ Lossy encoding with every frame a keyframe or, if you don't care about the file size that much and would rather it encode quicker: ``` -c:v libx264 -crf 14 -preset faster -g 1 ``` 16 is medium quality but higher numbers would be very good quality. The higher the number, the larger the file until you reach lossless. ### ProRes Note the `-vendor ap10` part below is only needed if working with Final Cut, but it does no harm otherwise. High Quality 4444 - usually overkill unless doing VFX work ``` -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 ``` High Quality 422 (84 Mbit/s) - use this one ``` -c:v prores_ks -profile:v 3 -vendor ap10 ``` Standard Quality 422 - or this if you are low on space and need something 'good enough' ``` -c:v prores_ks -profile:v 2 -vendor ap10 ``` Proxy Quality - For proxy files only, looks crappy but edits fast and is small ``` -c:v prores_ks -profile:v 0 -vendor ap10 ``` ### DNxHD @@ -138,4 +143,122 @@ Then add the bitrate to this command (using 1080p 24fps as an example): ``` -c:v dnxhd -b:v 175M ``` ### UTVideo UTVideo, being lossless, can generally handle any input format, so the command is simply: ``` -c:v utvideo ``` ### MJpeg Where qscale is the quantizer to use, 1 being the highest. Still not great quality. For shitty proxy files you can drop qscale to 4 or lower to make small but ugly and fast files. ``` -c:v mjpeg -qscale 1 ``` ## Audio Settings ### Stripping Audio Simply add this shorthand ``` -an ``` ### AAC (for mp4 video files) Stereo Bitrates: 128k, 160k, 192k, 224k, 320k 224 is what iTunes uses if that gives any idea ``` -c:a aac -b 224k ``` ## Container Settings and Extension You can determine a container format either by specifying it on the commandline with `-f` otherwise ffmpeg will use the filename to determine the container: ### Encoding h264 `-f mp4` or simply `outputFilname.mp4` ### Encoding ProRes `-f mov` or `outputFilename.mov` ### Encoding DXnHD `-f mx2` or `outputFilename.mx2` ### Encoding UTVideo or MJpeg `-f avi` or `outputFilename.avi` # Quick video-only command lines ## Lossless h264 ``` -i input.mkv -pix_fmt yuv420p -c:v libx264 -crf 0 -g 1 -an outputFile.mp4 ``` ## Lossy good-enough h264 ``` -i input.mkv -pix_fmt yuv420p -c:v libx264 -crf 14 -g 1 -preset faster -an outputFile.mp4 ``` ## Prores Ultra ``` -i input.mkv -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 -an outputFile.mov ``` ## Prores HQ ``` -i input.mkv -pix_fmt yuv422p10le -c:v prores_ks -profile:v 3 -vendor ap10 -an outputFile.mov ``` ## Prores DNxHD 1080p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mx2 ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mx2 ``` ## Prores DNxHD 720p 23.976 or 24fps If framesize matches ``` -i input.mkv -pix_fmt yuv420p -c:v dnxhd -b:v 175M -an outputFile.mx2 ``` else ``` -i input.mkv -pix_fmt yuv420p -filter:v -filter:v "scale=(sar*iw)*min(1280/(sar*iw)\,720/ih):ih*min(1280/(sar*iw)\,720/ih), pad=1280:720:(1280-(sar*iw)*min(1280/(sar*iw)\,720/ih))/2:(720-ih*min(1280/(sar*iw)\,720/ih))/2" -c:v dnxhd -b:v 175M -an outputFile.mx2 ``` ## UTVideo ``` -i input.mkv -c:v utvideo -an outputFile.avi ``` ## MJpeg ``` -i input.mkv -c:v mjpeg -qscale 1 -an outputFile.avi ``` -
AbsoluteDestiny revised this gist
Jul 31, 2017 . 1 changed file with 95 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,11 @@ Not usually required - ffmpeg will often choose the correct option for the codec * `yuv422p` - More chroma samples, used for common intermediate and editing codecs * `yuv444p` - 'Lossless' colorspace used for high quality editing codec profiles, especial in VFX work ### Resizing source video before encoding Before scaling, set the rsize algorithm: `-sws_flags spline` or `-sws_flags lanczos` will do. Then, resize either with the scale video filter: `-filter:v scale` Examples: @@ -40,11 +44,98 @@ Scale to fit into a 1920x1080 frame and add borders if needed: Generic pattern, for any size - just replace XXXX with the width and YYYY with the Y ``` -filter:v "scale=(sar*iw)*min(XXXX/(sar*iw)\,YYYY/ih):ih*min(XXXX/(sar*iw)\,YYYY/ih), pad=XXXX:YYYY:(XXXX-(sar*iw)*min(XXXX/(sar*iw)\,YYYY/ih))/2:(YYYY-ih*min(XXXX/(sar*iw)\,YYYY/ih))/2" ``` ## Video Settings Choosing a video codec in ffmpeg generally uses the format `-c:v` followed by the codec Here is a summary of the most important codecs for conversion: * `libx264` - The open-source encoder for h264 encoding (mpeg4), usually for web distribution but also can be set as a high quality lossy intermediate codec for editing on some systems. * `prores` and `prores_ks` - ffmpeg's implementation of Apple's ProRes codec. Fairly industry standard for Final Cut usage - works in all pro editing systems. Main downside is the ffmpeg implementation is slow as an encoder so processing source may take longer than other options. * `dxnhd` - Avid's editing codec. This is profile-based so will only allow certain resolution, fps and colorspace combinations. * `utvideo` - Lossless codec, excellent quality but only really supported by Windows version of video editors. Can be sometimes slow to read making quick editing trickier but the compressed size is fairly similar to high quality lossy codecs! * `mjpeg` - low quality traditional format that reads and writes really fast so good as a proxy source for video editors that allow low-quality proxies to be used. ### h264 Lossless h264 ``` ``` Lossy encoding with every frame a keyframe ``` -c:v libx264 -crf 16 -g 1 ``` or, if you don't care about the file size that much and would rather it encode quicker: ``` -c:v libx264 -crf 16 -preset faster -g 1 ``` 16 is medium quality but higher numbers would be very good quality. The higher the number, the larger the file until you reach lossless. ### ProRes High Quality 4444 - usually overkill unless doing VFX work ``` -c:v prores_ks -profile:v 4 -pix_fmt yuv444p10 ``` High Quality 422 (84 Mbit/s) - use this one ``` -c:v prores_ks -profile:v 3 ``` Standard Quality 422 - or this if you are low on space and need something 'good enough' ``` -c:v prores_ks -profile:v 2 ``` Proxy Quality - For proxy files only, looks crappy but edits fast and is small ``` -c:v prores_ks -profile:v 0 ``` ### DNxHD First look up the bitrate you need to set on this table based on the framesize, fps and desired quality level. For each there is a standard and a high quality version. The high quality version is preferred: | Project Format | Resolution | Frame Size | Bits | FPS | <bitrate> | |----------------|------------|-------------|------|--------|-----------| | 1080i / 59.94 | DNxHD 220 | 1920 x 1080 | 8 | 29.97 | 220M | | 1080i / 59.94 | DNxHD 145 | 1920 x 1080 | 8 | 29.97 | 145M | | 1080i / 50 | DNxHD 185 | 1920 x 1080 | 8 | 25 | 185M | | 1080i / 50 | DNxHD 120 | 1920 x 1080 | 8 | 25 | 120M | | 1080p / 25 | DNxHD 185 | 1920 x 1080 | 8 | 25 | 185M | | 1080p / 25 | DNxHD 120 | 1920 x 1080 | 8 | 25 | 120M | | 1080p / 25 | DNxHD 36 | 1920 x 1080 | 8 | 25 | 36M | | 1080p / 24 | DNxHD 175 | 1920 x 1080 | 8 | 24 | 175M | | 1080p / 24 | DNxHD 115 | 1920 x 1080 | 8 | 24 | 115M | | 1080p / 24 | DNxHD 36 | 1920 x 1080 | 8 | 24 | 36M | | 1080p / 23.976 | DNxHD 175 | 1920 x 1080 | 8 | 23.976 | 175M | | 1080p / 23.976 | DNxHD 115 | 1920 x 1080 | 8 | 23.976 | 115M | | 1080p / 23.976 | DNxHD 36 | 1920 x 1080 | 8 | 23.976 | 36M | | 1080p / 29.7 | DNxHD 45 | 1920 x 1080 | 8 | 29.97 | 45M | | 720p / 59.94 | DNxHD 220 | 1280x720 | 8 | 59.94 | 220M | | 720p / 59.94 | DNxHD 145 | 1280x720 | 8 | 59.94 | 145M | | 720p / 50 | DNxHD 175 | 1280x720 | 8 | 50 | 175M | | 720p / 50 | DNxHD 115 | 1280x720 | 8 | 50 | 115M | | 720p / 23.976 | DNxHD 90 | 1280x720 | 8 | 23.976 | 90M | | 720p / 23.976 | DNxHD 60 | 1280x720 | 8 | 23.976 | 60M | Then add the bitrate to this command (using 1080p 24fps as an example): ``` -c:v dnxhd -b:v 175M ``` -
AbsoluteDestiny revised this gist
Jul 30, 2017 . 1 changed file with 45 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,5 +3,48 @@ ## Breakdown of an FFMpeg Command ``` ffmpeg -i inputfile1.mkv [Source Settings] [Video Settings] [Audio Settings] [Container Settings] output.ext ``` ## Source Settings ### `-pix_fmt` - forces the colorspace you wish to work in Not usually required - ffmpeg will often choose the correct option for the codec(s) involed but some encoders can support multiple colorspaces so you sometimes need to be specific. Here are some common ones: * `yuv420p` - same as DVD and BLu-ray footage. Common in most compressed streaming media. Use this for encoding for the web * `yuv422p` - More chroma samples, used for common intermediate and editing codecs * `yuv444p` - 'Lossless' colorspace used for high quality editing codec profiles, especial in VFX work ### `Rsizing source video before encoding Examples: Scale to a particular width, auto-calculate the appropriate height: ``` -vf scale=1280:-1 ``` Scale to a particular height, auto-calculate the appropriate width: ``` -vf scale=-1:1080 ``` Scale to fit into a 1920x1080 frame and add borders if needed: ``` -filter:v "scale=(sar*iw)*min(1920/(sar*iw)\,1080/ih):ih*min(1920/(sar*iw)\,1080/ih), pad=1920:1080:(1920-(sar*iw)*min(1920/(sar*iw)\,1080/ih))/2:(1080-ih*min(1920/(sar*iw)\,1080/ih))/2" ``` Generic pattern, for any size - just replace XXXX with the width and YYYY with the Y ``` "scale=(sar*iw)*min(XXXX/(sar*iw)\,YYYY/ih):ih*min(XXXX/(sar*iw)\,YYYY/ih), pad=XXXX:YYYY:(XXXX-(sar*iw)*min(XXXX/(sar*iw)\,YYYY/ih))/2:(YYYY-ih*min(XXXX/(sar*iw)\,YYYY/ih))/2" ``` #### Resize method `-sws_flags spline` -
AbsoluteDestiny created this gist
Jul 30, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ # Source Conversion Guide ## Breakdown of an FFMpeg Command ``` ffmpeg -i inputfile.mkv ```