Inspired by this blog article, with my personal modifications as HEVC (h.256) works for me but not for h.254 (when downloading compressed file from Google Photos to iOS).

Compression

Using HEVC codec, no audio compression1.

ffmpeg -i <INPUT-FILEPATH> -copy_unknown -map_metadata 0 -map 0 -codec copy -codec:v libx265 -pix_fmt yuv420p -crf 23 -preset veryslow <OUTPUT-FILEPATH>

Metadata Management

The -map_metadata flag above should retain most of the original metadata except for:

  • creation date
  • modification date
  • location

This extra step resolves the issue:

exiftool -tagsFromFile <INPUT-FILEPATH> -extractEmbedded -all:all -FileModifyDate -overwrite_original <OUTPUT-FILEPATH>

Footnotes

  1. I don’t have access to the right audio codec. Compiling from source looks like too much of a work.