[FFmpeg-user] mute audio without restart of encoding process

Moritz Barsnick barsnick at gmx.net
Thu Sep 29 15:55:06 EEST 2016


On Thu, Sep 29, 2016 at 13:38:06 +0300, Виктор Митрофанов wrote:

> I need some way to mute audio in live rtmp stream while it is beign encoded
> by ffmpeg.
> Ideal scenario would be to have the ability to mute/unmute audio "on the
> go" - without restarting ffmpeg and encoding process - is there any way to
> make this possible?

Sure, the zmq/azmq filter allows pushing commands to filters, to change
their parameters at runtime. You would use "-af azmq,volume=1":

$ ffmpeg -re -loglevel verbose -f lavfi -i anoisesrc -af azmq,volume=1 -c:a libmp3lame test.mp3 -y

Then using tools/zmqsend, you can send commands to the filter chain:
$ echo 'Parsed_volume_1 volume 0' | tools/zmqsend
(You can use any value which the volume filter can parse, such as
"-20dB" or +"5dB", no spaces allowed though in this case apparently.)

If you run ffmpeg with loglevel "verbose" (as in my example above), you
can see the name of your filter within the chain, required for use with
zmq, and the values it uses:

[Parsed_volume_1 @ 0xbc44360] n:nan t:nan pts:nan precision:float volume:1.000000 volume_dB:0.000000

As soon as I issue the above command with zmqsend, I get these
messages:

[Parsed_azmq_0 @ 0xbc42100] Processing command #0 target:Parsed_volume_1 command:volume arg:0
[Parsed_volume_1 @ 0xbc44360] n:289.000000 t:6.165333 pts:295936.000000 precision:float volume:0.000000 volume_dB:-inf

Note how the volume filter changes its amplification variable "volume"
to 0, at time 6.165.

Have fun with this,
Moritz


More information about the ffmpeg-user mailing list