Skip to content

Instantly share code, notes, and snippets.

@radum
Forked from mfd/ffmpeg.md
Created May 13, 2021 08:24
Show Gist options
  • Save radum/3945347a198bbba0dfadf7442c01d812 to your computer and use it in GitHub Desktop.
Save radum/3945347a198bbba0dfadf7442c01d812 to your computer and use it in GitHub Desktop.
video4web
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment