将视频流保存为asf文件,但是请问设置asf文件视频图像的宽度和高度的接口指针是什么??

aoosang 2005-01-31 10:15:40
如题
...全文
556 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
aoosang 2005-02-02
  • 打赏
  • 举报
回复
希望对后面遇到同样问题的兄弟们有个帮助,下面我要结贴了,再次感谢陆,蒋两位老大
aoosang 2005-02-02
  • 打赏
  • 举报
回复
ok,问题已经解决,谢谢蒋兄和 陆兄的指点 ,解决的方法,我找到了系统的profile,并且手动修改了系统的profile, Directshow自己带的profile放在WINNT目录下,名字叫WMSysPr9.prx.dshow所用到的profile 都在这个文件里,采用的XML格式,下面我给出一个profile的格式

摘录了一个profile ,

<profile version="458752"
name="Video for dial-up modems or LAN (28.8 to 100 Kbps)"
guid="{07DF7A25-3FE2-4A5B-8B1E-348B0721CA70}"
description="Use this multiple bit rate profile for target audiences with a dial-up modem, LAN, or dual-channel ISDN connection (bandwidths between 28.8 to 100 Kbps).">
<streamconfig majortype="{73647561-0000-0010-8000-00AA00389B71}"
streamnumber="1"
streamname="Audio Stream"
inputname="Audio"
bitrate="8000"
bufferwindow="-1">
<wmmediatype subtype="{00000161-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="1"
btemporalcompression="0"
lsamplesize="64">
<waveformatex wFormatTag="353"
nChannels="1"
nSamplesPerSec="8000"
nAvgBytesPerSec="1000"
nBlockAlign="64"
wBitsPerSample="16"
codecdata="00220000000000000000"/>
</wmmediatype>
</streamconfig>
<streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="2"
streamname="Video Stream"
inputname="Video"
bitrate="7062"
bufferwindow="-1">
<videomediaprops maxkeyframespacing="80000000"
quality="0"/>
<wmmediatype subtype="{31564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
<videoinfoheader dwbitrate="7062"
dwbiterrorrate="0"
avgtimeperframe="666666">
<rcsource left="0"
top="0"
right="176"
bottom="144"/>
<rctarget left="0"
top="0"
right="176"
bottom="144"/>
<bitmapinfoheader biwidth="176"
biheight="144"
biplanes="1"
bibitcount="24"
bicompression="WMV1"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
</videoinfoheader>
</wmmediatype>
</streamconfig>
<streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="3"
streamname="Video Stream"
inputname="Video"
bitrate="11338"
bufferwindow="-1">
<videomediaprops maxkeyframespacing="80000000"
quality="0"/>
<wmmediatype subtype="{31564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
<videoinfoheader dwbitrate="11338"
dwbiterrorrate="0"
avgtimeperframe="666666">
<rcsource left="0"
top="0"
right="176"
bottom="144"/>
<rctarget left="0"
top="0"
right="176"
bottom="144"/>
<bitmapinfoheader biwidth="176"
biheight="144"
biplanes="1"
bibitcount="24"
bicompression="WMV1"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
</videoinfoheader>
</wmmediatype>
</streamconfig>
<streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="4"
streamname="Video Stream"
inputname="Video"
bitrate="23970"
bufferwindow="-1">
<videomediaprops maxkeyframespacing="80000000"
quality="0"/>
<wmmediatype subtype="{31564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
<videoinfoheader dwbitrate="23970"
dwbiterrorrate="0"
avgtimeperframe="666666">
<rcsource left="0"
top="0"
right="176"
bottom="144"/>
<rctarget left="0"
top="0"
right="176"
bottom="144"/>
<bitmapinfoheader biwidth="176"
biheight="144"
biplanes="1"
bibitcount="24"
bicompression="WMV1"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
</videoinfoheader>
</wmmediatype>
</streamconfig>
<streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="5"
streamname="Video Stream"
inputname="Video"
bitrate="87127"
bufferwindow="-1">
<videomediaprops maxkeyframespacing="80000000"
quality="0"/>
<wmmediatype subtype="{31564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0">
<videoinfoheader dwbitrate="87127"
dwbiterrorrate="0"
avgtimeperframe="666666">
<rcsource left="0"
top="0"
right="176"
bottom="144"/>
<rctarget left="0"
top="0"
right="176"
bottom="144"/>
<bitmapinfoheader biwidth="176"
biheight="144"
biplanes="1"
bibitcount="24"
bicompression="WMV1"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/>
</videoinfoheader>
</wmmediatype>
</streamconfig>
<mutualexclusion type="{D6E22A01-35DA-11D1-9034-00A0C90349BE}">
<stream number="2"/>
<stream number="3"/>
<stream number="4"/>
<stream number="5"/>
</mutualexclusion>
</profile>
蒋晟 2005-02-02
  • 打赏
  • 举报
回复
不要用系统的profile,自己建一个profile
aoosang 2005-02-01
  • 打赏
  • 举报
回复
还有diectshow自带的profile都放在那个文件夹下? 我想看看是否修改成功,

另: 我已经试过了,效果不明显,我怀疑是否真正修改了profile,所以想查看一下
happydeer 2005-02-01
  • 打赏
  • 举报
回复
wm asf writer默认使用的是v8的系统Profile,他的视频大小都是 320 x 240这么大小的。可以通过IConfigAsfWriter::GetCurrentProfile获得Profile对象,然后按你的要求修改,正如你描述的那样。(你为什么不按你的想法试一下,如果碰到问题再把问题贴出来。)

另外一个办法,就是使用windows media format sdk自己来创建一个profile,然后通过wm asf writer的IConfigAsfWriter::ConfigureFilterUsingProfile设置,这种方式可以使用最新的9系列的编解码器(系统Profile只能使用v8的编解码器)。

profile的创建可以参考wmf sdk 9的例子:wmgenprofile。
aoosang 2005-02-01
  • 打赏
  • 举报
回复

谢谢蒋老大,下面我详细描述一下我的问题,

我用dshow带的一个filter (pushsource)来捕捉全屏幕,然后写入asf文件,遇到的问题是asf文件回放的时候,画面大小为320*240,如果拖动放大全屏播放,失真太厉害.后来我将pushSource Filter的拷贝屏幕的区域限定为320*240,asf文件播放正常.我才知道可能是写入asf文件时限定了图像的大小,所以我现在想通过修改profile来修改asf文件的视频大小(高度和宽度),我不知道我是否可以通过修改系统配置的profile达到目的?还是我必须自己要重新生成自己的profile? 还有diectshow自带的profile都放在那个文件夹下?
我用下面的代码修改asf 文件的图像的高度和宽度是否可行?
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>mediaType.pbFormat);
// 在这里重新设置视频流的属性
pVih->bmiHeader.biWidth=1024;
pVih->bmiHeader.biHeight=768;
蒋晟 2005-02-01
  • 打赏
  • 举报
回复
改了长宽之后WM_MEDIA_TYPE的lSampleSize;WMVIDEOINFOHEADER的rcSource,rcTarget,dwBitRate和bmiHeader应该都要改
aoosang 2005-02-01
  • 打赏
  • 举报
回复
IWMProfile *ppProfile;
pAsfConfig->GetCurrentProfile (&ppProfile);

IWMStreamConfig* ppConfig;
ppProfile->GetStream(0,&ppConfig); //获取视频流的
/////设置视频流的属性
IWMMediaProps *pMediaProps;
ppConfig->QueryInterface(IID_IWMMediaProps,(void**)(&pMediaProps));
WM_MEDIA_TYPE mediaType;
DWORD bufsize;
pMediaProps->GetMediaType(NULL,&bufsize);
pMediaProps->GetMediaType(&mediaType,&bufsize);

VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(mediaType.pbFormat);

// 在这里重新设置视频流的属性
pVih->bmiHeader.biWidth=1024;
pVih->bmiHeader.biHeight=768;
pMediaProps->SetMediaType(&mediaType);


陆兄看看上面设置图像的大小的一段代码是否正确?
pVih->bmiHeader.biWidth=1024;
pVih->bmiHeader.biHeight=768;
RunningYang 2005-02-01
  • 打赏
  • 举报
回复
顶一下
happydeer 2005-01-31
  • 打赏
  • 举报
回复
视频的格式细节是由媒体类型来描述的。你可以从IWMStreamConfig接口查询获得IWMMediaProps接口,然后调用GetMediaType、SetMediaType去调整视频的宽度和高度。
aoosang 2005-01-31
  • 打赏
  • 举报
回复
希望朋友们帮忙
aoosang 2005-01-31
  • 打赏
  • 举报
回复
下面是IWMStreamConfig接口的所有函数,我只看到如何调整bitrate,但是那个函数使用调整视频流的图像的高度和宽度啊,老大,继续指示
Method Description
GetBitrate Retrieves the bit rate for the stream.
GetBufferWindow Retrieves the maximum latency between when a stream is received and when it begins to be displayed.

GetConnectionName Retrieves the connection name given to the stream.
GetStreamName Retrieves the stream name.
GetStreamNumber Retrieves the stream number.
GetStreamType Retrieves the major type of the stream (audio, video, or script).
SetBitrate Specifies the bit rate for the stream.
SetBufferWindow Specifies the maximum latency between when a stream is received and when it begins to be displayed.

SetConnectionName Specifies the connection name given to a stream.
SetStreamName Specifies the stream name.
SetStreamNumber Specifies the stream number.
happydeer 2005-01-31
  • 打赏
  • 举报
回复
要通过Profile去设置。

Profile对象的接口IProfile,它内部的流配置子对象IWMStreamConfig。
aoosang 2005-01-31
  • 打赏
  • 举报
回复
楼上的你问我还是问陆老大啊?我还是一个裤衩呢
yyhzpk 2005-01-31
  • 打赏
  • 举报
回复
弱弱问一下:
asf 的网上播放和定位速度
好像很慢,有很大的延迟,我现在还不明白为什么要用
这些格式,它有那些好处,
aoosang 2005-01-31
  • 打赏
  • 举报
回复
ok,谢谢陆兄的指点,我也是这么做的,见代码,其中pAsfConfig是从asfwriter指针获取的.
IWMProfile *ppProfile;
pAsfConfig->GetCurrentProfile (&ppProfile);

IWMStreamConfig* ppConfig;
ppProfile->GetStream(0,&ppConfig); //获取视频流的
/////设置视频流的属性
IWMMediaProps *pMediaProps;
ppConfig->QueryInterface(IID_IWMMediaProps,(void**)(&pMediaProps));
WM_MEDIA_TYPE mediaType;
DWORD bufsize;
pMediaProps->GetMediaType(NULL,&bufsize);
pMediaProps->GetMediaType(&mediaType,&bufsize);
////////////////////////
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(mediaType.pbFormat);
在这里重新设置视频流的属性
.........
//////////////////////////
pMediaProps->SetMediaType(&mediaType);


我想通过pVih指针设置视频的大小,VIDEOINFOHEADER结构如下:

typedef struct tagVIDEOINFOHEADER {
RECT rcSource,
RECT rcTarget;
DWORD dwBitRate;
DWORD dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
BITMAPINFOHEADER bmiHeader;
} VIDEOINFOHEADER;

因为我看到BITMAPINFOHEADER 结构有两个成员
LONG biWidth;
LONG biHeight;
不知道是否通过这bmiHeader的两个变量来设置视频的宽度和高度,???
另:我通过查看GetMediaType返回的媒体类型,发现biWidth和 biHeight都是零?怎么解释啊?
还请陆兄再次指教



附:BITMAPINFOHEADER结构
typedef struct tagBITMAPINFOHEADER {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
qrlvls 2005-01-31
  • 打赏
  • 举报
回复

2,542

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧