Skip to content

Instantly share code, notes, and snippets.

@ErnWong
Last active June 2, 2025 03:52
Show Gist options
  • Save ErnWong/a307a2d7913f1955d4f43daf6b0a1c31 to your computer and use it in GitHub Desktop.
Save ErnWong/a307a2d7913f1955d4f43daf6b0a1c31 to your computer and use it in GitHub Desktop.
Handy script to transcode videos to .mov/mjpeg so they can be used in davinci resolve
set -e
shopt -s nullglob
LOGS="./to_mjpeg.log"
function info()
{
BLUE="\e[1;44;37m"
RESET="\e[0m"
echo -e "$BLUE$@$RESET" | tee -a "$LOGS"
}
function warn()
{
YELLOW="\e[1;43;30m"
RESET="\e[0m"
echo -e "$YELLOW$@$RESET" | tee -a "$LOGS"
}
info ""
info ""
info "======================================"
info "New session: $(date -Iseconds)"
info "======================================"
info ""
info ""
for i in */*.{mp4,MP4}
do
out="${i%.*}.mov"
if [[ -f "$out" ]]
then
info "Skipping $out - already exists"
else
info "Processing $i ----> $out"
info ""
temp="$out.wip"
if [[ -f "$temp" ]]
then
warn "Overwriting existing partial output and restarting from scratch: $temp"
fi
info ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "$temp" -y
file_logs="$out.logs"
ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "$temp" -y 2>&1 | tee "$file_logs" | tee -a "$LOGS"
mv "$temp" "$out"
info ""
fi
done
info ""
info ""
info "======================================"
info "Session done: $(date -Iseconds)"
info "======================================"
info ""
info ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment