各コーデックのタイプまたはコーデックのタイプリストには、最後に約 500 のコーデックがあります。たとえば、最初のリストに次のように表示されます。
オーディオ mpeha mpegv ..... ビデオ xvid divx
等々。
コーデックのリストを取得する最初の 2 つの関数は C にあります。
const char* Encoder_GetNextCodecName()
{
current_codec = av_codec_next(current_codec);
while (current_codec != NULL)
{
return current_codec->name;
}
return "";
}
const char* Encoder_GetFirstCodecName()
{
current_codec = NULL;
return Encoder_GetNextCodecName();
}
次に、ヘッダーファイルがあります:
const char* Encoder_GetNextCodecName();
const char* Encoder_GetFirstCodecName();
次に、リストを作成する別の C++ ヘッダー ファイル:
List<String^> ^GetCodecs()
{
List<String^> ^l = gcnew List<String^>;
String ^s = gcnew String(Encoder_GetFirstCodecName());
while (!String::IsNullOrEmpty(s))
{
l->Add(s);
s = gcnew String(Encoder_GetNextCodecName());
}
return l;
}
次に、私が CSHARP でこれを行っているとき:
List<string> l = new List<string>(f.GetCodecs());
変数 l に 506 コーデックの . コーデックはffmpegです!!!
Cファイルには次のようなものもあります:
current_codec->type
多くのプロパティがあります。また、Cファイルには次のようなものもあります:
AVMediaType::
これにより、コーデックのタイプの 7 つのカテゴリが得られます。
問題は、オーディオ、ビデオ、データなどの各コーデックまたはコーデックの各グループのタイプを持つリストを作成するときに、C++ ヘッダー ファイルでどのように作成するかです。
編集
これは、C 関数と CLI を接続する別のヘッダー ファイルです。
最初に C から関数を呼び出す別のヘッダー ファイルがあります。
ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
bool Encoder_MoveToNextCodec();
bool Encoder_MoveToFirstCodec();
const char* Encoder_GetCurrentCodecName();
int Encoder_GetCurrentCodecType();
#ifdef __cplusplus
} // extern "C"
#endif
これは私のCLIコードです:
#pragma once
// FFMPEG_WRAPPER.cpp : Defines the exported functions for the DLL application.
//
#include "ENCODER.h"
#include <stdlib.h>
#include <string.h>
#include <msclr\marshal.h>
#include <vcclr.h>
#include <cstdlib>
#include <Windows.h>
using namespace System;
using namespace System::Drawing;
using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices;
using namespace System::Drawing::Imaging;
using namespace msclr::interop;
namespace MyVideo
{
public ref class FFMPEGWrapper
{
public:
FFMPEGWrapper(void)
{
Encoder_init();
}
ref class CodecInfo
{
public:
String^ CodecName;
int CodecType;
};
List<CodecInfo^> ^GetCodecs()
{
List<CodecInfo^> ^l = gcnew List<CodecInfo^>;
bool KeepLooping = Encoder_MoveToFirstCodec();
while (KeepLooping)
{
CodecInfo ^codec = gcnew CodecInfo();
codec->CodecName = gcnew String(Encoder_GetCurrentCodecName());
codec->CodecType = Encoder_GetCurrentCodecType();
l->Add(codec);
KeepLooping = Encoder_MoveToNextCodec();
}
return l;
}
次に、CSHARP で次のことを行いました。
List<f.CodecInfo> l = f.GetCodecs();
しかし、CodecInfo が存在せず、GetCodecs() でエラーが発生します。
エラー 1 型 'System.Collections.Generic.List' を 'System.Collections.Generic.List' に暗黙的に変換できません
エラー 2 「ScreenVideoRecorder.Form1.f」は「フィールド」ですが、「タイプ」のように使用されています
エラーが CSHARP にある問題。