0

特定の出力属性、つまり出力サイズに .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 に表示されていますが、これらの下位レベルのプロパティにアクセスする方法がわかりません。

4

2 に答える 2

1

ファイルはユニコードです。具体的には、BOM コード 0xFFFE に基づくリトルエンディアン UTF-16。

.NET を使用しているように見えるので、FileStream を StreamWriter でラップしてみてください。

Dim FS As FileStream = New FileStream(prxFile, FileMode.CreateNew)
Dim SW As StreamWriter = New StreamWriter(FS, new UnicodeEncoding(false, true))

次に、文字列全体をファイルに書き込むことができます。

XmlDocument の Load/Save メソッドは、TextWriter を拡張する StreamWriter を取ります。エンコーディングを指定して同じ方法で作成するだけです。

于 2013-02-27T00:08:17.710 に答える
0

16進エディターでファイルを確認した後、有効なプロファイルは0x00各文字の間にあり、ファイルはで始まります0xFFFE。エンコードを想定しています。それが決まったら、ストリームリーダーを使用してテキストを文字列に読み込み、文字列操作で変更を加えました。

トリッキーな部分は、すべてをファイルに書き戻すことでした。何らかの理由で、最初の2つの16進文字をファイルに書き込もうとすると、それらは4つの異なる16進文字に変換されます。解決策は、FileStreamを使用してバイトごとに書き込むことでした。

//Read in the initial profile
Dim profileData As String
Using reader As New StreamReader(File.OpenRead(prxFile))
    profileData = reader.ReadToEnd()
End Using

//Make changes to the profile with string manipulation

//Write the changed data back to the file including all the Hex characters
File.Delete(prxFile)
Dim FS As FileStream = New FileStream(prxFile, FileMode.CreateNew)
//Start by writing 0xFFFE
FS.WriteByte(&HFF)
FS.WriteByte(&HFE)
//Then write each character succeeded by 0x00
For Each Character As Char In profileData.ToCharArray
    FS.WriteByte(AscW(Character))
    FS.WriteByte(&H0)
Next
FS.Close()
于 2012-11-28T19:57:17.907 に答える