Created
June 3, 2024 01:16
-
-
Save bryanheinz/ddcbea5f37cc510f0e859af0fae5fb34 to your computer and use it in GitHub Desktop.
These are my notes on editing MP4 metadata using Python Mutagen. I found most of it not straight forward and it's required a lot of research, trial, and error.
This file contains 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
# pip install mutagen | |
from mutagen.mp4 import MP4, MP4Cover | |
video = MP4('video.mp4') | |
# set a TV show series name | |
video['tvsh'] = "TV SHOW NAME" | |
# set the episode title | |
video['\xa9nam'] = "EPISODE TITLE" | |
# set the video type to a TV Show | |
video['stik'] = [10] | |
# set episode number | |
video['tves'] = [1] | |
# set season number | |
video['tvsn'] = [1] | |
# set the movie rating to G | |
video['----:com.apple.iTunes:iTunEXTC'] = b'mpaa|G|100|' | |
# set the thumbnail artwork | |
with open('thumb.png', 'rb') as fh: | |
img = fh.read() | |
mpv['covr'] = [MP4Cover(img, imageformat=MP4Cover.FORMAT_PNG)] | |
video.save() | |
# Movie Ratings | |
# - mpaa|Not Rated|000| | |
# - mpaa|G|100| | |
# - mpaa|PG|200| | |
# - mpaa|PG-13|300| | |
# - mpaa|R|400| | |
# - mpaa|NC-17|500| | |
# - mpaa|Unrated|900| | |
# | |
# TV Ratings | |
# - `us-tv|TV-Y|100|` (G) | |
# - `us-tv|TV-Y7|200|` (PG) | |
# - `us-tv|TV-G|300|` (PG-13) | |
# - `us-tv|TV-PG|400|` (R) | |
# - `us-tv|TV-14|500|` (NC-17) | |
# - `us-tv|Unrated|900|` (Unrated) | |
# - `us-tv|Not Rated|000|` (Not Rated) | |
# | |
# Media Types | |
# stik 0 == Home Movie | |
# stik 6 == Music Video | |
# stik 9 == Movie | |
# stik 10 == TV Show | |
# https://mutagen.readthedocs.io/en/latest/api/mp4.html | |
# https://stackoverflow.com/a/52413955/7341009 | |
# https://github.com/quodlibet/mutagen/issues/391 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment