2

On Windows, when you look at "Details" tab for an mp4 file, there is a "Parental rating" field which seems to be free text. I am trying to set that to "PG", "R", etc. for my movies.

The mutagen python module has a "rtng" tag, described as Content Rating, with an integer value. I am assuming these two attributes are related, and somehow there is a mapping from integer to an actual rating?

If that's true, I tried this:

from mutagen.mp4 import MP4
f = 'myfile.mp4'
mp4_video_tags = MP4(f)
mp4_video_tags['\xa9nam'] = 'My Title is long'
mp4_video_tags['\xa9gen'] = 'My Genre1; My Genre2'
mp4_video_tags['\xa9day'] = '1919'
mp4_video_tags['\xa9cmt'] = 'My Comments are very long'
mp4_video_tags['rtng'] = 1
mp4_video_tags.save()
print(mutagen.File(f))

Everything works, except "mp4_video_tags['rtng'] = 1". I get

mutagen.mp4.MP4MetadataValueError: 'int' object is not iterable

When I tried quoting the '1':

mp4_video_tags['rtng'] = '1'

I get another error:

mutagen.mp4.MP4MetadataValueError: value out of range: '1'

So my questions are

  1. Is the Parental rating attribute on the file set through 'rtng'?
  2. How to set 'rtng' correctly?
  3. What are the integer values for G, PG, PG13, R, etc?

2 Answers2

1

The rtng tag is used to denote the Parental Advisory attributes. It is mainly used by mp3 files to tag Explicit and Clean music types.

rtng = 2 would evaluate to Clean
rtng = 4 would evaluate to Explicit
rtng = 0 would evaluate to None

Anything other than 0,2 and 4, mutagen evaluates that to Explicit

EDIT
Its strange that that it requires a list rather that an int
And when you do give it a list it then works fine but you have multiple ratings separated by /which is really strange. This is a problem to it in this respect.

For example when you give it a list = [0,2,4] it sets Rating tag to None / Explicit / Clean

Currently there doesn't seem to be a tag supported by mutagen that would contain Content Rating for Movies like PG, PG-13,R, etc

0

I know I'm late for the party, but someone else can help. Answering your questions:

  1. Yes, parental rating attribute on file is set via 'rtng'.
  2. The correct way to configure is by putting an integer inside a list: mp4_video_tags['rtng'] = [0] to None. mp4_video_tags['rtng'] = [2] to Clean. mp4_video_tags['rtng'] = [4] to Explicit.
  3. As you answered above, there currently does not appear to be a mutagens compliant tag that contains content rating for movies.