-
-
Save rjmoggach/19df5848c6859a1f1084 to your computer and use it in GitHub Desktop.
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. Will probably convert this to a bash script later, but for the time being, here's some examples. Not sure there have actually sensible dimensions and bitrates for web video.
This file contains hidden or 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
#!/usr/bin/env bash | |
FULLFILE="$1" | |
FILENAME=$(basename "$FULLFILE" | cut -d. -f1) | |
# webm | |
for size in 640x360; do | |
ffmpeg -i $FULLFILE -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s ${size} ${FILENAME}-${size}.webm | |
done | |
# mp4 | |
for size in 480x270 640x360 960x540 1280x720; do | |
# ffmpeg -i $FULLFILE -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -preset slow -f mp4 -crf 22 -s ${size} ${FILENAME}-${size}.mp4 | |
ffmpeg -i $FULLFILE -vcodec libx264 -f mp4 -vb 1024k -preset slow -pix_fmt yuv420p -s ${size} ${FILENAME}-${size}.mp4 | |
done | |
# ogg (if you want to support older Firefox) | |
ffmpeg2theora ${FILENAME}-1280x720.mp4 -x 640 -y 360 --videoquality 5 --audioquality 5 --output ${FILENAME}-640x360.ogv |
This file contains hidden or 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
REM mp4 (H.264 / ACC) | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -f mp4 -vcodec libx264 -acodec aac -ac 2 -ab 128k -vb 1024k -preset slow -crf 22 -s 640x360 "\\%~p1%~n1-640x360.mp4" | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -f mp4 -vcodec libx264 -acodec aac -ac 2 -ab 128k -vb 1024k -preset slow -crf 22 -s 1280x720 "\\%~p1%~n1-1280x720.mp4" | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -f mp4 -vcodec libx264 -acodec aac -ac 2 -ab 128k -vb 1024k -preset slow -crf 22 -s 960x540 "\\%~p1%~n1-960x540.mp4" | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -f mp4 -vcodec libx264 -acodec aac -ac 2 -ab 128k -vb 1024k -preset slow -crf 22 -s 480x270 "\\%~p1%~n1-480x270.mp4" | |
REM webm (VP8 / Vorbis) | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -f webm -b 1500k -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -g 30 -s 640x360 "\\%~p1%~n1-640x360.webm" | |
REM ogv (Theora / Vorbis) | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 -s 640x360 "\\%~p1%~n1-640x360.ogv" | |
REM jpegs (screenshot every 24 frames) | |
"c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%1" -r 1 -qscale:v 2 "\\%~p1%~n1.%%02d.jpg" |
added windows batch script
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated for better compatibility with QuickTime player by adding
-pix_fmt yuv420p