Skip to content

Instantly share code, notes, and snippets.

@cupofjoakim
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cupofjoakim/8cf2bd80b553e6b12e40 to your computer and use it in GitHub Desktop.
Save cupofjoakim/8cf2bd80b553e6b12e40 to your computer and use it in GitHub Desktop.
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