What I have is an MP4 movie with a video stream and an audio stream.

What I want in the output is an MP4 file containing:

  • the same video stream
  • the same audio stream
  • the same video stream with a lower bit-rate

Can anyone please tell me the appropriate ffmpeg command?

| improve this question | | | | |
  • 1
    May I ask why you need to do this? It's not difficult, but it may not help you accomplish what you want to accomplish. Plus, even if it does, it would make your question easier to find by others who are trying to do the same thing. – trlkly Aug 13 '14 at 7:25
  • @trlkly Please. I am doing this because I need to put such output files on my multi-rate video adaptive streamer server. – Behnam Aug 13 '14 at 10:31

In principle, it's done like so. Encode to lower bitrate with no audio. Of course, this assumes you have H.264 video. Check the encoding guide for more info.

ffmpeg -i input.mp4 -c:v libx264 -b:v 700k -an lower.mp4

Then, merge your files:

ffmpeg -i input.mp4 -i lower.mp4 -c copy -map 0:v -map 0:a -map 1:v output.mp4

This will take the first file's first video and audio streams, and the second file's first video stream, and copy them to the output container.

Then again, as @trikly mentions, there's no real advantage in doing this. Especially since you've tagged your question with "video streaming", note that by adding yet another stream inside a container, you're increasing the size of the file that the client has to download, rather than offering just a smaller representation, which is what you typically want to do for restricted bandwidth environments.

The real solution would be to do some kind of adaptive streaming, either with MPEG-DASH or HLS*. ffmpeg can create segmented files that can be used for DASH and HLS streaming, but you also need to generate the meta information files, etc. And you need a client that is DASH or HLS capable.

If that's too much to set up, you should simply offer the video in two different formats, each with their own link.

* Scalable Video Coding was also designed with a similar goal but it's not really used by anybody these days.

| improve this answer | | | | |
  • Thank you, I have a streamer server that handles demuxing and sending the appropriate video stream automatically. – Behnam Aug 25 '14 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.