不能使用sinkwriter从媒体基金会的MP4文件添加音频流 [英] can't add audio stream to MP4 file using sinkwriter from Media Foundation

查看:380
本文介绍了不能使用sinkwriter从媒体基金会的MP4文件添加音频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个星期,因为我试图让我的EN codeR作品...

It's been a week since I'm trying to make my encoder works...

所以的事情是:


  1. 我创建使用汇作家从MF文件。

  1. I create a file using the Sink Writer from MF.

我写我的所有的视频​​样本。

I write all my video sample.

- >(如果我停在那里,并调用完成方法,我能够读取使用VLC文件,但如果我这样做了波纹管的东西,该文件将被破坏)

--> (If I stop there and call the Finish methods, I'm able to read the file using VLC but if I do the bellow stuff, the file will be "corrupted")

我写我的所有音频采样。

I write all my audio sample.

我所说的完成功能,我得到一个HRESULT code说:因为所需的头部并没有提供给沉汇无法创建有效的输出文件。我完全理解错误,只是我不明白怎么解决的...

I call the finish function and I get a HRESULT code saying: "Sink could not create valid output file because required headers were not provided to the sink". I totally understand the error, just I don't get how to solve it...

如果你们需要的任何code,我会很高兴把它放在这儿。

If you guys need any code , I'll be glad to put it here.

推荐答案

我遇到了这个确切的错误,当我用MP4容器(在敲定汇)首先开始。

I ran into this exact error when I first started using the MP4 container (upon finalizing the sink).

错误0xC00D4A45:水槽无法创建有效的输出文件,因为
  所需的头部并没有提供给接收器。

Error 0xC00D4A45: Sink could not create valid output file because required headers were not provided to the sink.

您没有提到什么分型音频采样你是喂养水槽,也没有什么子类型加入(输出)音频流,但我相信,你的问题是后者。

You didn't mention what sub-type of audio samples you are feeding the sink, nor what sub-type of audio stream that was added (for output), however I am confident that your issue is with the latter.

与媒体基础开发,在MP4容器是最容易配置使用 MFAudioFormat_AAC MFAudioFormat_MP3 。如果你看一下的细节MP4文件接收器在这的链接,你会看到接收器可以生成样本描述为以下格式框(STSD):

Developing with media foundation, the MP4 container is easiest to configure using MFAudioFormat_AAC or MFAudioFormat_MP3. If you look at the details for the MP4 File Sink at this link, you will see that the sink can generate the sample description box (stsd) for the following formats:

- H.264/AVC video
- AAC audio
- MP3 audio

有可能使用一些其他的格式,但是你将不得不使用的样本描述框(STSD)介绍/en-us/library/windows/desktop/dd319566(v=vs.85).aspx相对=nofollow> MF_MT_MPEG4_SAMPLE_DESCRIPTION GUID配置时,创建水槽前属性。这是使用以下函数来完成:

It is possible to use a few other formats, however you will have to manually supply the sample description box (stsd) description using MF_MT_MPEG4_SAMPLE_DESCRIPTION GUID when configuring the attributes before creating the sink. This is accomplished using the following function:

// IMFAttributes::SetBlob
attributes->SetBlob(MF_MT_MPEG4_SAMPLE_DESCRIPTION, buffer, buffer_size);

但是,也有一些其他类型的可使用的,如由的.aspx相对=nofollow> MP4文件来源。在媒体类型,还有各种允许类型的表。除了AAC / MP3 previously提到的,很少有剩余的音频类型,并且没有一个是非常有吸引力的选择。你会发现,坚持 MFAudioFormat_AAC MFAudioFormat_MP3 将竭诚为您服务好。

However, there are few other types which can be used, as described by the MP4 File Source here. Under Media Types, there is a table of various allowed types. Other than AAC/MP3 previously mentioned, there are few remaining audio types, and none are very attractive choices. You will find that sticking to MFAudioFormat_AAC or MFAudioFormat_MP3 will serve you well.

希望这有助于。

编辑:

如果您选择使用音频的分型比 AAC MP3 等,并提供 MF_MT_MPEG4_SAMPLE_DESCRIPTION 通过配置 IMFAttributes ::的setBlob ,在样本描述框(STSD)中描述< A HREF =htt​​p://stackoverflow.com/questions/14331142/mp4-stsd-structure>这个答案。由于这个问题的答案州,框嵌套。

If you choose to use an audio sub-type other than AAC or MP3, and provide a MF_MT_MPEG4_SAMPLE_DESCRIPTION configuration using IMFAttributes::SetBlob, the sample description box (stsd) is described in this answer. As that answer states, the boxes are nested.

用于修饰声音,采取例如,如果您选择 MFAudioFormat_PCM MP4文件来源列出了媒体类型部分5项。其结果是,使用适当的采样条目code('生','sowt','两岁','无',0x00)来构建时,样本描述框。注意,在原始的空间。高电平总结如下:

Pertaining to Audio, take for instance, if you to select MFAudioFormat_PCM, MP4 File Source lists 5 entries in the Media Types section. As a result, use the appropriate sample entry code ('raw ', 'sowt', 'twos', 'NONE', 0x00) when building the sample description box. Note the space in 'raw '. The high level summary is as follows:

//  'raw '  Audio   MFAudioFormat_PCM   8-bit PCM audio
//  'sowt'  Audio   MFAudioFormat_PCM   16-bit little-endian PCM audio
//  'twos'  Audio   MFAudioFormat_PCM   16-bit big-endian PCM audio
//  'NONE'  Audio   MFAudioFormat_PCM   8-bit or 16-bit big-endian PCM audio
//   0x00   Audio   MFAudioFormat_PCM   8-bit or 16-bit big-endian PCM audio

您也可以找到这些注册codeCS有趣

这篇关于不能使用sinkwriter从媒体基金会的MP4文件添加音频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆