获取镜头路径后效果sdk的问题 [英] Trouble getting footage path after effects sdk

查看:414
本文介绍了获取镜头路径后效果sdk的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后效应sdk有问题。
基本上,我循环通过所有的镜头项目项目,并试图从他们的镜头路径。这里是我在循环中的代码。

Having trouble with the after effects sdk. Basically I'm looping through all of the footage project items and trying to get the footage path from them. Here's the code I have inside of the loop.

AEGP_ItemType itemType = NULL;
ERR(suites.ItemSuite6()->AEGP_GetNextProjItem(projH, itemH, &itemH));
if (itemH == NULL) {
  break;
}
ERR(suites.ItemSuite6()->AEGP_GetItemType(itemH, &itemType));
if (itemType == AEGP_ItemType_FOOTAGE) {
          numFootage++;
          AEGP_FootageH footageH;
          ERR(suites.FootageSuite5()->AEGP_GetMainFootageFromItem(itemH, &footageH));
          A_char newItemName[AEGP_MAX_ITEM_NAME_SIZE] = {""};
          wchar_t footagePath[AEGP_MAX_PATH_SIZE];
          ERR(suites.ItemSuite6()->AEGP_GetItemName(itemH, newItemName));
          AEGP_MemHandle pathH = NULL;
          ERR(suites.FootageSuite5()->AEGP_GetFootagePath(footageH, 0, AEGP_FOOTAGE_MAIN_FILE_INDEX, &pathH));
          ERR(suites.MemorySuite1()->AEGP_LockMemHandle(pathH, reinterpret_cast<void**>(&footagePath)));
          std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
          const std::string utf8_string = converter.to_bytes(footagePath);
          std::ofstream tempFile;
          tempFile.open ("C:\\temp\\log1.txt");
          tempFile << utf8_string;
          tempFile.close();
          ERR(suites.MemorySuite1()->AEGP_UnlockMemHandle(pathH));
          ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(pathH));
}

我正在获取footagePath

I'm getting the footagePath

然后我将UTF-16(wchar_t)指针转换为UTF-8字符串

I then convert the UTF-16 (wchar_t) pointer to a UTF-8 string

它总是输出以下内容。

펐㛻

我可以请一些指导吗?谢谢!

Can I please have some guidance on this? Thanks!

推荐答案

我能够找出答案。
http://forums.adobe.com/message/5112560#5112560

这是错误的。
这是因为执行代码在一个循环中,并且我没有使用new操作符分配字符串。

This is what was wrong. It was because the executing code was in a loop and I wasn't allocating strings with the new operator.

这是需要一个新的它。
wchar_t footagePath [AEGP_MAX_PATH_SIZE];

This was the line that needed a new on it. wchar_t footagePath[AEGP_MAX_PATH_SIZE];

有用的信息是,不是所有素材项目都有路径。

Another piece of information that would have been useful to know is that not ALL footage items have paths.

如果没有路径,它将返回空字符串。
这是我最终得到的代码。

If the don't have a path it will return empty string. This is the code I ended up with.

if (itemType == AEGP_ItemType_FOOTAGE) {
          A_char* newItemName = new A_char[AEGP_MAX_ITEM_NAME_SIZE];
          ERR(suites.ItemSuite6()->AEGP_GetItemName(newItemH, newItemName));
          AEGP_MemHandle nameH = NULL;
          AEGP_FootageH footageH = NULL;
          char* footagePathStr = new char[AEGP_MAX_PATH_SIZE];
          ERR(suites.FootageSuite5()->AEGP_GetMainFootageFromItem(newItemH, &footageH));
          if (footageH) {
                            suites.FootageSuite5()->AEGP_ GetFootagePath(footageH, 0, AEGP_FOOTAGE_MAIN_FILE_INDEX, &nameH);
                            if(nameH) {
                                       tries++;
                                       AEGP_MemSize size = 0;
                                       A_UTF16Char *nameP = NULL;
                                       suites.MemorySuite1()->AEGP_GetMemHandleSize(nameH, &size);
                                       suites.MemorySuite1()->AEGP_LockMemHandle(nameH, (void **)&nameP);
                                       std::wstring test = L"HELLO";
                                       std::string output;
                                       int len = WideCharToMultiByte(CP_OEMCP, 0, (LPCWSTR)nameP, -1, NULL, 0, NULL, NULL);
                                       if (len > 1) {
                                                  footagePathStr = new char[len];
                                                  int len2 = WideCharToMultiByte(CP_OEMCP, 0, (LPCWSTR)nameP, -1, footagePathStr, len, NULL, NULL);
                                                  ERR(suites.MemorySuite1()->AEGP_UnlockMemHandle(nameH));
                                                  suites.MemorySuite1()->AEGP_FreeMemHandle(nameH);
                                       }
                            }
          }
}

这篇关于获取镜头路径后效果sdk的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆