Skip to content

Instantly share code, notes, and snippets.

@sww314
Created July 27, 2022 00:32
Show Gist options
  • Save sww314/de88f0ec4b0c3abe0720d9c542324e7d to your computer and use it in GitHub Desktop.
Save sww314/de88f0ec4b0c3abe0720d9c542324e7d to your computer and use it in GitHub Desktop.
Run ffmpeg from docker container to convert video file to mp4. Requires docker to be installed.
#! /bin/bash
set -e
if [ -z "$1" ]; then
echo "Uses ffmpeg in a docker container, to convert a video file to an mp4"
echo "Missing argument. "
echo "encode.sh <VIDEO_TO_ENCODE>"
echo "encode.sh movie.wmv"
exit 1
fi
if [ -z "$2" ]; then
VIDEO=video.mp4
THUMBNAIL=thumbnail.jpg
else
VIDEO=$2.mp4
THUMBNAIL=$2.jpg
fi
FFMPEG="docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg"
SOURCE_LINK=$1
# $FFMPEG -i $SOURCE_LINK -c copy -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -f ffmetadata meta.txt
echo "********* Creating thumbail -> $THUMBNAIL *****************"
echo
echo
$FFMPEG -y -i $SOURCE_LINK -vframes 1 -an -s 300x300 $THUMBNAIL
$FFMPEG -y -stats -i $SOURCE_LINK $VIDEO
echo
echo "********* Transcoding $SOURCE_LINK -> $VIDEO *****************"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment