Closed ldenoue closed 1 year ago
After writing to video file finishes, for example, in StopRecording
function after Encoder_Stop(&gEncoder);
call, you can add there following code to set custom title:
IPropertyStore* PropStore;
if (SUCCEEDED(SHGetPropertyStoreFromParsingName(gRecordingPath, NULL, GPS_READWRITE, &IID_IPropertyStore, &PropStore)))
{
PROPVARIANT Title = { .vt = VT_LPWSTR, .pwszVal = L"My Custom Video Title" };
HR(IPropertyStore_SetValue(PropStore, &PKEY_Title, &Title));
HR(IPropertyStore_Commit(PropStore));
IPropertyStore_Release(PropStore);
}
Add #include <propkey.h>
on top.
This works very well, thank you so much for getting me on the right track.
Laurent
@mmozeiko It seems limited to writing 255 characters. Do you know if there's a way to write longer text in the PROPVARIANT
or is it a limitation of the MP4 metadata field?
I don't think there are any limits for mp4 or PROPVARIANT. If anything then that is limitation of IPropertyStore
implementation.
Well, my dirty hack is just to append my text data to the MP4 file and my app is able to ready that back (it starts with a special text). I couldn't find any C library that I could easily use from the existing code.
I saw we could use
SHGetPropertyStoreFromParsingName
to add metadata to the recording, but can't figure how to actually code this. Any idea?