Skip to content

Instantly share code, notes, and snippets.

@599316527
Last active July 17, 2019 13:16
Show Gist options
  • Select an option

  • Save 599316527/425a6a8d8cdfde4e85aef1c577d89f19 to your computer and use it in GitHub Desktop.

Select an option

Save 599316527/425a6a8d8cdfde4e85aef1c577d89f19 to your computer and use it in GitHub Desktop.

Revisions

  1. 599316527 revised this gist Jul 17, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions convert.sh
    Original file line number Diff line number Diff line change
    @@ -7,5 +7,6 @@ fileSizeParam="-b:v 1.6M -maxrate 1.6M -bufsize 2m";

    echo "Convert: $1 -> $2";

    # Use two-pass to reduce size https://trac.ffmpeg.org/wiki/Encode/H.264
    /usr/local/bin/ffmpeg $ffmpegParam -i $1 $videoEncodeParam $audioEncodeParam $fileSizeParam -pass 1 -f mp4 /dev/null && \
    /usr/local/bin/ffmpeg $ffmpegParam -i $1 $videoEncodeParam $audioEncodeParam $fileSizeParam -pass 2 -f mp4 $2
  2. 599316527 created this gist Jul 17, 2019.
    11 changes: 11 additions & 0 deletions convert.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/zsh

    ffmpegParam="-hide_banner -y";
    videoEncodeParam="-c:v libx264 -crf 23 -profile:v main -level 3.1 -pix_fmt yuv420p -movflags +faststart -s 1024x768";
    audioEncodeParam="-an";
    fileSizeParam="-b:v 1.6M -maxrate 1.6M -bufsize 2m";

    echo "Convert: $1 -> $2";

    /usr/local/bin/ffmpeg $ffmpegParam -i $1 $videoEncodeParam $audioEncodeParam $fileSizeParam -pass 1 -f mp4 /dev/null && \
    /usr/local/bin/ffmpeg $ffmpegParam -i $1 $videoEncodeParam $audioEncodeParam $fileSizeParam -pass 2 -f mp4 $2