ホーム › Media.MediaFoundation › MFCreateTranscodeTopology
MFCreateTranscodeTopology
関数ソースとプロファイルからトランスコード用トポロジを生成する。
シグネチャ
// MF.dll
#include <windows.h>
HRESULT MFCreateTranscodeTopology(
IMFMediaSource* pSrc,
LPCWSTR pwszOutputFilePath,
IMFTranscodeProfile* pProfile,
IMFTopology** ppTranscodeTopo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pSrc | IMFMediaSource* | in | トランスコード対象のソースファイルをカプセル化するメディアソースへのポインター。メディアソースオブジェクトは IMFMediaSource インターフェイスを公開しており、ソースリゾルバーを使用して作成できます。詳細については、Using the Source Resolver を参照してください。 |
| pwszOutputFilePath | LPCWSTR | in | 生成する出力ファイルの名前とパスを含む、null 終端文字列へのポインター。 |
| pProfile | IMFTranscodeProfile* | in | 音声ストリーム、映像ストリーム、およびファイルの書き込み先となるコンテナーの構成設定を含むトランスコードプロファイルへのポインター。トランスコードプロファイルオブジェクトは IMFTranscodeProfile インターフェイスを公開しており、MFCreateTranscodeProfile 関数を呼び出して作成する必要があります。オブジェクトの作成後、呼び出し元は適切な IMFTranscodeProfile メソッドを呼び出して構成設定を指定する必要があります。 |
| ppTranscodeTopo | IMFTopology** | out | トランスコードトポロジーオブジェクトの IMFTopology インターフェイスへのポインターを受け取ります。呼び出し元はこのインターフェイスを解放する必要があります。 |
戻り値の型: HRESULT
公式ドキュメント
部分的なトランスコードトポロジーを作成します。
戻り値
この関数は HRESULT を返します。可能な値には、次の表に示すものが含まれますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数呼び出しが成功し、ppTranscodeTopo がトランスコードトポロジーへのポインターを受け取りました。 | |
| pwszOutputFilePath に無効な文字が含まれています。 | |
| メディアソースで選択されているストリームがありません。 | |
| プロファイルに MF_TRANSCODE_CONTAINERTYPE 属性が含まれていません。 | |
| 1 つ以上のストリームについて、プロファイルで指定されたメディアタイプを受け入れるエンコーダーが見つかりません。 | |
| プロファイルが、メディアソース上で選択されたいずれのストリームに対してもメディアタイプを指定していません。 |
解説(Remarks)
この関数を使用するサンプルコードについては、次のトピックを参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MF.dll
#include <windows.h>
HRESULT MFCreateTranscodeTopology(
IMFMediaSource* pSrc,
LPCWSTR pwszOutputFilePath,
IMFTranscodeProfile* pProfile,
IMFTopology** ppTranscodeTopo
);[DllImport("MF.dll", ExactSpelling = true)]
static extern int MFCreateTranscodeTopology(
IntPtr pSrc, // IMFMediaSource*
[MarshalAs(UnmanagedType.LPWStr)] string pwszOutputFilePath, // LPCWSTR
IntPtr pProfile, // IMFTranscodeProfile*
IntPtr ppTranscodeTopo // IMFTopology** out
);<DllImport("MF.dll", ExactSpelling:=True)>
Public Shared Function MFCreateTranscodeTopology(
pSrc As IntPtr, ' IMFMediaSource*
<MarshalAs(UnmanagedType.LPWStr)> pwszOutputFilePath As String, ' LPCWSTR
pProfile As IntPtr, ' IMFTranscodeProfile*
ppTranscodeTopo As IntPtr ' IMFTopology** out
) As Integer
End Function' pSrc : IMFMediaSource*
' pwszOutputFilePath : LPCWSTR
' pProfile : IMFTranscodeProfile*
' ppTranscodeTopo : IMFTopology** out
Declare PtrSafe Function MFCreateTranscodeTopology Lib "mf" ( _
ByVal pSrc As LongPtr, _
ByVal pwszOutputFilePath As LongPtr, _
ByVal pProfile As LongPtr, _
ByVal ppTranscodeTopo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFCreateTranscodeTopology = ctypes.windll.mf.MFCreateTranscodeTopology
MFCreateTranscodeTopology.restype = ctypes.c_int
MFCreateTranscodeTopology.argtypes = [
ctypes.c_void_p, # pSrc : IMFMediaSource*
wintypes.LPCWSTR, # pwszOutputFilePath : LPCWSTR
ctypes.c_void_p, # pProfile : IMFTranscodeProfile*
ctypes.c_void_p, # ppTranscodeTopo : IMFTopology** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MF.dll')
MFCreateTranscodeTopology = Fiddle::Function.new(
lib['MFCreateTranscodeTopology'],
[
Fiddle::TYPE_VOIDP, # pSrc : IMFMediaSource*
Fiddle::TYPE_VOIDP, # pwszOutputFilePath : LPCWSTR
Fiddle::TYPE_VOIDP, # pProfile : IMFTranscodeProfile*
Fiddle::TYPE_VOIDP, # ppTranscodeTopo : IMFTopology** out
],
Fiddle::TYPE_INT)#[link(name = "mf")]
extern "system" {
fn MFCreateTranscodeTopology(
pSrc: *mut core::ffi::c_void, // IMFMediaSource*
pwszOutputFilePath: *const u16, // LPCWSTR
pProfile: *mut core::ffi::c_void, // IMFTranscodeProfile*
ppTranscodeTopo: *mut *mut core::ffi::c_void // IMFTopology** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MF.dll")]
public static extern int MFCreateTranscodeTopology(IntPtr pSrc, [MarshalAs(UnmanagedType.LPWStr)] string pwszOutputFilePath, IntPtr pProfile, IntPtr ppTranscodeTopo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MF_MFCreateTranscodeTopology' -Namespace Win32 -PassThru
# $api::MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)#uselib "MF.dll"
#func global MFCreateTranscodeTopology "MFCreateTranscodeTopology" sptr, sptr, sptr, sptr
; MFCreateTranscodeTopology pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo ; 戻り値は stat
; pSrc : IMFMediaSource* -> "sptr"
; pwszOutputFilePath : LPCWSTR -> "sptr"
; pProfile : IMFTranscodeProfile* -> "sptr"
; ppTranscodeTopo : IMFTopology** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "MF.dll"
#cfunc global MFCreateTranscodeTopology "MFCreateTranscodeTopology" sptr, wstr, sptr, sptr
; res = MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
; pSrc : IMFMediaSource* -> "sptr"
; pwszOutputFilePath : LPCWSTR -> "wstr"
; pProfile : IMFTranscodeProfile* -> "sptr"
; ppTranscodeTopo : IMFTopology** out -> "sptr"; HRESULT MFCreateTranscodeTopology(IMFMediaSource* pSrc, LPCWSTR pwszOutputFilePath, IMFTranscodeProfile* pProfile, IMFTopology** ppTranscodeTopo)
#uselib "MF.dll"
#cfunc global MFCreateTranscodeTopology "MFCreateTranscodeTopology" intptr, wstr, intptr, intptr
; res = MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
; pSrc : IMFMediaSource* -> "intptr"
; pwszOutputFilePath : LPCWSTR -> "wstr"
; pProfile : IMFTranscodeProfile* -> "intptr"
; ppTranscodeTopo : IMFTopology** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mf = windows.NewLazySystemDLL("MF.dll")
procMFCreateTranscodeTopology = mf.NewProc("MFCreateTranscodeTopology")
)
// pSrc (IMFMediaSource*), pwszOutputFilePath (LPCWSTR), pProfile (IMFTranscodeProfile*), ppTranscodeTopo (IMFTopology** out)
r1, _, err := procMFCreateTranscodeTopology.Call(
uintptr(pSrc),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszOutputFilePath))),
uintptr(pProfile),
uintptr(ppTranscodeTopo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFCreateTranscodeTopology(
pSrc: Pointer; // IMFMediaSource*
pwszOutputFilePath: PWideChar; // LPCWSTR
pProfile: Pointer; // IMFTranscodeProfile*
ppTranscodeTopo: Pointer // IMFTopology** out
): Integer; stdcall;
external 'MF.dll' name 'MFCreateTranscodeTopology';result := DllCall("MF\MFCreateTranscodeTopology"
, "Ptr", pSrc ; IMFMediaSource*
, "WStr", pwszOutputFilePath ; LPCWSTR
, "Ptr", pProfile ; IMFTranscodeProfile*
, "Ptr", ppTranscodeTopo ; IMFTopology** out
, "Int") ; return: HRESULT●MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo) = DLL("MF.dll", "int MFCreateTranscodeTopology(void*, char*, void*, void*)")
# 呼び出し: MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
# pSrc : IMFMediaSource* -> "void*"
# pwszOutputFilePath : LPCWSTR -> "char*"
# pProfile : IMFTranscodeProfile* -> "void*"
# ppTranscodeTopo : IMFTopology** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mf" fn MFCreateTranscodeTopology(
pSrc: ?*anyopaque, // IMFMediaSource*
pwszOutputFilePath: [*c]const u16, // LPCWSTR
pProfile: ?*anyopaque, // IMFTranscodeProfile*
ppTranscodeTopo: ?*anyopaque // IMFTopology** out
) callconv(std.os.windows.WINAPI) i32;proc MFCreateTranscodeTopology(
pSrc: pointer, # IMFMediaSource*
pwszOutputFilePath: WideCString, # LPCWSTR
pProfile: pointer, # IMFTranscodeProfile*
ppTranscodeTopo: pointer # IMFTopology** out
): int32 {.importc: "MFCreateTranscodeTopology", stdcall, dynlib: "MF.dll".}pragma(lib, "mf");
extern(Windows)
int MFCreateTranscodeTopology(
void* pSrc, // IMFMediaSource*
const(wchar)* pwszOutputFilePath, // LPCWSTR
void* pProfile, // IMFTranscodeProfile*
void* ppTranscodeTopo // IMFTopology** out
);ccall((:MFCreateTranscodeTopology, "MF.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}),
pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
# pSrc : IMFMediaSource* -> Ptr{Cvoid}
# pwszOutputFilePath : LPCWSTR -> Cwstring
# pProfile : IMFTranscodeProfile* -> Ptr{Cvoid}
# ppTranscodeTopo : IMFTopology** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFCreateTranscodeTopology(
void* pSrc,
const uint16_t* pwszOutputFilePath,
void* pProfile,
void* ppTranscodeTopo);
]]
local mf = ffi.load("mf")
-- mf.MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
-- pSrc : IMFMediaSource*
-- pwszOutputFilePath : LPCWSTR
-- pProfile : IMFTranscodeProfile*
-- ppTranscodeTopo : IMFTopology** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MF.dll');
const MFCreateTranscodeTopology = lib.func('__stdcall', 'MFCreateTranscodeTopology', 'int32_t', ['void *', 'str16', 'void *', 'void *']);
// MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
// pSrc : IMFMediaSource* -> 'void *'
// pwszOutputFilePath : LPCWSTR -> 'str16'
// pProfile : IMFTranscodeProfile* -> 'void *'
// ppTranscodeTopo : IMFTopology** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MF.dll", {
MFCreateTranscodeTopology: { parameters: ["pointer", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo)
// pSrc : IMFMediaSource* -> "pointer"
// pwszOutputFilePath : LPCWSTR -> "buffer"
// pProfile : IMFTranscodeProfile* -> "pointer"
// ppTranscodeTopo : IMFTopology** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFCreateTranscodeTopology(
void* pSrc,
const uint16_t* pwszOutputFilePath,
void* pProfile,
void* ppTranscodeTopo);
C, "MF.dll");
// $ffi->MFCreateTranscodeTopology(pSrc, pwszOutputFilePath, pProfile, ppTranscodeTopo);
// pSrc : IMFMediaSource*
// pwszOutputFilePath : LPCWSTR
// pProfile : IMFTranscodeProfile*
// ppTranscodeTopo : IMFTopology** out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Mf extends StdCallLibrary {
Mf INSTANCE = Native.load("mf", Mf.class);
int MFCreateTranscodeTopology(
Pointer pSrc, // IMFMediaSource*
WString pwszOutputFilePath, // LPCWSTR
Pointer pProfile, // IMFTranscodeProfile*
Pointer ppTranscodeTopo // IMFTopology** out
);
}@[Link("mf")]
lib LibMF
fun MFCreateTranscodeTopology = MFCreateTranscodeTopology(
pSrc : Void*, # IMFMediaSource*
pwszOutputFilePath : UInt16*, # LPCWSTR
pProfile : Void*, # IMFTranscodeProfile*
ppTranscodeTopo : Void* # IMFTopology** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFCreateTranscodeTopologyNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef MFCreateTranscodeTopologyDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final MFCreateTranscodeTopology = DynamicLibrary.open('MF.dll')
.lookupFunction<MFCreateTranscodeTopologyNative, MFCreateTranscodeTopologyDart>('MFCreateTranscodeTopology');
// pSrc : IMFMediaSource* -> Pointer<Void>
// pwszOutputFilePath : LPCWSTR -> Pointer<Utf16>
// pProfile : IMFTranscodeProfile* -> Pointer<Void>
// ppTranscodeTopo : IMFTopology** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFCreateTranscodeTopology(
pSrc: Pointer; // IMFMediaSource*
pwszOutputFilePath: PWideChar; // LPCWSTR
pProfile: Pointer; // IMFTranscodeProfile*
ppTranscodeTopo: Pointer // IMFTopology** out
): Integer; stdcall;
external 'MF.dll' name 'MFCreateTranscodeTopology';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFCreateTranscodeTopology"
c_MFCreateTranscodeTopology :: Ptr () -> CWString -> Ptr () -> Ptr () -> IO Int32
-- pSrc : IMFMediaSource* -> Ptr ()
-- pwszOutputFilePath : LPCWSTR -> CWString
-- pProfile : IMFTranscodeProfile* -> Ptr ()
-- ppTranscodeTopo : IMFTopology** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfcreatetranscodetopology =
foreign "MFCreateTranscodeTopology"
((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* pSrc : IMFMediaSource* -> (ptr void) *)
(* pwszOutputFilePath : LPCWSTR -> (ptr uint16_t) *)
(* pProfile : IMFTranscodeProfile* -> (ptr void) *)
(* ppTranscodeTopo : IMFTopology** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mf (t "MF.dll"))
(cffi:use-foreign-library mf)
(cffi:defcfun ("MFCreateTranscodeTopology" mfcreate-transcode-topology :convention :stdcall) :int32
(p-src :pointer) ; IMFMediaSource*
(pwsz-output-file-path (:string :encoding :utf-16le)) ; LPCWSTR
(p-profile :pointer) ; IMFTranscodeProfile*
(pp-transcode-topo :pointer)) ; IMFTopology** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFCreateTranscodeTopology = Win32::API::More->new('MF',
'int MFCreateTranscodeTopology(LPVOID pSrc, LPCWSTR pwszOutputFilePath, LPVOID pProfile, LPVOID ppTranscodeTopo)');
# my $ret = $MFCreateTranscodeTopology->Call($pSrc, $pwszOutputFilePath, $pProfile, $ppTranscodeTopo);
# pSrc : IMFMediaSource* -> LPVOID
# pwszOutputFilePath : LPCWSTR -> LPCWSTR
# pProfile : IMFTranscodeProfile* -> LPVOID
# ppTranscodeTopo : IMFTopology** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。