Friday, December 16, 2005

how to make mp4 for streaming

Use ffmpeg, FAAC and MPEG4IP to make mp4 for streaming

  1. To extract the audio track from the source

    ffmpeg -i input_file -vn output_file


  2. To encode the raw PCM audio track split by FFmpeg: (use FAAC)

    faac -m4 -b64 -r48000 -pLC input_file output_file # for older version
    faac -m 4 -b 123 input_file output_file # for newer version

  3. encoding to ISO MPEG-4 video (bitrate: 300 kbps):
    • One pass

      ffmpeg -i input_file -an -b 300 -vcodec mpeg4 output_file


    • first pass

      ffmpeg -i input_file -an -pass 1 -passlogfile log_file -qscale 2 -vcodec mpeg4 output_file

      second pass

      ffmpeg -i input_file -an -pass 2 -passlogfile log_file -b 300 -vcodec mpeg4 output_file

  4. Multiplexing: combining the Audio and Video (using MPEG4IP)
    adding a video track

    mp4creator -c myvideo.avi -hint mytest.mp4

    adding a audio track, -interleave not needed for MP3

    mp4creator -c myaudio.aac -hint -interleave mytest.mp4

    optimize it

    mp4creator -optimize mytest.mp4
After that, you can use Darwin Streaming Server to stream the MPEG-4 clip.

Ref: Streaming MPEG-4 with Linux, 2003-03-13

No comments: