Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox says some files converted from mkv to mp4 in ffmpeg are corrupt

I have recently converted many videos for web playback, but all videos from one "series" all show up in firefox as "Video can't be played because the file is corrupt." (They work for google chrome and VLC. Not for firefox or edge.) All files have been converted with this command:

ffmpeg -i "file.mkv" -vcodec h264 -movflags +faststart -map 0 -vf subtitles="file.mkv" "file.mp4"

ffmpeg output from one of the non-working files:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Episode_7.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.3.100
  Duration: 00:23:53.52, start: -0.001333, bitrate: 1900 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1920x1080 [SAR 1:1 DAR 16:9], 1763 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 130 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

ffmpeg output from a working file:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Episode_7.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.3.100
  Duration: 00:23:40.06, start: 0.000000, bitrate: 1848 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1710 kb/s, 23.81 fps, 23.81 tbr, 16k tbn, 47.62 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

Of a collection of over 100 files, only 12 episodes of a single series show up as corrupted in firefox. I see some differences in the information about the two files, but I don't know why one file works and the other does not. What do I need to tell ffmpeg to make the videos playable in firefox?

like image 856
EpicKnarvik97 Avatar asked Mar 08 '23 03:03

EpicKnarvik97


1 Answers

It's the 4:4:4 chroma sampling. Add -pix_fmt yuv420p to the output file.

like image 67
szatmary Avatar answered Mar 09 '23 17:03

szatmary