Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Set bitrate #1690

Open
alexsafe opened this issue Dec 24, 2024 · 5 comments
Open

[Question] Set bitrate #1690

alexsafe opened this issue Dec 24, 2024 · 5 comments

Comments

@alexsafe
Copy link

Hi Pedro,

I'm flagging this as just a question for now, because I think it relates to the general way in which the bitrate is set. When setting the bitrate either by prepareVideo or setVideoBitrateOnFly in the stream I see that the bitrate kind of matches the one I set but when I move the camera, so where there is "action" the bitrate increases well above the set value. If the camera faces a static scene only then the bitrate I set is reached.
Is this the expected behaviour?

@pedroSG94
Copy link
Owner

Hello,

Sorry for late response. I'm on holidays

This is expected but depend a bit of the encoder used. The H264 codec reduce the bitrate if the image current image is similar to the previous image because repeat values to avoid increase the size but when te image is different the bitrate increase because you need send new info to properly create the image.

You can check if this way:
If you put your hand in the camera to full cover it and create a black image the bitrate reduce to a lower values because all images are similar to the previous one but if you move the devices fast all time the bitrate increase a higher values.

Also, the difference is the bitrate could change if you use a codec that support CBR but not all devices support it.

@alexsafe
Copy link
Author

alexsafe commented Jan 2, 2025

hehe yeah no problem same here.
The behavior you described is the same for me too. I was hoping to find a solution to better control the bitrate. like streaming 720p at 800kbps or 1500 kbps for instance. But if I set it for 800 I would like to not have it spike at 2000 kbps or something :).

For now my observations seem to indicate that the stream will try to send at the set bitrate (say 800) as long as there isn't much happening in front of the camera (like you also described). But then if you move something in front of the camera the bitrate will go as high as the network allows it for the given resolution. The use-case is that the network speed is very variable so I'd like to have more controls over those spikes. Is there something I could use for this?

@pedroSG94
Copy link
Owner

Hello,

Unfortunately you can't do anything about it. You can try use other codec like H265 and check if the result is better but it should be similar. Anyway, H265 can get the same quality with about 20-30% less bitrate so the spikes should be less to

@alexsafe
Copy link
Author

Yeah I thought so. With H265 it's the problem on the server side, the viewers need to be on Safari

@pedroSG94
Copy link
Owner

Maybe you can transcode from H265 to H264 in server side to solve the problem. Fews servers like media MTX can you a ffmpeg command to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants