Skip to content

Instantly share code, notes, and snippets.

@tralston
Last active April 11, 2018 00:31
Show Gist options
  • Save tralston/cdf8f311568671542370e16b73cea687 to your computer and use it in GitHub Desktop.
Save tralston/cdf8f311568671542370e16b73cea687 to your computer and use it in GitHub Desktop.
[Fix HEVC fourcc code to be able to play h265 videos on AppleTV from Plex]
# Note this only works on newer versions of ffmpeg (3.4.2+)
ffmpeg -i file.mp4 -codec copy -vtag hvc1 -map 0:0 -map 0:1 file.mp4
# see what codec id (fourcc code) your video has
mediainfo "file.ext" | grep -im 2 'codec id' | tail -n1
# or a list of files
for file in *.mp4; do echo "$file" "$(mediainfo "$file" | grep -im 2 'codec id' | tail -n1)"; done
# Fix the fourcc code hev1 -> hvc1. Note: this will overwrite the timestamp, so make sure to save it or restore it
# Added _fixed suffix as to not overwrite original in case it doesn't work
for file in IMG*.mp4; do ffmpeg -y -hide_banner -loglevel quiet -i "$file" -codec copy -vtag hvc1 -map 0:0 -map 0:1 "${file%.*}_fixed.${file##*.}"; echo "Processed $file"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment