mmozeiko / wcap

Small and efficient screen recording utility for Windows 10 and 11
The Unlicense
839 stars 35 forks source link

how to add a title to the generate MP4? [feature request] #19

Closed ldenoue closed 1 year ago

ldenoue commented 1 year ago

I saw we could use SHGetPropertyStoreFromParsingName to add metadata to the recording, but can't figure how to actually code this. Any idea?

mmozeiko commented 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.

ldenoue commented 1 year ago

This works very well, thank you so much for getting me on the right track.

Laurent

ldenoue commented 1 year ago

@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?

mmozeiko commented 1 year ago

I don't think there are any limits for mp4 or PROPVARIANT. If anything then that is limitation of IPropertyStore implementation.

ldenoue commented 1 year ago

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.