Skip to content

Instantly share code, notes, and snippets.

@mpampols
Created February 4, 2014 11:48
Show Gist options
  • Save mpampols/8802263 to your computer and use it in GitHub Desktop.
Save mpampols/8802263 to your computer and use it in GitHub Desktop.
Bash that checks a folder for .mp4 files without STREAMING string and reencodes them using ffmpeg to move the moov atom at the beginning of the file in order to enable web streaming.
#!/bin/bash
for file in /opt/web/streaming/*.mp4
do
echo "Check if file ${file% STREAMING.mp4} STREAMING.mp4 exists"
if [ ! -f "${file% STREAMING.mp4} STREAMING.mp4" ]; then
echo "-- New afile detected:"
echo "-- Running: ffmpeg -i "$file" -c:a copy -c:v copy -movflags faststart "${file%.mp4} STREAMING".mp4"
ffmpeg -i "$file" -c:a copy -c:v copy -movflags faststart "${file%.mp4} STREAMING".mp4
mv "$file" /opt/videos-originals
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment