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.


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
  • Just wanted to say, thanks a lot, this helped me right now. – SSS Feb 16 '19 at 15:35
  • worked like a charm, thank you. – Utku Özdemir Sep 13 '20 at 19:32

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).

  • 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 Dec 15 '19 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.