After reading this topic I was curious if this can be done directly with the help of Microsoft Powershell and FFmpeg.
Needed steps:
a) Reading the existing XML data file (in this case it is an exported NFO from TinyMediaManager)
b) Extracting selected data
c) Assign selected data to mp4 tag
d) Writing the tags into the mp4 movie
This is the very basic Powershell code that can achieve that.
(It contains example code for directly reading and assigning single occurences of data like the TITLE or SEASON.
It contains examples for loops to read multiple occurences of data like for ARTIST or NETWORK.
It contains the FFmpeg writing code to add this metadata into the mp4.)
$xmlContent = [xml](Get-Content -Path ".\demo.xml" -Encoding UTF8)
$name_array = @()
$studio_array = @()
$title = $xmlContent.episodedetails.title
$originaltitle = $xmlContent.episodedetails.originaltitle
$showtitle = $xmlContent.episodedetails.showtitle
$season = $xmlContent.episodedetails.season
$episode = $xmlContent.episodedetails.episode
foreach ($actor in $xmlContent.episodedetails.actor) {
$name_array += $actor.name + " (R: " + $actor.role + ")"
}
foreach ($studio in $xmlContent.episodedetails.studio) {
$studio_array += $studio
}
.\ffmpeg.exe -i "Test.mp4" `
-metadata artist=$name_array `
-metadata title=$showtitle `
-metadata copyright=MyCopyright `
-metadata date=2025 `
-metadata episode_id="123456" `
-metadata episode_number=5 `
-metadata episode_sort=$episode `
-metadata hd_video=0 `
-metadata genre="Animation" `
-metadata media_type="10" `
-metadata network=$studio_array `
-metadata season_number=$season `
-metadata show=$originaltitle `
-codec copy Mp4_with_Metadata.mp4
It does NOT contain code to read and apply several mp4's one after the other
It does NOT contain code to detect multiple variants of *.xml names.
It does NOT contain the finetuning for the separators between the actor name and his role (for example to suppress it, if the role is unknown).
It does NOT contain every possible tag that you can add to mp4 files.
This is just example code as a starting point.
Maybe this can help interested readers to apply existing XML/NFO directly into mp4 files.
Warning: Please test it carefully with COPIES of your movies ![]()