[FFmpeg-devel] [PATCH] avcodec/mediacodec: Add support of dynamic bitrate

Andrew Sayers ffmpeg-devel at pileofstuff.org
Tue May 28 18:38:18 EEST 2024


On Mon, May 27, 2024 at 01:49:47PM +0100, Dmitrii Okunev wrote:
> MediaCodec supports parameter "video-bitrate" to change the bitrate
> on fly. This commit add possibility to use it.
> 
> It adds option -bitrate_ctrl_socket to the encoder which makes
> the encoder to create an UNIX socket and listen for messages
> to change the bitrate.
> 
> An example of ffmpeg execution:
> 
>     ffmpeg -listen 1 -i rtmp://0.0.0.0:1935/live/myStream -c:v hevc_mediacodec -bitrate_ctrl_socket /run/bitrate.sock -b:v 8M -f rtsp rtsp://127.0.0.1:1935/live/reEncoded
> 
> An example of changing the bitrate to 1000 BPS:
> 
>     printf '%016X' 1000 | xxd -r -p | socat -u STDIN UNIX:/run/bitrate.sock

Nitpick: please do s/\* / \*/g on the following lines:

> +                                    const FFAMediaFormat* format_ctx)
> +static int mediacodec_ndk_setParameters(FFAMediaCodec* ctx,
> +                                    const FFAMediaFormat* format_ctx)
> +    int (*setParameters)(FFAMediaCodec* codec, const FFAMediaFormat* format);

(found by an in-progress review bot)


More information about the ffmpeg-devel mailing list