Open CXwudi opened 4 days ago
PoC finished, here is the implementation route:
Extraction: ffmpeg -i .\【初音ミク】こころのキラリ【shishy】[661223]-pv.mkv -vn -acodec copy .\【初音ミク】こころのキラリ【shishy 】.mka
.
Tagging: mkvpropedit.exe '.\【初音ミク】こころのキラリ【shishy】.mka' --tags all:tag.xml
Where tag-file.xml
specification can be found in:
https://www.matroska.org/technical/elements.html (see Tagging section) https://www.matroska.org/technical/tagging.html
Here is a sample XML file from GPT-4o:
<?xml version="1.0" encoding="UTF-8"?>
<Tags>
<!-- Tag for the whole file -->
<Tag>
<Targets>
<TargetTypeValue>50</TargetTypeValue>
</Targets>
<Simple>
<Name>ENCODER</Name>
<String>Lavf61.1.100</String>
</Simple>
<Simple>
<Name>CUSTOM TAG</Name>
<String>Wudi</String>
</Simple>
</Tag>
<!-- Tag for the artist and date recorded -->
<Tag>
<Targets>
<TargetTypeValue>30</TargetTypeValue>
</Targets>
<Simple>
<Name>ARTIST</Name>
<String>some artist</String>
<TagLanguage>und</TagLanguage>
<DefaultLanguage>1</DefaultLanguage>
</Simple>
<Simple>
<Name>DATE_RECORDED</Name>
<String>2024</String>
<TagLanguage>und</TagLanguage>
<DefaultLanguage>1</DefaultLanguage>
</Simple>
<Simple>
<Name>CUSTOM TAG 2</Name>
<String>Wudi 2</String>
</Simple>
</Tag>
<!-- Tag for the title -->
<Tag>
<Targets>
<TargetTypeValue>30</TargetTypeValue>
</Targets>
<Simple>
<Name>TITLE</Name>
<String>some title</String>
<TagLanguage>und</TagLanguage>
<DefaultLanguage>1</DefaultLanguage>
</Simple>
</Tag>
</Tags>
To add cover image, an extra command is needed: mkvpropedit.exe '.\【初音ミク】こころのキラリ【shishy】.mka' --attachment-name "cover.webp" --attachment-mime-type "image/webp" --attachment-description "cover image" --add-attachment .\【初音ミク】こころのキラリ【shishy】[661223]-thumbnail.webp
Be aware that we need to detect the mime-type, we can reuse mediainfo we already have
Looks like Mka can be a versatile container for any audio format. Hence, we can use mka
as the fallback for any other unrecognized format.
Matroska is not supported in mutagen https://github.com/quodlibet/mutagen/issues/3, so no need to think about workaround in python
When downloading videos from https://vocadb.net/L/15285, we encountered a new audio format that was never seen before
【初音ミク】こころのキ ラリ【shishy】.zip
Here is the MediaInfo: