使用 QTKit 标记 QT 电影元数据

发布于 2024-11-26 00:16:24 字数 1903 浏览 0 评论 0原文

我正在尝试使用 QTKit 对某些视频文件进行一些元数据标记。我已经做好了标记以字符串作为值的原子的工作,但很难设置以 8 位整数作为参数的原子。以下是我现在从 Apple 文档和互联网上其他各种来源获得的信息:

-(void) setMediaKind: (NSString *) value
{
QTMetaDataRef   metaDataRef;
Movie           theMovie;
OSStatus        status;

theMovie = [movie quickTimeMovie];
status = QTCopyMovieMetaData (theMovie, &metaDataRef );
NSAssert(status == noErr,@"QTCopyMovieMetaData failed!");

if (status == noErr)
{
    int intValue = NSSwapHostIntToBig([(NSNumber *)value intValue]);
    UInt8 *dataValuePtr = (UInt8*)(&intValue);
    ByteCount dataSize = sizeof(int);

    if (dataValuePtr)
    {
        OSType key = 'stik';
        QTMetaDataItem outItem;
        status = QTMetaDataAddItem(metaDataRef,
                                   kQTMetaDataStorageFormatiTunes, 
                                   kQTMetaDataKeyFormatiTunesShortForm,
                                   (const UInt8 *)&key,
                                   sizeof(key),
                                   dataValuePtr,
                                   dataSize,
                                   kQTMetaDataTypeSignedIntegerBE,
                                   &outItem);
        NSAssert(status == noErr,@"QTMetaDataAddItem failed!");

        char langCodeStr[] = "en";
        status = QTMetaDataSetItemProperty(
                                           metaDataRef,
                                           outItem,
                                           kPropertyClass_MetaDataItem,
                                           kQTMetaDataItemPropertyID_Locale,
                                           strlen(langCodeStr) + 1,
                                           langCodeStr);
    }
}
}

因此,原子“stik”设置了 iTunes 中视频的类型。如果我想将视频指定为电视节目,我需要为其分配值 10。如果我向此方法发送@“10”,我不会收到任何错误,但视频文件也没有正确标记。

我确信我的部分问题是我跳过了学习 C 并直接学习 Objective C,所以当我必须像这样深入研究 C 时我遇到了问题。

I'm trying to do some metadata tagging to some video files using QTKit. I've got things down for tagging atom that take a string as their value, but having a hard time setting atoms that take an 8-bit integer as their argument. Here is what I got right now from Apple's Documentation and other various sources on the internet:

-(void) setMediaKind: (NSString *) value
{
QTMetaDataRef   metaDataRef;
Movie           theMovie;
OSStatus        status;

theMovie = [movie quickTimeMovie];
status = QTCopyMovieMetaData (theMovie, &metaDataRef );
NSAssert(status == noErr,@"QTCopyMovieMetaData failed!");

if (status == noErr)
{
    int intValue = NSSwapHostIntToBig([(NSNumber *)value intValue]);
    UInt8 *dataValuePtr = (UInt8*)(&intValue);
    ByteCount dataSize = sizeof(int);

    if (dataValuePtr)
    {
        OSType key = 'stik';
        QTMetaDataItem outItem;
        status = QTMetaDataAddItem(metaDataRef,
                                   kQTMetaDataStorageFormatiTunes, 
                                   kQTMetaDataKeyFormatiTunesShortForm,
                                   (const UInt8 *)&key,
                                   sizeof(key),
                                   dataValuePtr,
                                   dataSize,
                                   kQTMetaDataTypeSignedIntegerBE,
                                   &outItem);
        NSAssert(status == noErr,@"QTMetaDataAddItem failed!");

        char langCodeStr[] = "en";
        status = QTMetaDataSetItemProperty(
                                           metaDataRef,
                                           outItem,
                                           kPropertyClass_MetaDataItem,
                                           kQTMetaDataItemPropertyID_Locale,
                                           strlen(langCodeStr) + 1,
                                           langCodeStr);
    }
}
}

So the atom 'stik' sets the video's kind in iTunes. If I want to specify the video as a TV Show i'd need to assign it a value of 10. If I send @"10" to this method I don't get any errors but the video file isn't properly tagged either.

I'm sure part of my problem is I skipped learning C and went straight to Objective C so when I have to dive into C like this I have problems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文