How to convert mp4 video files to fragmented mp4 files?

Hi Sahil,

To convert an mp4 video file into a fragmented mp4 file, use the following ffmpeg command:

ffmpeg -re -i input.mp4 -c copy -f mp4 -movflags frag_keyframe+empty_moov output.mp4

Here,

  • re: This flag will instruct FFmpeg to read the input file at its native frame rate.
  • i input.mp4: Indicates the source file (input.mp4) that has to be converted.
  • -c copy: The input video and audio streams will be duplicated without being re-encoded in stream copy mode.
  • -f mp4: Indicates the output format as MP4.
  • -movflags: This option sets the MOV/MP4 muxer flags.
  • frag_keyframe: This will instruct the FFmpeg to fragment the output file at keyframes.
  • empty_moov: It creates a placeholder moov atom at the start of the output file, allowing it to be streamed before the entire file is fully written.
  • output.mp4: Indicates the output file name as output.mp4.

You may also use the following tools to convert MP4 videos into fragmented MP4 files and package them with ABR (HLS/MPEG-DASH) format.

1. Shaka Packager

This media package was developed by Google. The major goal of this is to assist developers in preparing and encrypting media files for streaming using well-liked adaptive streaming formats like MPEG-DASH and HLS.

2. Bento4

Bento4 is a strong and flexible toolkit provided by Incodemedia that gives programmers the resources they need to work with MPEG-4 and ISOBMFF files. It makes it easier to perform activities like packaging, segmenting, and altering media content for streaming and distribution.

Refer this To convert m4s files to mp4 using FFmpeg: How to convert m4s files into mp4 using FFmpeg? - #2 by gurupal_singh

2 Likes