ffmpeg: edit metadata and automatically increment

2019-03-03 11:38发布

问题:

This PowerShell code divides a large audio file (sound1) in 5 minutes parts and saves them as sound100_1.mp3, sound1_002.mp3...

ffmpeg -i $file_name_complete -f segment -segment_time 300 -c copy $fileNameOnly"_"%03d$fileExtensionOnly
  • How can I set the metadata title to be the same than the file name?

  • And how can I also (on the same time) edit the Album metadata with an incremental name (it's useless, but it's to understand how that work). It should be alb_1, alb_2.

I have seen on the docs that I should use:

-metadata title="my title"

But:

  • should I repeat each time -metadata for each metadata? EDIT: yes according to this

  • how can I increment the number since the title need to be quoted (-metadata title="$fileNameOnly""_"%03d won't work since the last quote is missing)

  • how can I set the title field so it take the same value than the Name?


This did not work:

ffmpeg -i $file_name_complete -f segment -segment_time 300 
       -metadata title="$fileNameOnly""_"%03d album="test" 
       -c copy $fileNameOnly"_"%03d$fileExtensionOnly

I get this error:

-metadata : The term '-metadata' is not recognized as the name of a cmdlet