ffmpeg-python
ffmpeg-python copied to clipboard
Adding metadata
Hi guys. Just a little question. I know u can pass **metadata_dict
as argument to set multiple metadata as u stated before, but why the keyword metadata
isnt needed?
def test(src, dst, **kwargs):
(
ffmpeg
.input(src).audio
.output(f'{dst}.mp3', **kwargs)
.overwrite_output()
.run()
)
With this small function, im trying to call it like this:
test("song.mp3", "Test1", map_metadata=-1, metadata={'metadata:g:0': f'title=hello', 'metadata:g:1': f'date=2000'})
But it is not working. However, if i remove the metadata
keyword and i call it like:
test("song.mp3", "Test1", map_metadata=-1, **{'metadata:g:0': f'title=hello', 'metadata:g:1': f'date=2000'})
It works.
Can someone explain me please?
Each parameter is an argument to be passed to ffmpeg. metadata
with your arguments would turn into -metadata={'metadata:g:0': f'title=hello', 'metadata:g:1': f'date=2000'}
. When you pass in the dictionary with **
you will "unpack" the dictionary, where each field will become its own named parameter passed to the function.