Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A little shell script for converting two files to avi, mp4 & wmv while keeping the resolution intact. Uses FFMPEG. Due to multiple clients with different needs for a project, we needed a smooth way of doing shizzle.
#!/bin/bash
#
# A little shell script for converting two files to
# avi, mp4 & wmv while keeping the resolution intact.
# Uses FFMPEG.
#
# Create folder inside Converts
mkdir -p Converts/$3
# Give us target name without extension
filenameOne=$(basename "$1")
extension="${filenameOne##*.}"
filenameOne="${filenameOne%.*}"
# Convert file $1 to AVI, MP4 & WMV.
ffmpeg -i $1 -q:v 1 -vcodec mpeg4 -y Converts/$3/$filenameOne-avi-output.avi
ffmpeg -i $1 -b 16000k -qmin 3 Converts/$3/$filenameOne-wmv-output.wmv
ffmpeg -i $1 -b:v 10M -c:v libx264 -crf 1 -c:a aac -strict -2 -pix_fmt yuv420p Converts/$3/$filenameOne-mp4-output.mp4
# Give us target name without extension
filenameTwo=$(basename "$2")
extension="${filenameTwo##*.}"
filenameTwo="${filenameTwo%.*}"
# Convert file $2 to AVI, MP4 & WMV.
ffmpeg -i $2 -q:v 1 -vcodec mpeg4 -y Converts/$3/$filenameTwo-avi-output.avi
ffmpeg -i $2 -b 16000k -qmin 3 Converts/$3/$filenameTwo-wmv-output.wmv
ffmpeg -i $2 -b:v 10M -c:v libx264 -crf 1 -c:a aac -strict -2 -pix_fmt yuv420p Converts/$3/$filenameTwo-mp4-output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.