Last active
January 23, 2021 01:34
-
-
Save migueleliasweb/64401a3b856438991cbb52966568214b to your computer and use it in GitHub Desktop.
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
mp4tomov() { | |
FILENAME=$(basename -- "${1}") | |
FILE_EXTENSION="${FILENAME##*.}" | |
FILENAME_ONLY="${FILENAME%.*}" | |
FILENAME_OUTPUT="${2}${FILENAME_ONLY}.mov" | |
if [ ! -d "${2}" ]; then | |
echo "Second parameter must be a directory" | |
return | |
fi | |
echo "OUTPUT TO: ${FILENAME_OUTPUT}" | |
if [ "${FILENAME_EXTENSION}" == "mp4" ] || [ "${FILENAME_EXTENSION}" == "MP4" ]; then | |
echo "File extension must be .mp4 or .MP4, got ${FILE_EXTENSION} instead." | |
return | |
fi | |
if [ ! -f "${FILENAME_OUTPUT}" ]; then | |
# You can use -q:v 2 for better quality but the file size | |
# is humongous. Be warned. | |
ffmpeg -i ${1} -vcodec mjpeg -q:v 3 -acodec pcm_s16be -q:a 0 -f mov ${FILENAME_OUTPUT} | |
else | |
echo "File ${FILENAME_OUTPUT} already present. Skipping." | |
fi | |
} | |
mp4tomovdir(){ | |
for FILENAME in `find "${1}" -type f -iname "*MP4"`; do | |
mp4tomov ${FILENAME} ${2} | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment