- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 ASF Writer 将原始 AVI 文件压缩为 WMV。我非常需要加快压缩速度。关于如何实现这一目标,有任何提示和最佳实践吗?降低/降低索引器的影响?任何隐藏压缩参数?
文件仅包含 RGB/24 位格式的视频,视频流的压缩级别在 200kbps 到 2000kbps 之间。
任何配置提示(使用 C++、C#、Delphi 等)
这是配置 WMV 编写器的代码部分(使用 DSPack)。
function CreateWMVWriter(VideoQuality, AudioQuality: Cardinal; videoInfo: PVideoInfoHeader; audioInfo: PWaveFormatEx; hasAudio: Boolean): IBaseFilter;
const
PROFILE_NAME = 'WMV AutoProfile';
// BUFFER_WINDOW = $FFFFFFFF; // auto buffer
BUFFER_WINDOW = 1000; // 1 second
MAX_KEY_FRAME_SPACING = 10000000; // 1 seconds
var
configWriter : IConfigAsfWriter;
profileManager : IWMProfileManager;
profile : IWMProfile;
stream : IWMStreamConfig;
mediaProps : IWMMediaProps;
vmediaProps : IWMVideoMediaProps;
pmt : PWMMediaType;
msize : Cardinal;
vih : PVideoInfoHeader;
wfe: PWaveFormatEx;
hr : HRESULT;
videoBitRate, audioBitRate: Cardinal;
width, height: Integer;
begin
videoBitRate := VideoQuality * 1000; // kbits
// create the profile
CheckDSError(WMCreateProfileManager(profileManager));
CheckDSError(profileManager.CreateEmptyProfile(WMT_VER_9_0, profile));
CheckDSError(profile.SetName(StringToOleStr(PROFILE_NAME)));
CheckDSError(profile.SetDescription(StringToOleStr(PROFILE_NAME)));
CheckDSError(profile.CreateNewStream(WMMEDIATYPE_Video, stream));
CheckDSError(stream.SetStreamName(StringToOleStr('Video')));
CheckDSError(stream.SetBitrate(videoBitRate));
CheckDSError(stream.SetBufferWindow(BUFFER_WINDOW));
// config video media type
stream.QueryInterface(IID_IWMMediaProps, mediaProps);
CheckDSError(mediaProps.GetMediaType(nil, msize));
GetMem(pmt, msize);
CheckDSError(mediaProps.GetMediaType(pmt, msize));
with pmt^ do
begin
majortype := WMMEDIATYPE_Video;
subtype := WMMEDIASUBTYPE_WMV3;
bFixedSizeSamples := True;
bTemporalCompression := True;
pUnk := nil;
vih := PVideoInfoHeader(pbFormat);
// copy video info header (the same as with the original - copy: rcSource, rcTarget, AvgTimePerFrame, biWidth, biHeight)
CopyMemory(vih, videoInfo, SizeOf(TVideoInfoHeader));
// set bit rate at the same value
vih.dwBitRate := videoBitRate;
// set new compression ('WMV3')
vih.bmiHeader.biCompression := MAKEFOURCC('W', 'M', 'V', '3');
end;
CheckDSError(mediaProps.SetMediaType(pmt));
FreeMem(pmt, msize);
// set media props
stream.QueryInterface(IID_IWMVideoMediaProps, vmediaProps);
CheckDSError(vmediaProps.SetQuality(100));
CheckDSError(vmediaProps.SetMaxKeyFrameSpacing(0));
// CheckDSError(vmediaProps.SetMaxKeyFrameSpacing(MAX_KEY_FRAME_SPACING));
// add video stream
CheckDSError(profile.AddStream(stream));
// add audio stream (if needed)
if hasAudio then
begin
CheckDSError(profile.CreateNewStream(WMMEDIATYPE_Audio, stream));
CheckDSError(stream.SetStreamName(StringToOleStr('Audio')));
audioBitRate := audioInfo.nSamplesPerSec * audioInfo.nChannels * audioInfo.wBitsPerSample;
CheckDSError(stream.SetBitrate(audioBitRate));
CheckDSError(stream.SetBufferWindow(BUFFER_WINDOW)); // auto
// config video media type
stream.QueryInterface(IID_IWMMediaProps, mediaProps);
CheckDSError(mediaProps.GetMediaType(nil, msize));
GetMem(pmt, msize);
hr := mediaProps.GetMediaType(pmt, msize);
with pmt^ do
begin
// uncompressed audio
majortype := WMMEDIATYPE_Audio;
subtype := WMMEDIASUBTYPE_PCM;
formattype := WMFORMAT_WaveFormatEx;
cbFormat := sizeof(TWaveFormatEx);
bFixedSizeSamples := True;
bTemporalCompression := False;
lSampleSize := audioInfo.nChannels * audioInfo.wBitsPerSample div 8;
pUnk := nil;
wfe := PWaveFormatEx(pbFormat);
// copy video info header (the same as with the original)
CopyMemory(wfe, audioInfo, SizeOf(TWaveFormatEx));
end;
CheckDSError(mediaProps.SetMediaType(pmt));
FreeMem(pmt, msize);
// add video stream
CheckDSError(profile.AddStream(stream));
end;
// create the writer
Result := AddFilterGUID(CLSID_WMAsfWriter, 'WmvWriter');
// config the writer
configWriter := Result as IConfigAsfWriter;
CheckDSError(configWriter.SetIndexMode(True));
CheckDSError(configWriter.ConfigureFilterUsingProfile(profile));
end;
最佳答案
我真的没有太多这方面的经验,但根据其他地方发布的内容,尝试设置 WMMEDIASUBTYPE_WVC1
而不是 WMMEDIASUBTYPE_WVC3
。信息收集自 here .
关于c# - 如何使用 ASF Writer 更快地压缩 WMV?有什么提示吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/800179/
我有一个函数可以将数据写入任何实现接口(interface)的对象,该接口(interface)使用 Write(b []byte) (n int, err error) 方法。现在在我的程序中,我写
我继承了一些 Java。我对其他类似 C 的语言有很多经验,但我对 Java 还是很陌生。在一个函数中,我的前任同时使用了 write()和 append() Writer 的方法类,但我不明白为什么
我继承了一些 Java。我对其他类似 C 的语言有很多经验,但我对 Java 还是很陌生。在一个函数中,我的前任同时使用了 write()和 append() Writer 的方法类,但我不明白为什么
假设这里唯一的区别是二进制读取器/写入器对字符串使用固定长度编码,因此可能效率较低,是否正确? 最佳答案 不存在大量其他差异,例如读取和写入行、编码...基本上是与文本相关的“帮助器”函数的负载。 关
在将有效负载发送到 Web 服务之前尝试将有效负载转换为 xml 时,我在 mule 独立版本 3.8.1 中遇到错误。 我的流程配置是这样的:
似乎有两种方法可以将 JSON 对象的内容写入编写器。我可以做 myWriter.write(myJSONObj.toString()); 或者 myJSONObj.write(myWriter);
这个问题已经有答案了: Should one call .close() on HttpServletResponse.getOutputStream()/.getWriter()? (6 个回答)
初始化记录器后: var Logger *log.Logger f, err := os.OpenFile("somefile", os.O_WRONLY|os.O_CREATE|os.O_APPEN
我正在开发一个网站,除其他外,它通过 Metaweblog API 提供博客。我已经让 API 与几个博客客户端一起工作得很好,但 Windows Live Writer 正在扼杀我。 我已经完成了网
我有一个在启动后异步运行的方法,使用 OutputStream 或 Writer 作为参数。 它充当 OutputStream 或 Writer 的记录适配器(这是我无法更改的第三方 API)。 如何
我正在使用 ruby version 1.9.3 并且在启动 thin server 时出现错误 /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1
我编辑了一个来自客户的文档,其中有一些亮点,然后决定删除评论中的亮点。 无论出于何种原因,该文档突出显示了许多项目符号和编号列表部分,当我尝试选择整个文档并将突出显示更改为“无填充”时,我无法还原这些
我正在读取 URL 的内容并将其写入文件,这按预期工作,但即使程序控制台显示多行,它也只写入一次。 代码: PrintWriter writer = new PrintWriter("the-file
在调用 XslCompiledTransform.Transform() 方法时出现此异常: The Writer is closed or in error state. 谁知道这是什么意思? 最佳
我试图制作一个系统,用于将 lua 编译脚本存储在内存中。问题是我不能做一个“lua_Writer”,变量字节码是空的。我使用 Luajit。在我的代码下方。 typedef struct {
我想将一些字符串写入文件。所以,我使用了 BufferedWriter 类。由于许多线程倾向于写入该文件,我想知道 write 和 writeLine 方法是否是原子的。 此外,我希望程序将输出写入多
我有一个套接字,我可以在其中写入一些字符数据和一些原始字节数据。对于字符数据,使用PrintWriter 更容易。对于原始字节数据,直接写入 OutputStream 会更容易。所以在我的代码中,我有
在 Golang 中是否可以将 string 转换为 io.Writer 类型? 我将在 fmt.Fprintf() 中使用此字符串,但我无法转换类型。 最佳答案 你不能写入 string,strin
我正在将数据框拧到 Excel 中。也许我做得不对, 当我使用此代码时: from datetime import datetime import numpy as np import pandas
我尝试导入 Control.Monad.Writer像这样的模块: import Control.Monad.Writer ghc版本 7.4.1 给出以下错误: Ambiguous module n
我是一名优秀的程序员,十分优秀!