Let's assume I have a video of 10 minutes length. And I want to reduce its size by having some parts in high bitrate, while other less important parts can be low bitrate. For this I'd cut the original into segments. Leaving the important ones as they are, while transcoding the unimportant parts to a lower quality.

enter image description here

Now, is there a video container format out there which is able to "glue" these different parts together into one file? With good support in players so trusty mplayer will play the video as if it's an ordinary file? And in a standardized/annotated/undo-able way so a simple cli command would untangle the segments into separate parts/files again?

I was under the impression Matroska would be able to do this, via chapters, where each of my segments would be one chapter. (I've read it somewhere where merging videos without transcoding was dicussed). But when I read the actual mkv docs, it seems mkv chapters are more like a textual index pointing into another (video) stream of an .mkv file - and not some low level kind of data block index which would help me with my idea. So mkv looks like a dead end.

Simple editing, or merging (which is possible losslessly, with some remuxing) wouldn't offer me having different qualities in different sections of the video - right?

What I'm looking for is region-of-interest adapted quality, something image formats like JPEG2000 offer for spatial areas, only here applied to video over time.

Any suggestions or ideas?

The accepted answer suggests using the VBR capabilities of a format like mp4. While this works, please leave an answer if you know of a different way of achieving the desired result.

3 Answers 3


If the only difference is bitrate, then any container which accepts variable bitrate streams, will fulfill your requirement e.g. MP4, MKV..etc

Step 1 is to encode your segments, ideally using the same encoder, to different bitrates with all other parameters being the same e.g. via ffmpeg,

ffmpeg -ss 0 -t 5 -i input.mp4 -b:v 1000k seg1.mp4

ffmpeg -ss 5 -t 7 -i input.mp4 -b:v 3000k seg2.mp4

ffmpeg -ss 12 -i input.mp4 -b:v 500k seg3.mp4

Step 2 is to use ffmpeg to concat the encoded segments in copy mode, using the concat demuxer.

Prepare a text file

file 'seg1.mp4'
file 'seg2.mp4'
file 'seg3.mp4'

and then

ffmpeg -f concat -i list.txt -c copy joined.mp4

Clips with different properties, like resolution, can be joined together as well into one MP4, but compatibility across media players is iffy, and ffmpeg won't do it reliably at present, anyway.

  • Interesting! I've always had another conception of what VBR is and does, in terms of "granularity". Will try that. Also, I'll wait a little more until I'll probably mark your answer the as the accepted one
    – isync
    May 2, 2016 at 12:21
  • After trying it, and finding it works (both, vbr and even variable size), I've found a minor problem: When I edit-out one segment "as-is" with "-vcodec copy", the concat will report 1. "Auto-inserting h264_mp4toannexb bitstream filter" (seems fine), 2. "Non-monotonous DTS in output stream" (arg!!) for that segment. Is there a way to do a stream copy (no re-encoding), but stripping time-stamps. As I understand it, filtering the output/this segment in such a way would fix this DTS error (although the video plays anyway).
    – isync
    May 2, 2016 at 13:07
  • ffmpeg, by default, generates new timestamps, unless you use the segment muxers or supply a flag like copyts. What command are you getting the error with?
    – Gyan
    May 2, 2016 at 14:23
  • Command is what you suggested: ffmpeg -f concat -i list.txt -c copy joined.mp4, and the example segment commands, only the middle one altered to be ... -i input.mp4 -vcodec copy seg2.mp4. Tested with ffmpeg 2.8.1, my Ubuntu avconv doesn't know about concat yet.
    – isync
    May 2, 2016 at 16:34
  • Ah. With stream copy, cutting isn't exact. You'll have to insert -avoid_negative_ts make_zero but you'll likely get some repeat with the prior segment.
    – Gyan
    May 2, 2016 at 16:44

Advanced Authoring Format (AAF) and some MXF operational patterns (OP-2a, 2b, 3a, and 3b) should be able mix bit rates. I say "should" because I don't have any good way of testing right now and I don't know of any commercial systems that are making heavy use of those MXF OP's.


Well I can't say I know how it would be done; but RED (www.red.com), their R3D video format uses a debayer process.

I own a RED Epic. It shoots at up to 5K 100 FPS.

When out in the field, and wanting to view the video on say a laptop, the throughput of uncompressed (or near) say 3:1 5K is huge.

So RED uses a debayer process; where the pixels are basically assigned into a grid pattern in terms of how they are both encoded and decoded.

So this eliminates the need for "proxy" files, files which are downres'd for editing because your system simply can't play the file in realtime.

The Debayer is 8 levels. And the RED player (as well as software that supports it such as PPro/After Effects, allow you to playback at 100%, 50% 25% 12.5% and so on.

The unique aspect with RED is when your computer does this, it actually isnt lowering the quality, it's just only displaying the x/100 quality you want.

So perhaps my answer is a bit backwards in thinking: But essentially with RED files you have a 1K, 2K, 3K, 4K, 5K, version- all wrapped into 1 file.

Hope this perhaps helps somewhat, even though it's not an answer to the actual question.

  • This "answer" does not actually the question that was asked. It does not address how to handle the problem generally (one cannot transcode from any random video format into RED RAW). And to my knowledge, one cannot change RED debayer/compression parameters on the fly as a dynamic property of RED media. May 2, 2016 at 20:40
  • More an ex-course into file-formats, but anyway thank you for the effort.
    – isync
    May 3, 2016 at 0:06
  • I believe I said clearly that it was not changing the "debayer/compression" parameters; meerly the playback of such. I also specified that the answer does not directly relate to the question, moreso the "concept". May 15, 2016 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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