r/ffmpeg•
DSMars

Help with command to strip metadata

Hi FFMPEG experts!

I am looking for some advice, I am getting confused with the documentation and nothing I try is working so I am hoping one of you can assist with the command I need.

I have a PowerShell script to find new video files since it was last ran and replace the metdata title and comments with the Episode title and episode overview.

#$command = "$ffmpegPath -i `"$($video.FullName)`" -metadata title=`"$($video.Name)`" -metadata comment=`"$overview`" -map_metadata -1 -c copy `"$outputFile`""

This works but I noticed it is setting the Languages for Subtitles and Audio to unknown instead of whatever was there before.

I then tried this command

#$command = "$ffmpegPath -i `"$($video.FullName)`" -metadata title=`"$($video.Name)`" -metadata comment=`"$overview`" -map_metadata -1 -c copy -c:v copy -c:a copy -c:s copy `"$outputFile`""

But had the same issue.

I then tried

$command = "$ffmpegPath -i `"$($video.FullName)`" -map 0 -metadata:s:v title=`"$($video.Name)`" -metadata:s:v comment=`"$overview`" -c:v copy -c:a copy -c:s copy `"$outputFile`""

Same issue

I have tried various variations of this sometimes it keeps the language and audio but doesn't set the title or comments fields, other times it sets them but clears the language fields and I am pulling my hair out!

​

Any help appreciated.

Posted Feb 27, 2023, 10:22 AM UTC

13
bayarookie1•

-map_metadata -1 removes all metadata, so just add or replace metadata in container:

ffmpeg -i in -map 0 -c copy -metadata title="tit" -metadata comment="com" out

1
DSMarsOP•

ffmpeg -i in -map 0 -c copy -metadata title="tit" -metadata comment="com" out

thanks I set it to

$command = "$ffmpegPath -i `"$($video.FullName)`" -map 0 -c copy -metadata title=`"$($video.Name)`" -metadata comment=`"$overview`" `"$outputFile`""

which seems to keep the language but now the comments aren't being cleared and set to what I want. Oh well one step forward and 1 back!

1
bayarookie1•

Erase tags of stream with empty string -metadata:s:0 comment="" where 0 is number of output stream, same for container tags -metadata comment=""

1