Skip to content

Instantly share code, notes, and snippets.

@ahknight
Created March 7, 2014 15:23
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 ahknight/9413442 to your computer and use it in GitHub Desktop.
Save ahknight/9413442 to your computer and use it in GitHub Desktop.
Convert pretty much any video file to a format that will play on an AppleTV 3 (and maybe a 2). Only converts streams that need it.
#!/bin/bash
FILE="$1"
VCODEC=$( mediainfo --Inform="Video;%Format%" "$FILE" )
ACODEC=$( mediainfo --Inform="Audio;%Format%" "$FILE" )
echo $FILE: $VCODEC/$ACODEC
[ "$VCODEC" = "AVC" ] && VC="copy" || VC="libx264"
[ "$ACODEC" = "AAC" ] && AC="copy" || AC="aac -strict experimental"
avconv -i "$FILE" -vcodec $VC -acodec $AC "${FILE/%.???/.mp4}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment