Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP4.save() makes phone videos unreadable (Invalid NAL unit size) #584

Open
nahoj opened this issue Nov 26, 2022 · 0 comments
Open

MP4.save() makes phone videos unreadable (Invalid NAL unit size) #584

nahoj opened this issue Nov 26, 2022 · 0 comments

Comments

@nahoj
Copy link

nahoj commented Nov 26, 2022

If I use Mutagen to write tags to an MP4 video that I took with my phone (Samsung Galaxy S7 with LineageOS 14.1), I can't read the file with mplayer or VLC or any player I tried anymore.

This seems to be the case for any video taken with my phone and no other video I ever encountered.

Sample file: https://uno.nahoj.eu/nextcloud/s/CTffQgpw8qcqWnb

Steps to reproduce (last tried with Python 3.10 and Mutagen 1.46.0):

>>> f = mutagen.File("VID_20220226_151532a.mp4")
>>> type(f)
<class 'mutagen.mp4.MP4'>
>>> f["title"] = "Hi!"
>>> f.pprint()
'MPEG-4 audio (), 0.00 seconds, 0 bps (audio/mp4)\ntitle=Hi!'
>>> # Up to this point the file is fine
>>> f.save()
>>> # The file is now unreadable

After this, if I try to read the file with VLC, it outputs a bunch of errors of this type:

[h264 @ 0x7f0240c438c0] Invalid NAL unit size (961310570 > 279649).
[h264 @ 0x7f0240c438c0] Error splitting the input into NAL units.

Funnily this doesn't prevent Mutagen from reading and writing the tags multiple times. But undoing any changes doesn't make the video readable again.

I think this is a pretty bad bug. I noticed this when I added a tag on a personal video that I care a lot about and that got corrupted. Thankfully I had a backup; otherwise I would have had a very miserable day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant