Skip to content

Instantly share code, notes, and snippets.

@eviltester
Last active September 28, 2023 15:12
Show Gist options
  • Select an option

  • Save eviltester/7beef92896fdd8b638656f996fac38c0 to your computer and use it in GitHub Desktop.

Select an option

Save eviltester/7beef92896fdd8b638656f996fac38c0 to your computer and use it in GitHub Desktop.

Revisions

  1. eviltester revised this gist Sep 15, 2018. 1 changed file with 25 additions and 1 deletion.
    26 changes: 25 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,28 @@ And that gave me the following 'split' ffmpeg commands. Remember the second time
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:00:00 -t 00:09:29 igt-podcast-006-part1.mp4
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:09:29 -t 00:06:28 igt-podcast-006-part2.mp4
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:15:57 -t 00:10:00 igt-podcast-006-part3.mp4
    ~~~~~~~~
    ~~~~~~~~

    # Add an image after the video

    I want to add an image for 5 seconds, or however long, after the main mp4.

    To do that, I creat an mp4 which is just the image and I concatenate it to the main file.

    ~~~~~~~~
    ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -loop 1 -i image.png -pix_fmt yuv420p -t 5 -vf scale=1920:1080 promo-image-w-audio.mp4
    ~~~~~~~~

    Important points for the above are:

    - I'm scaling the image as I create the video, so that the output file has the same resolution as the one I want to append it to.
    - `-vf scale=1920:1080`
    - I add a silent audio layer to allow the concatenation to work
    - `-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100

    Then I need to concatenate the videos together:

    ~~~~~~~~
    ffmpeg -i video.mp4 -i promo-image-w-audio.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4
    ~~~~~~~~

  2. eviltester revised this gist Sep 14, 2018. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -40,4 +40,18 @@ The command below uses a headerimage.png which is 720x426

    ~~~~~~~~
    ffmpeg -i instagram-subs.mp4 -i headerimage.png -filter_complex "scale=w=720:h=1280:force_original_aspect_ratio=1,pad=720:1280:(ow-iw)/2:426,overlay" instagram-subs-igt.mp4
    ~~~~~~~~

    I looked through the video to identify the spots I wanted to split the video:

    - 00- 09:29 - intro and examples
    - 09:29 - 15:56 process workarounds
    - 15:58 - 20:45 (end) testing, automating and mindset

    And that gave me the following 'split' ffmpeg commands. Remember the second time is a duration i.e. start at 00:00 for duraton 09:29

    ~~~~~~~~
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:00:00 -t 00:09:29 igt-podcast-006-part1.mp4
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:09:29 -t 00:06:28 igt-podcast-006-part2.mp4
    ffmpeg -i instagram-subs-igt.mp4 -ss 00:15:57 -t 00:10:00 igt-podcast-006-part3.mp4
    ~~~~~~~~
  3. eviltester revised this gist Sep 14, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,12 @@ ffmpeg -i instagram-subs.mp4 -ss 00:01:05 -t 00:00:52 instagram-01-05.mp4
    ffmpeg -i subtitled-video.mp4 -ss 00:01:05 -t 00:00:52 subtitled-01-05.mp4
    ~~~~~~~~

    Repeat as necessary using different videos and different sections
    Repeat as necessary using different videos and different sections

    # To format for IGTV

    The command below uses a headerimage.png which is 720x426

    ~~~~~~~~
    ffmpeg -i instagram-subs.mp4 -i headerimage.png -filter_complex "scale=w=720:h=1280:force_original_aspect_ratio=1,pad=720:1280:(ow-iw)/2:426,overlay" instagram-subs-igt.mp4
    ~~~~~~~~
  4. eviltester created this gist Sep 9, 2018.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Create a new caption file

    ~~~~~~~~
    ffmpeg -i captions.srt captions.ass
    ~~~~~~~~

    # Add subtitles to main video without changing it

    ~~~~~~~~
    ffmpeg -i video.mp4 -vf "subtitles=captions.ass:force_style='OutlineColour=&H80000000,BorderStyle=4,Outline=1,Shadow=0,MarginV=20'" subtitled-video.mp4
    ~~~~~~~~

    # Change size of video to support Instagram

    ~~~~~~~~
    ffmpeg -i video.mp4 -vf scale=720:720:force_original_aspect_ratio=decrease,pad=720:720 instagram-sized.mp4
    ~~~~~~~~

    # Add subtitles to the instagram video

    ~~~~~~~~
    ffmpeg -i instagram-sized.mp4 -vf "subtitles=captions.ass:force_style='OutlineColour=&H80000000,BorderStyle=4,Outline=1,Shadow=0,MarginV=90'" instagram-subs.mp4
    ~~~~~~~~

    # Split the Instagram Subtitled video into 3 new videos

    ~~~~~~~~
    ffmpeg -i instagram-subs.mp4 -ss 00:01:05 -t 00:00:52 instagram-01-05.mp4
    ~~~~~~~~

    ~~~~~~~~
    ffmpeg -i subtitled-video.mp4 -ss 00:01:05 -t 00:00:52 subtitled-01-05.mp4
    ~~~~~~~~

    Repeat as necessary using different videos and different sections