0

Idk why but when I apply this filter the video is still output with sound. I am not sure of the syntax required to apply filter, so help would be appreciated. Only necessary portion of the code is shown, as im pretty sure this is just a syntax error. I am attempting to mute the clip

ffmpeg.filter_(i,'volume',0)                                     ##YOU ARE HERE TRYING TO GET FILTERS TO WORK
        ffmpeg.output(i, videoFileName,
                    **{'c:v': 'libx264', 'b:v': targetTotalBitrate, 'pass': 2, 'f' :'mp4'}
                    ).overwrite_output().run()
        print('selected')

1 Answers1

0

I doubt the volume filter is meant to be used for muting. If you want no sound, you eliminate an audio stream from your output. The easiest way is to use -an output option.

See FFmpeg Audio Options Documentation

For ffmpeg-python, try

ffmpeg.output(i, videoFileName,**{'c:v': 'libx264', 'an':None, 'b:v': targetTotalBitrate, 'pass': 2,'f' :'mp4'})

Finally, if you continue having an issue with ffmpeg-python, you can give my ffmpegio a try:

pip install ffmpegio-core

(There is ffmpegio package as well, but that one adds NumPy dependency)

from ffmpegio import ffmpegprocess

ffmpegprocess.run_two_pass({
    'inputs' : [('myvideo.mp4',None)], # None can be replaced with an option dict
    'outputs': [(videoFileName, {
        'c:v': 'libx264', 
        'an' : None, 
        'b:v': targetTotalBitrate, 
        'f'  : 'mp4'})]}, overwrite=True)
kesh
  • 4,515
  • 2
  • 12
  • 20
  • I am aware of the -an option, but I don't know how to add that into my code, as the documentation is just for ffmpeg not ffmpeg-python. – Alex.Foster Feb 14 '22 at 12:25
  • It's on [their GitHub](https://github.com/kkroening/ffmpeg-python/issues/68) – kesh Feb 14 '22 at 15:20
  • I have written like this, which is how the github suggests, and it still doesnt work. `else: ffmpeg.output(i, videoFileName,**{'c:v': 'libx264', 'b:v': targetTotalBitrate, 'pass': 2,'f' :'mp4'}).global_args('-an').overwrite_output().run()` – Alex.Foster Feb 14 '22 at 17:26
  • How about `ffmpeg.output(i, videoFileName,**{'c:v': 'libx264', 'an':None, 'b:v': targetTotalBitrate, 'pass': 2,'f' :'mp4'})`? (`-an` is an output option not global option) – kesh Feb 14 '22 at 17:39
  • Added alternate solution with `ffmpegio` library if interested – kesh Feb 14 '22 at 17:53
  • Dude the 'an' :None worked. Thanks so much – Alex.Foster Feb 14 '22 at 17:59