Discussion:
How to get a true constant video bitrate (not only muxrate) in an UDP output with Melt
(too old to reply)
David Alonso Grande
2017-03-30 13:54:43 UTC
Permalink
Raw Message
Hello,

I need to get a true constant video bitrate in an UDP output address.

By using cbrts consumer I am getting a constant muxrate in the UDP output,
but not a constant video bitrate.
I have noticed that varying the gop size has an effect in the shape of the
output video bitrate curve but still I am not getting a flat (or almost
flat) video bitrate line in the output analyzer.

This is the script I am using:

melt -profile atsc_1080i_50 test_1.mp4 \
-consumer cbrts udp.address=10.192.33.14 udp.port=5678 udp.ttl=12
udp.reuse=1 udp.rtp=0 muxrate=6000000 udp.buffer=1000 \
vcodec=libx264 bufsize=5505024 vb=3M minrate=3M maxrate=3M g=15 bf=2 \
acodec=mp2 ab=160k threads=3 real_time=1

I am trying to add this libx264 encoding option

-x264-params "nal-hrd=cbr:force-cfr=1"

as described in this post:

http://slhck.info/video/2017/03/01/rate-control.html

but It seems that Melt is ignoring it although It is not showing any error.

Any help would be really appreciated!

Regards,

David
Brian Matherly
2017-03-30 14:46:10 UTC
Permalink
Raw Message
Post by David Alonso Grande
I need to get a true constant video bitrate in an UDP output address.
By using cbrts consumer I am getting a constant muxrate in the UDP
output, but not a constant video bitrate.
I have noticed that varying the gop size has an effect in the shape of
the output video bitrate curve but still I am not getting a flat (or
almost flat) video bitrate line in the output analyzer.
melt -profile atsc_1080i_50 test_1.mp4 \
-consumer cbrts udp.address=10.192.33.14 udp.port=5678 udp.ttl=12
udp.reuse=1 udp.rtp=0 muxrate=6000000 udp.buffer=1000 \
vcodec=libx264 bufsize=5505024 vb=3M minrate=3M maxrate=3M g=15 bf=2 \
acodec=mp2 ab=160k threads=3 real_time=1
I am trying to add this libx264 encoding option
-x264-params "nal-hrd=cbr:force-cfr=1"
http://slhck.info/video/2017/03/01/rate-control.html
but It seems that Melt is ignoring it although It is not showing any error.
Any help would be really appreciated!
Regards,
David
"-x264-params" is the "new" ffmpeg option. MLT still uses the old
option: "x264opts"
https://mltframework.org/plugins/ConsumerAvformat/#x264opts

I suppose we will have to update to use the new option some day. In the
mean time, try using "x264opts".

~Brian
Dan Dennedy
2017-03-30 15:29:33 UTC
Permalink
Raw Message
Post by David Alonso Grande
I need to get a true constant video bitrate in an UDP output address.
By using cbrts consumer I am getting a constant muxrate in the UDP output,
but not a constant video bitrate.
I have noticed that varying the gop size has an effect in the shape of the
output video bitrate curve but still I am not getting a flat (or almost
flat) video bitrate line in the output analyzer.
melt -profile atsc_1080i_50 test_1.mp4 \
-consumer cbrts udp.address=10.192.33.14 udp.port=5678 udp.ttl=12
udp.reuse=1 udp.rtp=0 muxrate=6000000 udp.buffer=1000 \
vcodec=libx264 bufsize=5505024 vb=3M minrate=3M maxrate=3M g=15 bf=2 \
acodec=mp2 ab=160k threads=3 real_time=1
I am trying to add this libx264 encoding option
-x264-params "nal-hrd=cbr:force-cfr=1"
http://slhck.info/video/2017/03/01/rate-control.html
but It seems that Melt is ignoring it although It is not showing any error.
Any help would be really appreciated!
Regards,
David
"x264opts"
https://mltframework.org/plugins/ConsumerAvformat/#x264opts
I suppose we will have to update to use the new option some day. In the
mean time, try using "x264opts".
Actually, MLT does not define either x264-params or 264opts. Those are
AVOptions that MLT exposes. So, it depends on how it is built (version of
libavcodec). You can use "melt -query consumer=avformat | grep x264" to see
which to use. Then, of course, you must use the melt "name=value" syntax
instead of "-name value".
David Alonso Grande
2017-04-03 14:34:39 UTC
Permalink
Raw Message
Hello Dan, Brian.

Thank you for your answers. I've been struggling with this issue for a
while and I don't manage to get an almost constant video bitrate in the
output.

It seems I should use the --nal-hrd cbr option to "fill the mux" as
explained in post:

http://forum.doom9.org/archive/index.php/t-159536.html

But I don't manage to use it successfully in Melt neither with -x264-params,
nor with x264opts.

I don't know how to properly translate it to "name=value" melt syntax.
Should I write -x264opts in the command or not?

I have made different tries with no success so far, such as:

vcodec=libx264 nal-hrd=cbr vbv-bufsize=6M vb=3M minrate=3M maxrate=3M g=15
bf=2 ts=cbr

Changing the line to:

vcodec=libx264 -x264opts nal-hrd=cbr vbv-bufsize=6M vb=3M minrate=3M
maxrate=3M g=15 bf=2 ts=cbr

does not seem to have effect either.


If I do: "melt -query consumer=avformat | grep x264"

It seems I have both options available:

- identifier: x264opts
description: x264 options (libx264)
description: Select the quality for constant quality mode (libx264)
- identifier: x264-params
description: "Override the x264 configuration using a :-separated list
of key=value parameters (libx264)"
description: Set the encoding preset (cf. x264 --fullhelp) (libx264rgb)

Do you have a melt working example to get a constant video bitrate in the
output?

Thank you,

David
Post by Dan Dennedy
Post by David Alonso Grande
I need to get a true constant video bitrate in an UDP output address.
By using cbrts consumer I am getting a constant muxrate in the UDP
output, but not a constant video bitrate.
I have noticed that varying the gop size has an effect in the shape of
the output video bitrate curve but still I am not getting a flat (or almost
flat) video bitrate line in the output analyzer.
melt -profile atsc_1080i_50 test_1.mp4 \
-consumer cbrts udp.address=10.192.33.14 udp.port=5678 udp.ttl=12
udp.reuse=1 udp.rtp=0 muxrate=6000000 udp.buffer=1000 \
vcodec=libx264 bufsize=5505024 vb=3M minrate=3M maxrate=3M g=15 bf=2 \
acodec=mp2 ab=160k threads=3 real_time=1
I am trying to add this libx264 encoding option
-x264-params "nal-hrd=cbr:force-cfr=1"
http://slhck.info/video/2017/03/01/rate-control.html
but It seems that Melt is ignoring it although It is not showing any error.
Any help would be really appreciated!
Regards,
David
"x264opts"
https://mltframework.org/plugins/ConsumerAvformat/#x264opts
I suppose we will have to update to use the new option some day. In the
mean time, try using "x264opts".
Actually, MLT does not define either x264-params or 264opts. Those are
AVOptions that MLT exposes. So, it depends on how it is built (version of
libavcodec). You can use "melt -query consumer=avformat | grep x264" to see
which to use. Then, of course, you must use the melt "name=value" syntax
instead of "-name value".
Brian Matherly
2017-04-03 14:52:33 UTC
Permalink
Raw Message
Post by David Alonso Grande
Hello Dan, Brian.
Thank you for your answers. I've been struggling with this issue for a
while and I don't manage to get an almost constant video bitrate in
the output.
It seems I should use the --nal-hrd cbr option to "fill the mux" as
http://forum.doom9.org/archive/index.php/t-159536.html
<http://forum.doom9.org/archive/index.php/t-159536.html>
But I don't manage to use it successfully in Melt neither with
-x264-params, nor with x264opts.
I don't know how to properly translate it to "name=value" melt syntax.
Should I write -x264opts in the command or not?
vcodec=libx264 nal-hrd=cbr vbv-bufsize=6M vb=3M minrate=3M maxrate=3M
g=15 bf=2 ts=cbr
vcodec=libx264 -x264opts nal-hrd=cbr vbv-bufsize=6M vb=3M minrate=3M
maxrate=3M g=15 bf=2 ts=cbr
does not seem to have effect either.
If I do: "melt -query consumer=avformat | grep x264"
- identifier: x264opts
description: x264 options (libx264)
description: Select the quality for constant quality mode (libx264)
- identifier: x264-params
description: "Override the x264 configuration using a :-separated
list of key=value parameters (libx264)"
description: Set the encoding preset (cf. x264 --fullhelp)
(libx264rgb)
Do you have a melt working example to get a constant video bitrate in
the output?
Thank you,
David
It seems your version of ffmpeg supports both the new and old x264
option. So you can use either.

This has worked for me in the past to get a reasonably CBR output:

x264opts="keyint=30:min-keyint=1:bframes=2:nal-hrd=cbr:pic-struct:weightp=0:crop-rect=0,0,0,4:fps=29.97:bitrate=18000:vbv-maxrate=18000:vbv-bufsize=25000:ref=4:level=4"

Try tweaking it to meet your needs. It also demonstrates the correct syntax.

As I recall, if the bitrate is high enough, and the content is simple
enough (like a solid color or still picture), x264 might not be able to
use all of the available bitrate - even if you specify CBR.

~Brian

Loading...