Last active
March 25, 2017 01:00
-
-
Save dantheman213/fcf4853773e24ae214a9614f5afbc422 to your computer and use it in GitHub Desktop.
Batch transcode mp4 files from a directory, set bitrate, and output to another directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Batch transcode mp4 files from a directory, | |
| # set bitrate, and output to another directory. | |
| # User-defined parameters | |
| INPUT_DIR="/home/user/Videos/pre" | |
| OUTPUT_DIR="/home/user/Videos/post" | |
| MEDIA_EXTENSION="mp4" | |
| TARGET_BITRATE_VIDEO="8M" | |
| TARGET_BITRATE_AUDIO="128K" | |
| # Execution | |
| echo "Started down transcode script" | |
| echo "Looking for $MEDIA_EXTENSION files within $INPUT_DIR" | |
| for filePath in `find $INPUT_DIR | grep ".$MEDIA_EXTENSION"`; do | |
| fileName=basename "${filePath}" | |
| echo "Transcoding $fileName..." | |
| ffmpeg -i $filePath -vcodec libx264 -b:v $TARGET_BITRATE_VIDEO -acodec aac -b:a $TARGET_BITRATE_AUDIO $OUTPUT_DIR/$fileName | |
| done | |
| echo "completed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment