Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple script for encoding files for use with Akamai HD and generating a SMIL file
#!/bin/bash
VIDSOURCE=$1
OUTNAME=$2
RESOLUTION1="320x180"
RESOLUTION2="512x288"
RESOLUTION3="640x360"
RESOLUTION4="960x540"
RESOLUTION5="1024x576"
RESOLUTION6="1280x720"
RESOLUTION7="1920x1080"
BITRATE1="400000"
BITRATE2="800000"
BITRATE3="1000000"
BITRATE4="1200000"
BITRATE5="1400000"
BITRATE6="2000000"
BITRATE7="4000000"
echo "Encoding $VIDSOURCE"
AUDIO_OPTS="-c:a libfaac -b:a 160000 -ac 2"
AUDIO_OPTS2="-c:a libfaac -b:a 640000 -ac 2"
VIDEO_OPTS1="-c:v libx264 -vprofile main -preset slow"
VIDEO_OPTS2="-c:v libx264 -vprofile main -preset slow"
VIDEO_OPTS3="-c:v libx264 -vprofile main -preset slow"
OUTPUT_HLS="-f mp4"
~/Desktop/workspace/ffmpeg-mac/FFmpeg/ffmpeg -i $VIDSOURCE -y \
$AUDIO_OPTS -s $RESOLUTION1 $VIDEO_OPTS1 -b:v $BITRATE1 $OUTPUT_HLS ${OUTNAME}_${BITRATE1}.mp4 \
$AUDIO_OPTS -s $RESOLUTION2 $VIDEO_OPTS2 -b:v $BITRATE2 $OUTPUT_HLS ${OUTNAME}_${BITRATE2}.mp4 \
$AUDIO_OPTS2 -s $RESOLUTION3 $VIDEO_OPTS3 -b:v $BITRATE3 $OUTPUT_HLS ${OUTNAME}_${BITRATE3}.mp4 \
$AUDIO_OPTS2 -s $RESOLUTION4 $VIDEO_OPTS3 -b:v $BITRATE4 $OUTPUT_HLS ${OUTNAME}_${BITRATE4}.mp4 \
$AUDIO_OPTS2 -s $RESOLUTION5 $VIDEO_OPTS3 -b:v $BITRATE5 $OUTPUT_HLS ${OUTNAME}_${BITRATE5}.mp4 \
$AUDIO_OPTS2 -s $RESOLUTION6 $VIDEO_OPTS3 -b:v $BITRATE6 $OUTPUT_HLS ${OUTNAME}_${BITRATE6}.mp4 \
$AUDIO_OPTS2 -s $RESOLUTION7 $VIDEO_OPTS3 -b:v $BITRATE7 $OUTPUT_HLS ${OUTNAME}_${BITRATE7}.mp4 \
MASTER="<smil> \
<head> \
</head> \
<body> \
<switch> \
<video src='mp4:${OUTNAME}_${BITRATE1}.mp4' system-bitrate='$BITRATE1'/> \
<video src='mp4:${OUTNAME}_${BITRATE2}.mp4' system-bitrate='$BITRATE2'/> \
<video src='mp4:${OUTNAME}_${BITRATE3}.mp4' system-bitrate='$BITRATE3'/> \
<video src='mp4:${OUTNAME}_${BITRATE4}.mp4' system-bitrate='$BITRATE4'/> \
<video src='mp4:${OUTNAME}_${BITRATE5}.mp4' system-bitrate='$BITRATE5'/> \
<video src='mp4:${OUTNAME}_${BITRATE6}.mp4' system-bitrate='$BITRATE6'/> \
<video src='mp4:${OUTNAME}_${BITRATE7}.mp4' system-bitrate='$BITRATE7'/> \
</switch> \
</body> \
</smil> \
"
echo $MASTER > "$OUTNAME.smil"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment