特定の出力属性、つまり出力サイズに .prx ファイルを使用するビデオ キャプチャ用のサード パーティ コントロールを使用しています。ユーザーの実際の画面サイズの比率を維持しながら、出力の高さと幅を可能な限り大きく設定しようとしています。
.prx ファイルは単なる XML ファイルだと思いますが、それを XMLDocument として開いて保存すると、Windows Media Encoder で開こうとすると、「プロファイルが無効です。(0xC00D0BC6)」というメッセージが表示されます。コードを実行する前に、同じファイルを問題なく開くことができました。
Dim prx As New XmlDocument()
prx.Load(Globals.appPath + prxFileName)
Dim prxWidth As XmlAttribute = prx.SelectSingleNode("/profile/streamconfig/wmmediatype/videoinfoheader/bitmadinfoheader/@biwidth")
Dim prxHeight As XmlAttribute = prx.SelectSingleNode("/profile/streamconfig/wmmediatype/videoinfoheader/bitmadinfoheader/@biheight")
prx.Save(Globals.appPath + prxFileName)
そのため、ファイルを実際に編集せずに XMLDocument として再保存すると、プロファイルは無効になります。プロファイルの有効性を維持しながらコードで .prx ファイルを編集する方法はありますか?
参考までに、テキスト エディターで開いた有効な .prx ファイルを以下に示します。
<profile version="589824"
storageformat="1"
name="myProfile"
description="">
<streamconfig majortype="{73647561-0000-0010-8000-00AA00389B71}"
streamnumber="1"
streamname="Audio Stream"
inputname="Audio409"
bitrate="48000"
bufferwindow="3000"
reliabletransport="0"
decodercomplexity=""
rfc1766langid="en-us"
>
<wmmediatype subtype="{00000161-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="1"
btemporalcompression="0"
lsamplesize="1152">
<waveformatex wFormatTag="353"
nChannels="2"
nSamplesPerSec="32000"
nAvgBytesPerSec="6000"
nBlockAlign="1152"
wBitsPerSample="16"
codecdata="008800001F0000000000"/>
</wmmediatype>
</streamconfig>
<streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="2"
streamname="Video Stream"
inputname="Video409"
bitrate="400000"
bufferwindow="3000"
reliabletransport="0"
decodercomplexity="AU"
rfc1766langid="en-us"
>
<videomediaprops maxkeyframespacing="80000000"
quality="100"/>
<wmmediatype subtype="{33564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
<videoinfoheader dwbitrate="400000"
dwbiterrorrate="0"
avgtimeperframe="333333">
<rcsource left="0"
top="0"
right="2000"
bottom="562"/>
<rctarget left="0"
top="0"
right="2000"
bottom="562"/>
<bitmapinfoheader biwidth="2000"
biheight="562"
biplanes="1"
bibitcount="24"
bicompression="WMV3"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
</videoinfoheader>
</wmmediatype>
</streamconfig>
</profile>
この質問の助けを借りて、Video Capture output always in 320x240にもかかわらず、解像度を変更して、IWMStreamConfigを使用するように戦略を少し変更しました。
Dim profileData As String
Using reader As New StreamReader(File.OpenRead(Globals.appPath + prxFileName))
profileData = reader.ReadToEnd()
End Using
Dim profileManager As IWMProfileManager
Dim wmProfile As IWMProfile = Nothing
Dim hr As Integer = WMLib.WMCreateProfileManager(profileManager)
If hr >= 0 Then
hr = profileManager.LoadProfileByData(profileData, wmProfile)
End If
If profileManager IsNot Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(profileManager)
profileManager = Nothing
End If
Dim pConfig As IWMStreamConfig
wmProfile.GetStream("Video Stream", pConfig)
少なくとも IWMStreamConfig オブジェクトとしてストリームを取得したので、さらに近づいているように感じます。しかし、この MSDN 記事にあるように、BITMAPINFOHEADER.biHeight と BITMAPINFOHEADER.biWidth を編集するにはどうすればよいでしょうか。
http://msdn.microsoft.com/en-us/library/windows/desktop/dd756998(v=vs.85).aspx
SetBitRate と SetBufferWindow は InteliSense に表示されていますが、これらの下位レベルのプロパティにアクセスする方法がわかりません。