ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

Adding metadata

Open AzazelHD opened this issue 2 years ago • 1 comments

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?

AzazelHD avatar May 24 '22 16:05 AzazelHD

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.

McTwist avatar Sep 12 '22 15:09 McTwist