Filter the video while keeping the bitrate (FFmpeg)

0

For experimental purposes, I need to filter my video (using -vf option) and change, say, brightness, but keep the same bitrate as in original video.

Just for testing purposes, I change RGB values to make video completely black using line like this:

ffmpeg -i input.mp4 -vf lutrgb='r=0.0*val:g=0.0*val:b=0.0*val' output.mp4

So far, I tried to specify bitrate manually by adding -b, -minrate/maxrate and -q options to this line, but no matter what I do, FFmpeg keep reducing the br of the output video to just a few kilobytes.

And my question is - if it's possible to keep bitrate on the same level even if if I change RGB values to be completely black (as an extreme case).

Timofey

Posted 2013-12-20T16:53:03.727

Reputation: 101

Why do you want a completely black output? Why do you want to try to match the bitrate? – llogan – 2013-12-20T18:37:29.427

Ok, I asked moderator to do this. I'm doing measurements of battery consumption on the phone caused by video streaming. I need to separate the effect of usage of the phone screen and the effect of usage of network. So I though about creating two files with the same bitrate, one completely black (so, the playback doesn't actually involves the screen), and second - normal version. It could be a silly idea, of course, but up till now, it's the best I can think of. – None – 2013-12-20T20:48:07.533

Answers

1

There is always a maximum size necessity to store something. If you specify 100Tb per second, the video will not be that big, because without adding padding, there is just not enough information in the source video to fill that much space. A completely black frame has almost zero information. it is literally the easiest thing to compress. Hence after it passes through the compression algorithm, the output is only a couple of bits. Its like ziping a file containing all zeros. Try making each pixel random, and you file will be huge.

I suggest reading up on information theory.

szatmary

Posted 2013-12-20T16:53:03.727

Reputation: 2 181

I probably didn't put it clear enough. I understand what causes my problem. Naturally, size of the completely black frame would be only couple of kb. However, theoretically, it is possible to have, say, black image sized 10 Mb (e.g. if we attach RAR archive to it), so why not possible to have video with bitrate 10 Mb/s? (by attaching an achieve to each frame... ok, just kidding). FFmpeg surely not intended for such tricks, but it has lots of features... – None – 2013-12-20T20:32:00.480

h.264 does have a filler NALU. I adds 0xFF bytes for force a bit-rate. But I do not believe ffmpeg will insert them. – szatmary – 2013-12-20T22:40:41.760

is there another way to manipulate these bytes? – Timofey – 2013-12-21T17:39:47.003

Another way besides what? – szatmary – 2013-12-21T20:28:59.540

Besides using FFmpeg – Timofey – 2013-12-22T00:17:02.547

1Sure. you can write a program to do it. – szatmary – 2013-12-24T01:24:47.437