ffmpeg -i input.mp4 -vf scale=-2:320 output.mp4
Last active
August 2, 2021 10:07
-
-
Save mfd/d795c11aec7bca3bb6c10f91b9e01afa to your computer and use it in GitHub Desktop.
video4web ffmpeg mp4 webvideo web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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