Skip to content

Instantly share code, notes, and snippets.

@AbsoluteDestiny
Last active March 16, 2023 12:54
Show Gist options
  • Save AbsoluteDestiny/ac0551a32646d39b62d773b416737bfc to your computer and use it in GitHub Desktop.
Save AbsoluteDestiny/ac0551a32646d39b62d773b416737bfc to your computer and use it in GitHub Desktop.

Revisions

  1. AbsoluteDestiny revised this gist May 23, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 02. Quick Commands For Video-only Source.md
    Original 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 -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
    -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
  2. AbsoluteDestiny revised this gist Mar 17, 2018. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion 03. Clipping Commands.md
    Original 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
    `--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

    ```
  3. AbsoluteDestiny renamed this gist Feb 3, 2018. 1 changed file with 0 additions and 0 deletions.
  4. AbsoluteDestiny revised this gist Feb 3, 2018. 1 changed file with 34 additions and 0 deletions.
    34 changes: 34 additions & 0 deletions 05. Export for online sharing
    Original 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
    ```
  5. AbsoluteDestiny revised this gist Sep 17, 2017. 2 changed files with 5 additions and 5 deletions.
    8 changes: 4 additions & 4 deletions 02. Quick Commands For Video-only Source.md
    Original 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
    -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.mxf
    -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.mxf
    -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.mxf
    -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
    2 changes: 1 addition & 1 deletion 04. Source Conversion Guide.md
    Original 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`
    `-f mxf` or `outputFilename.mxf` or `-f mov` or `outputFilename.mov`

    ### Encoding UTVideo or MJpeg

  6. AbsoluteDestiny revised this gist Aug 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 04. Source Conversion Guide.md
    Original 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 higher numbers would be very good quality. The higher the number, the larger the file until you reach lossless.
    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

  7. AbsoluteDestiny revised this gist Aug 6, 2017. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion 03. Clipping Commands.md
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,13 @@
    ## Split file based on its keyframes

    ```
    -i input.mp4 -acodec copy -f segment -vcodec copy -reset_timestamps 1 -map 0 outputFile%d.mp4
    -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
    ```
  8. AbsoluteDestiny revised this gist Aug 6, 2017. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions 03. Clipping Commands.md
    Original file line number Diff line number Diff line change
    @@ -2,15 +2,16 @@

    ## 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

    ### Quick seeking (inaccurate, snaps to nearest keyframe):


    ```
    --ss 00:01:23.123 -i input.mkv -t 20 [... remaining commands]
    ```

    Accurate seeking
    ### Accurate seeking

    ```
    -i input.mkv --ss 00:01:23.123 -t 20 [... remaining commands]
  9. AbsoluteDestiny renamed this gist Aug 6, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  10. AbsoluteDestiny revised this gist Aug 6, 2017. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
  11. AbsoluteDestiny revised this gist Aug 6, 2017. 4 changed files with 23 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions 04. Clipping Commands
    Original 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
    ```
  12. AbsoluteDestiny revised this gist Aug 4, 2017. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion Quick Commands For Video-only Source.md
    Original file line number Diff line number Diff line change
    @@ -59,5 +59,5 @@ else
    ## MJpeg

    ```
    -i input.mkv -c:v mjpeg -qscale 1 -an outputFile.avi
    -i input.mkv -c:v mjpeg -q:v 1 -an outputFile.avi
    ```
    2 changes: 1 addition & 1 deletion Source Conversion Guide.md
    Original 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 -qscale 1
    -c:v mjpeg -q:v 1
    ```

    ## Audio Settings
  13. AbsoluteDestiny renamed this gist Aug 4, 2017. 1 changed file with 0 additions and 0 deletions.
  14. AbsoluteDestiny revised this gist Aug 4, 2017. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions Where to get FFmpeg.md
    Original 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/
  15. AbsoluteDestiny revised this gist Aug 3, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Quick Commands For Video-only Source.md
    Original 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 175M -an outputFile.mxf
    -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 175M -an outputFile.mxf
    -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
  16. AbsoluteDestiny revised this gist Aug 3, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions Quick Commands For Video-only Source.md
    Original 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 yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf
    -i input.mkv -pix_fmt yuv422p -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
    -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 yuv420p -c:v dnxhd -b:v 175M -an outputFile.mxf
    -i input.mkv -pix_fmt yuv422p -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
    -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
  17. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Source Conversion Guide.md
    Original 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 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 |
  18. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Quick Commands For Video-only Source.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    # Quick commands for encoding video-only source footage

    Change `input.mkv` and `outputFile` as needed for your file.
    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

  19. AbsoluteDestiny revised this gist Jul 31, 2017. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion Quick Commands For Video-only Source.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Quick video-only command lines
    # Quick commands for encoding video-only source footage

    Change `input.mkv` and `outputFile` as needed for your file.

    2 changes: 1 addition & 1 deletion Source Conversion Guide.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Source Conversion Guide
    # Detailed Source Conversion Guide

    ## Breakdown of an FFMpeg Command

  20. AbsoluteDestiny revised this gist Jul 31, 2017. No changes.
  21. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 6 additions and 9 deletions.
    15 changes: 6 additions & 9 deletions Quick Commands For Video-only Source.md
    Original 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 Ultra
    ## Prores HQ

    ```
    -i input.mkv -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 -an outputFile.mov
    -i input.mkv -pix_fmt yuv422p10le -c:v prores_ks -profile:v 3 -vendor ap10 -an outputFile.mov
    ```

    ## Prores HQ
    ## Prores Ultra (for VFX and keeping Alpha Channel)

    ```
    -i input.mkv -pix_fmt yuv422p10le -c:v prores_ks -profile:v 3 -vendor ap10 -an outputFile.mov
    -i input.mkv -pix_fmt yuv444p10 -c:v prores_ks -profile:v 4 -vendor ap10 -an outputFile.mov
    ```


    ## Prores DNxHD 1080p 23.976 or 24fps
    ## 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
    ```

    ## Prores DNxHD 720p 23.976 or 24fps
    ## DNxHD 720p 23.976 or 24fps

    If framesize matches
    ```
  22. AbsoluteDestiny revised this gist Jul 31, 2017. No changes.
  23. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions Source Conversion Guide.md
    Original 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:

    * `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.
    * `-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

  24. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Quick Commands For Video-only Source.md
    Original 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

    ```
  25. AbsoluteDestiny revised this gist Jul 31, 2017. 2 changed files with 63 additions and 64 deletions.
    62 changes: 62 additions & 0 deletions Quick Commands For Video-only Source.md
    Original 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
    ```
    65 changes: 1 addition & 64 deletions Source Conversion Guide.md
    Original 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`

    # 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
    ```
    `-f avi` or `outputFilename.avi`
  26. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions Source Conversion Guide.md
    Original 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 mx2` or `outputFilename.mx2`
    `-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.mx2
    -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.mx2
    -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.mx2
    -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.mx2
    -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
  27. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 133 additions and 10 deletions.
    143 changes: 133 additions & 10 deletions Source Conversion Guide.md
    Original 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:
    *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
    * `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:
    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. This is profile-based so will only allow certain resolution, fps and colorspace combinations.
    * `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 16 -preset faster -g 1
    -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

    ```
    -c:v prores_ks -profile:v 4 -pix_fmt yuv444p10
    -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
    -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
    -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
    -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
    ```
  28. AbsoluteDestiny revised this gist Jul 31, 2017. 1 changed file with 95 additions and 4 deletions.
    99 changes: 95 additions & 4 deletions Source Conversion Guide.md
    Original 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

    ### `Rsizing source video before encoding
    ### 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
    ```
    "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"
    -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

    ```
    #### Resize method
    ```

    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
    ```

    `-sws_flags spline`
    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
    ```
  29. AbsoluteDestiny revised this gist Jul 30, 2017. 1 changed file with 45 additions and 2 deletions.
    47 changes: 45 additions & 2 deletions Source Conversion Guide.md
    Original file line number Diff line number Diff line change
    @@ -3,5 +3,48 @@
    ## Breakdown of an FFMpeg Command

    ```
    ffmpeg -i inputfile.mkv
    ```
    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`


  30. AbsoluteDestiny created this gist Jul 30, 2017.
    7 changes: 7 additions & 0 deletions Source Conversion Guide.md
    Original 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
    ```