Edit "Media Duration" metadata on MP4 file

1

I have some video files which were converted to MP4, but not quite correctly. When I examine one with exiftool, I see these metadata values:

Duration                        : 0:11:23
Track Duration                  : 0:11:23
Media Duration                  : 0:04:13

That last one is incorrect. In VLC media player, the videos play fine, but the tool I'm using to play them in a web app (Flowplayer) takes the "Media Duration" value seriously and truncates the video.

To fix the metadata I tried

exiftool -"Media Duration"="0:11:23" video_1.mp4

But I got

Warning: Sorry, Media is not writable
Nothing to do.

Sudo didn't help. According to its man page and web site, exiftool can read and write metadata on MP4 files, but "ExifTool will not rewrite a file if it detects a significant problem with the file format."

How can I fix those files?


EDIT: I've had no luck with ffmpeg or mediainfo.

Sam Kauffman

Posted 2014-08-12T22:37:35.410

Reputation: 151

Answers

1

I found a solution. Rather than editing the metadata, I re-encoded the files using ffmpeg, in such a way that the video and audio content was simply copied and wrapped in a new, error-free MP4 container. Here's the command:

ffmpeg -i video_1.mp4 -vcodec copy -acodec copy video_1_fixed.mp4

Sam Kauffman

Posted 2014-08-12T22:37:35.410

Reputation: 151

Just wanted to say, thanks a lot, this helped me right now. – SSS – 2019-02-16T15:35:17.840

1

There are two reasons why the listed exiftool command didn't work.

First, "Media Duration" isn't the name of a tag, it's the description. From ExifTool FAQ #2

…by default it prints descriptions, not tag names, for the information it extracts. … Note that descriptions often contain spaces between words, but tag names never do. Also, tag names are always English, regardless of the -lang setting. To print the tag names instead instead of descriptions, use the -s option when extracting information

The second problem is that the MediaDuration tag isn't a writable tag (see the QuickTime MediaHeader Tags).

StarGeek

Posted 2014-08-12T22:37:35.410

Reputation: 782

Admittedly, this is a necro-post answer, but I thought I should bring up the reasons why the original exiftool command didn't work. – StarGeek – 2019-12-15T17:10:58.477