Skip to content

Instantly share code, notes, and snippets.

@ramzes642
Created May 13, 2015 00:26
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 ramzes642/bec5e2954f536e891bc9 to your computer and use it in GitHub Desktop.
Save ramzes642/bec5e2954f536e891bc9 to your computer and use it in GitHub Desktop.
Reconvert shell script for tv/mediaplayers
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage:
$0 <source_dir> <dest_dir> - reencode folder
$0 <source_file> - reencode file in same dir
Reconverts video stream in media files and keeps all audio channels. Uses ffmpeg."
fi
rencode() {
inp=$1
outp=$2
ffmpeg -i "$inp" -map 0 -vcodec h264 -acodec: copy "$outp"
}
if [ $# = 1 ]
then
rencode "$1" "rencoded_$1"
fi
if [ $# = 2 ]
then
mkdir -p $2
ls $1 | while read f
do
rencode "$1/$f" "$2/$f"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment