Why some of the MP4 file's mime-type are application/octet-stream instead of video/mp4?
Asked Answered
B

1

7

Why some of the MP4 file's mime-type are application/octet-stream instead of video/mp4?

I've checked with file command in terminal (CLI)

user@anto:~/Videos/VTB$ file --mime-type -b GDPR.mp4 
video/mp4
user@anto:~/Videos/VTB$ file --mime-type -b Test-vid1.mp4 
application/octet-stream
user@anto:~/Videos/VTB$ file --mime-type -b SampleVideoLarge.mov 
video/quicktime
user@anto:~/Videos/VTB$ file --mime-type -b SampleVideo21.mp4 
video/mp4
user@anto:~/Videos/VTB$ file --mime-type -b VTBSample-new.mp4 
application/octet-stream.

Can anyone tell me the reason? How to handle this mime-type. Is the video file with application/octet-stream is a correct mp4 file or wrong one?

Bewail answered 27/6, 2018 at 9:55 Comment(0)
J
1

It's still a correct MIME type for MP4. By saying "correct", it can be played without problems in most cases (using player software, playing with <video> tag in HTML, etc).

Some web servers do not configure the MIME type to serve the officially documented MIME type, video/mp4, thus the MIME type will be set to application/octet-stream by the web server, which is a generic MIME type for binary file downloads.

For example, to handle the application/octet-stream MP4 in HTML, you can specify MIME type in the <source> tag:

<video>
  <source src="video.mp4" type="video/mp4" />
</video>

Hope it helps.


UPDATE:

If you are really concerned about these application/octet-stream videos, you can re-render them using programs like ffmpeg to force the updated video file to be video/mp4 MIME type.

Justajustemilieu answered 27/6, 2018 at 10:7 Comment(8)
Thanks for your reply. I'm using paperclip ruby gem for one my product, Before we're using version 5.0.0, but no issues were reported by paperclip gem with the same mp4 video with mime-type as application/octet-stream. Now we've updated the gem version to 6.0.0. Now It's reported issues on the mime-type (mismatch - video/mp4 should be for mp4 file). This is the exact issue.Bewail
Read thisJustajustemilieu
For anyone wondering how to convert it, use this command with ffmpeg: ffmpeg -i broken.mp4 -pix_fmt yuv420p -crf 18 good.mp4Pontonier
@Pontonier it depends on case by case. Your command does not necessarily work on all scenarios.Justajustemilieu
@Justajustemilieu Oh okay, interesting to know. I still hope it helps somebody out though!Pontonier
i have recorded audio from safari using media recorder api and it give me file in octate-stream mime type so i have saved it as a .mp3 and when i try to convert it to actual mp3 file using ffmpeg it is converting only 1 second.Twitty
is there a video player library that supports octet streams?Hemorrhage
application/octet-stream is partially supported in browsers. Use with caution.Justajustemilieu

© 2022 - 2024 — McMap. All rights reserved.