ffmpeghtml5-video

FFmpeg MOV to MP4, do I also need .OGG , .WEBM files too?


I am new to FFmpeg and I'm just getting started. I have the two following commands to take a .mov upload and downsize it and save it out as an .mp4. I also produce a thumbnail version of the same.

What I am doing here seems to work well and I manage to get the .mov file from 12.5mb to about a 1mb .mp4.

My question from here is, can I get away with only providing a .mp4 for the source video, or do I need to provide additional .ogg and/or .webm files too? An if so, how is that best achieved? Would I have to loop that FFmpeg command again to output new .ogg and .webm files?

exec("ffmpeg -i src.mov -ss 00 -to 60 -vf scale=700:-1 -crf 30 -an -movflags +faststart output.mp4");

exec("ffmpeg -i src.mov -ss 00 -to 10 -vf 'scale=128:128:force_original_aspect_ratio=increase, crop=128:128' -crf 30 -an tn_output.mp4");


Solution

  • can I get away with only providing a .mp4 for the source video, or do I need to provide additional .ogg and/or .webm files too?

    I'm not that well-versed in webdev, but you'd like to have your <video> content to have multiple sources for browser compatibility. IIRC, Chromium does not natively support mp4, for example.

    An if so, how is that best achieved? Would I have to loop that FFmpeg command again to output new .ogg and .webm files?

    FFmpeg can produce multiple video files at once from one source:

    ffmpeg -i src.mov -ss 00 -to 60 \
      -filter_complex [v:0]scale=700:-1,split=3[v1][v2][v3] \
      -map [v1] output.mp4 \
      -map [v2] output.webm \
      -map [v3] output.ogg
    

    You need to use split filter to copy the video streams as one stream can only be used by one output file.

    What I do not know for sure is whether this is faster than calling FFmpeg 3 times (most likely, but never tried it myself).