Skip to content

Instantly share code, notes, and snippets.

@mfd
Last active August 2, 2021 10:07
Show Gist options
  • Select an option

  • Save mfd/d795c11aec7bca3bb6c10f91b9e01afa to your computer and use it in GitHub Desktop.

Select an option

Save mfd/d795c11aec7bca3bb6c10f91b9e01afa to your computer and use it in GitHub Desktop.

Revisions

  1. mfd revised this gist Aug 2, 2021. No changes.
  2. mfd revised this gist Aug 2, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions ffmpeg.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ## Scale to height 320
    ```
    ffmpeg -i input.mp4 -vf scale=-2:320 output.mp4
    ```

  3. mfd created this gist Mar 11, 2021.
    21 changes: 21 additions & 0 deletions video4web.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    # Generates a cover image along with mute web-ready WebM and MP4 files for each master video in a folder.
    # See: https://gist.github.com/jaydenseric/220c785d6289bcfd7366.

    # Parameter 1: Input video format (e.g. "mov").
    # Parameter 2: Output width in pixels (e.g. "1280").
    # Example use: "./video4web.sh mov 1280".

    mkdir web
    rm -rf web/*

    for i in *.$1
    do
    # Generate cover image
    ffmpeg -i $i -vframes 1 -vf scale=$2:-2 -q:v 1 web/${i%$1}jpg
    # Generate WebM
    ffmpeg -i $i -c:v libvpx -qmin 0 -qmax 25 -crf 4 -b:v 1M -vf scale=$2:-2 -an -threads 0 web/${i%$1}webm
    # Generate MP4
    ffmpeg -i $i -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -crf 22 -preset veryslow -vf scale=$2:-2 -an -movflags +faststart -threads 0 web/${i%$1}mp4
    done