Skip to content

Instantly share code, notes, and snippets.

@sgwd
Forked from billmei/timelapse.md
Created April 4, 2019 01:37
Show Gist options
  • Save sgwd/158d85f51be0366b6f5a858e5e59f5e8 to your computer and use it in GitHub Desktop.
Save sgwd/158d85f51be0366b6f5a858e5e59f5e8 to your computer and use it in GitHub Desktop.

Revisions

  1. @billmei billmei revised this gist Jan 3, 2019. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,15 @@
    ### Convert sequence of GoPro Hero 6 Black JPEG images to MKV / MP4 video

    ```
    ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scale=3840:-2" -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow output.mkv
    ffmpeg \
    -r 30000/1001 \
    -pattern_type glob -i '*.JPG' \
    -vf "crop=in_w:in_w*9/16,scale=3840:-2" \
    -sws_flags lanczos \
    -pix_fmt yuv420p \
    -vcodec libx264 \
    -crf 18 -preset slow \
    output.mkv
    ```

    - `-r 30000/1001` - 30 fps frame rate. Why divide by 1001? See [drop-frame timecode](https://en.wikipedia.org/wiki/SMPTE_timecode#Drop-frame_timecode).
    @@ -17,4 +25,6 @@ ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scal

    This is not required as long as you use the `crop` option in `ffmpeg`, but is included for reference in case you want to crop the images with ImageMagick first before feeding them into `ffmpeg` (this is slower than using `ffmpeg` directly).

    `find . -name '*.JPG' -exec convert {} -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' "{}_cropped.jpg" \;`
    ```
    find . -name '*.JPG' -exec convert {} -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' "{}_cropped.jpg" \;
    ```
  2. @billmei billmei revised this gist Jan 3, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    ### Convert sequence of GoPro Hero 6 Black JPEG images to MKV / MP4 video

    `ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scale=3840:-2" -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow output.mkv`
    ```
    ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scale=3840:-2" -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow output.mkv
    ```

    - `-r 30000/1001` - 30 fps frame rate. Why divide by 1001? See [drop-frame timecode](https://en.wikipedia.org/wiki/SMPTE_timecode#Drop-frame_timecode).
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory. Note this is case sensitive.
  3. @billmei billmei revised this gist Jan 3, 2019. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,18 @@
    ### Convert sequence of GoPro Hero 6 Black JPEG images to MKV / MP4 video

    #### MKV is an open standard, so I prefer that to MP4, it does also seem to play back 4k 60 fps less choppy.

    `ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scale=3840:-2" -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow output.mkv`

    - `-r 30000/1001` - 30 fps frame rate. Why divide by 1001? See [drop-frame timecode](https://en.wikipedia.org/wiki/SMPTE_timecode#Drop-frame_timecode).
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory.
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory. Note this is case sensitive.
    - `-vf "crop=in_w:in_w*9/16,scale=3840:-2"` - 4k UHD. GoPro captures in 4000x3000, so need to crop it to 16:9 resolution. Change `3840` to `1920` if you want HD 1080p resolution.
    - `-sws_flags lanczos` - I want to scale Gaussian or lanczos, I think it’s better than bicubic.
    - `-pix_fmt yuv420p` - Seems everyone uses this because quicktime supports only that.
    - `-pix_fmt yuv420p` - Required to support Quicktime.
    - `-vcodec libx264` - everyone is using this codec - but why?
    - `-crf 18 -preset slow` - Add this for better quality output.
    - `output.mkv` - Output filename. Change to `.mp4` if you want MP4.

    ### Bulk convert JPGs to 1920x1080, centered

    This is not required as long as you use the `crop` option in `ffmpeg`, but is included for reference in case you want to crop the images with ImageMagick first before feeding them into `ffmpeg` (this is slower than using `ffmpeg` directly).

    `find . -name '*.JPG' -exec convert {} -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' "{}_cropped.jpg" \;`
  4. @billmei billmei revised this gist Jan 3, 2019. 1 changed file with 5 additions and 11 deletions.
    16 changes: 5 additions & 11 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,17 @@
    ### Convert sequence of GoPro Hero 5 Black JPEG images to MKV / MP4 video
    ### Convert sequence of GoPro Hero 6 Black JPEG images to MKV / MP4 video

    #### MKV is an open standard, so I prefer that to MP4, it does also seem to play back 4k 60 fps less choppy.

    `ffmpeg -r 60 -pattern_type glob -i '*.JPG' -vf scale=3840:2160 -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse_lanczos_crf18_slow.mkv`
    `ffmpeg -r 30000/1001 -pattern_type glob -i '*.JPG' -vf "crop=in_w:in_w*9/16,scale=3840:-2" -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow output.mkv`

    - `-r 60` - output frame rate.
    - `-r 30000/1001` - 30 fps frame rate. Why divide by 1001? See [drop-frame timecode](https://en.wikipedia.org/wiki/SMPTE_timecode#Drop-frame_timecode).
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory.
    - `-vf scale=3840:2160` - 4k UHD. GoPro captures in 4000x3000, but I want to squeeze it into 4k.
    - `-vf "crop=in_w:in_w*9/16,scale=3840:-2"` - 4k UHD. GoPro captures in 4000x3000, so need to crop it to 16:9 resolution. Change `3840` to `1920` if you want HD 1080p resolution.
    - `-sws_flags lanczos` - I want to scale Gaussian or lanczos, I think it’s better than bicubic.
    - `-pix_fmt yuv420p` - Seems everyone uses this because quicktime supports only that.
    - `-vcodec libx264` - everyone is using this codec - but why?
    - `-crf 18 -preset slow` - Add this for better quality output.

    This does give you a "deprecated pixel format" warning. It would be nice to figure out how to get rid of that, but it seems to work fine.

    #### MP4

    `ffmpeg -r 60 -pattern_type glob -i '*.JPG' -vf scale=1920:1080 -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse_lanczos_crf18_slow_1080.mp4`

    ### Bulk convert JPGs to 1920x1080, centered

    `convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg`
    `find . -name '*.JPG' -exec convert {} -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' "{}_cropped.jpg" \;`
  5. @Sybrand Sybrand revised this gist Nov 13, 2018. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ### Convert sequence of GoPro Hero 5 Black JPEG images to MKV video
    ### Convert sequence of GoPro Hero 5 Black JPEG images to MKV / MP4 video

    MKV is an open standard, so I prefer that to MP4. It does also seem to play back 4k 60 fps less choppy.
    #### MKV is an open standard, so I prefer that to MP4, it does also seem to play back 4k 60 fps less choppy.

    `ffmpeg -r 60 -pattern_type glob -i '*.JPG' -vf scale=3840:2160 -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse_lanczos_crf18_slow.mkv`

    @@ -14,6 +14,10 @@ MKV is an open standard, so I prefer that to MP4. It does also seem to play back

    This does give you a "deprecated pixel format" warning. It would be nice to figure out how to get rid of that, but it seems to work fine.

    #### MP4

    `ffmpeg -r 60 -pattern_type glob -i '*.JPG' -vf scale=1920:1080 -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse_lanczos_crf18_slow_1080.mp4`

    ### Bulk convert JPGs to 1920x1080, centered

    `convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg`
  6. @Sybrand Sybrand revised this gist Nov 9, 2018. No changes.
  7. @Sybrand Sybrand revised this gist Nov 9, 2018. 1 changed file with 11 additions and 11 deletions.
    22 changes: 11 additions & 11 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    ### Convert sequence of JPEG images to MP4 video
    ### Convert sequence of GoPro Hero 5 Black JPEG images to MKV video

    `ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4`
    MKV is an open standard, so I prefer that to MP4. It does also seem to play back 4k 60 fps less choppy.

    - `-r 24` - output frame rate
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory
    - `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    - `-s hd1080` - 1920x1080 resolution
    `ffmpeg -r 60 -pattern_type glob -i '*.JPG' -vf scale=3840:2160 -sws_flags lanczos -pix_fmt yuv420p -vcodec libx264 -crf 18 -preset slow timelapse_lanczos_crf18_slow.mkv`

    #### Slower, better quality

    Add the following after `-vcodec libx264` to achieve better quality output

    `-crf 18 -preset slow`
    - `-r 60` - output frame rate.
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory.
    - `-vf scale=3840:2160` - 4k UHD. GoPro captures in 4000x3000, but I want to squeeze it into 4k.
    - `-sws_flags lanczos` - I want to scale Gaussian or lanczos, I think it’s better than bicubic.
    - `-pix_fmt yuv420p` - Seems everyone uses this because quicktime supports only that.
    - `-vcodec libx264` - everyone is using this codec - but why?
    - `-crf 18 -preset slow` - Add this for better quality output.

    This does give you a "deprecated pixel format" warning. It would be nice to figure out how to get rid of that, but it seems to work fine.

    ### Bulk convert JPGs to 1920x1080, centered

  8. @porjo porjo revised this gist Nov 10, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    ### Convert sequence of JPEG images to MP4 video

    `ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4`
    `ffmpeg -r 24 -pattern_type glob -i '*.JPG' -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4`

    - `-r 24` - output frame rate
    - `-start_number 32` - if filenames don't start at 0000, then specify start number
    - `-pattern_type glob -i '*.JPG'` - all JPG files in the current directory
    - `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    - `-s hd1080` - 1920x1080 resolution

  9. @porjo porjo revised this gist Nov 7, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion timelapse.md
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,6 @@ Add the following after `-vcodec libx264` to achieve better quality output
    `-crf 18 -preset slow`


    ### Bulk JPGs to 1920x1080, centered
    ### Bulk convert JPGs to 1920x1080, centered

    `convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg`
  10. @porjo porjo revised this gist Nov 7, 2016. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion timelapse.md
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,9 @@

    Add the following after `-vcodec libx264` to achieve better quality output

    `-crf 18 -preset slow`
    `-crf 18 -preset slow`


    ### Bulk JPGs to 1920x1080, centered

    `convert input.jpg -resize '1920x1080^' -gravity center -crop '1920x1080+0+0' output.jpg`
  11. Ian Bishop revised this gist Dec 31, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -2,11 +2,13 @@

    `ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4`

    `-r 24` - output frame rate
    `-start_number 32` - if filenames don't start at 0000, then specify start number
    `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    `-s hd1080` - 1920x1080 resolution
    - `-r 24` - output frame rate
    - `-start_number 32` - if filenames don't start at 0000, then specify start number
    - `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    - `-s hd1080` - 1920x1080 resolution

    #### Slower, better quality

    Add the following after `-vcodec libx264` to achieve better quality output

    `-crf 18 -preset slow`
  12. Ian Bishop revised this gist Dec 31, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion timelapse.md
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,6 @@
    `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    `-s hd1080` - 1920x1080 resolution

    # Slower, better quality
    #### Slower, better quality

    `-crf 18 -preset slow`
  13. Ian Bishop revised this gist Dec 31, 2014. 2 changed files with 12 additions and 6 deletions.
    12 changes: 12 additions & 0 deletions timelapse.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ### Convert sequence of JPEG images to MP4 video

    `ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4`

    `-r 24` - output frame rate
    `-start_number 32` - if filenames don't start at 0000, then specify start number
    `-i DSC_%04d.JPG` - e.g. DSC_0397.JPG
    `-s hd1080` - 1920x1080 resolution

    # Slower, better quality

    `-crf 18 -preset slow`
    6 changes: 0 additions & 6 deletions timelapse.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

    # -r 24 - output frame rate
    # -start_number 32 - if filenames don't start at 0000, then specify start number
    # -i DSC_%04d.JPG - e.g. DSC_0397.JPG
    # -s hd1080 - 1920x1080 resolution
  14. Ian Bishop revised this gist Dec 31, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions timelapse.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

    # -r 24 - output frame rate
    # -start_number 32 - if filenames don't start at 0000, then specify start number
    # -i DSC_%04d.JPG - e.g. DSC_0397.JPG
    # -s hd1080 - 1920x1080 resolution
  15. Ian Bishop created this gist Dec 31, 2014.
    5 changes: 5 additions & 0 deletions timelapse.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ffmpeg -r 24 -start_number 32 -i DSC_%04d.JPG -s hd1080 -vcodec libx264 timelapse.mp4

    # -r 24 - output frame rate
    # -i DSC_%04d.JPG - e.g. DSC_0397.JPG
    # -s hd1080 - 1920x1080 resolution