Skip to content

Instantly share code, notes, and snippets.

@wheel5up
Created April 28, 2020 02:44
Show Gist options
  • Save wheel5up/86ee1b4fde5f3720777e89ca4873b890 to your computer and use it in GitHub Desktop.
Save wheel5up/86ee1b4fde5f3720777e89ca4873b890 to your computer and use it in GitHub Desktop.
Quick script to convert MTS files to mp4 without transcodeing and keeping the original date
#!/bin/bash -x
exifdateformat='%Y:%m:%d %T%Z'
ffmpegdateformat='%FT%T'
filenamedateformat='%Y%m%d_%H%M%S'
for srcfile in "$@"
do
exifcreatetime=$(exiftool -s -s -s -datetimeoriginal $srcfile)
echo "Get date/time:$exifcreatetime"
ffmpegcreatetime=$(date -j -f "$exifdateformat" "$exifcreatetime" +"$ffmpegdateformat")
echo "transformed date/time:$ffmpegcreatetime"
filecreatetime=$(date -j -f "$exifdateformat" "$exifcreatetime" +"$filenamedateformat")
echo "filename date/time:$filecreatetime"
echo "Get value:$srcfile"
ffmpeg -i $srcfile -c copy -metadata creation_time=${ffmpegcreatetime}Z ${filecreatetime}.mp4
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment