I need to build something that starts serving a H.264 encoded video to a flash player halfway through the file (to support skipping to a point in the video that has not been buffered yet).
我需要构建一些开始在文件中途提供H.264编码视频的内容到闪存播放器(以支持跳转到尚未缓冲的视频中的某个点)。
Currently, the videos are in the FLV container format, but transcoding is an option. I managed to re-write the file header and metadata information for a given byte offset. This works for older videos, but not for H.264 encoded files. I suspect this is because the video tags inside the file also have to be altered, which is not feasible (it would take too much processing power).
目前,视频采用FLV容器格式,但转码是一种选择。我设法重写了给定字节偏移量的文件头和元数据信息。这适用于较旧的视频,但不适用于H.264编码的文件。我怀疑这是因为文件中的视频标签也必须改变,这是不可行的(它需要太多的处理能力)。
What is the "proper" way to do it?
这样做的“正确”方法是什么?
3 个解决方案
#1
2
The flash player can only start playing H.264 video once it's downloaded the MOOV atom. Existing pseudo-streaming providers just give you an FLV header - either the first 13 bytes of the file or a hardcoded one - and then serve the file from the given offset. If you want to make an H.264 pseudo-streamer, you'll need to have it output the FLV header, then a MOOV atom, and then serve the rest of the file from the given offset. If you don't use an FLV container, you won't need the FLV header, but you'll still need the MOOV atom.
一旦下载了MOOV原子,flash播放器才能开始播放H.264视频。现有的伪流式提供程序只为您提供FLV标头 - 文件的前13个字节或硬编码的 - 然后从给定的偏移量提供文件。如果你想制作一个H.264伪流,你需要让它输出FLV头,然后输出一个MOOV原子,然后从给定的偏移量中提供文件的其余部分。如果你不使用FLV容器,你将不需要FLV头,但你仍然需要MOOV原子。
Unfortunatley, I don't think you'll be able to use the MOOV atom from the file on disk; the information it contains won't be right for the file fragment that you serve. So you'd have to parse the existing atom and generate one of your own which was appropriate to the served part of the file.
不幸的是,我认为你不能从磁盘上的文件中使用MOOV原子;它包含的信息不适合您所服务的文件片段。所以你必须解析现有的atom并生成一个适合于文件服务部分的原子。
If there are complicated structures within the H.264 file it could be even more complicated to pseudo-stream. If parsing the file isn't feasible, I'm afraid you may not be able to pseudo-stream your media.
如果H.264文件中存在复杂的结构,则伪流可能更复杂。如果解析文件不可行,我担心您可能无法伪流媒体。
#2
3
@yoavf - I think the OP is interested in server-side aspects of streaming on-demand h.264 inside of FLV files. Reuse of existing players would be nice for him, I think. Or maybe that is my own needs coming out? <:S
@yoavf - 我认为OP对FLV文件中流媒体点播h.264的服务器端方面感兴趣。我想,重用现有球员对他来说会很好。或许这是我自己的需求出来? <:S
From yoavf's second link, there is another link to Tinic Uro's What just happened to video on the web? . A relevant quote:
从yoavf的第二个链接开始,还有另一个链接到Tinic Uro的网站上的视频发生了什么? 。相关报价:
Will it be possible to place H.264 streams into the traditional FLV file structure? It will, but we strongly encourage everyone to embrace the new standard file format. There are functional limits with the FLV structure when streaming H.264 which we could not overcome without a redesign of the file format. This is one reason we are moving away from the traditional FLV file structure. Specifically dealing with sequence headers and enders is tricky with FLV streams.
是否可以将H.264流放入传统的FLV文件结构中?它会,但我们强烈建议每个人都接受新的标准文件格式。当流式传输H.264时,FLV结构存在功能限制,如果不重新设计文件格式,我们无法克服这些限制。这是我们摆脱传统FLV文件结构的一个原因。具体处理序列标题和enders对于FLV流来说是棘手的。
So, it seems one can either tinker with ffmpeg encoding (if that is how you are getting your FLVs, like I am) or one can get into the new format. Hmmmm....
所以,似乎人们可以修补ffmpeg编码(如果这就是你获取FLV的方式,就像我一样)或者可以进入新的格式。 Hmmmm ....
#3
0
two things you can do:
你可以做两件事:
1) use lighttpd and it's mp4 streaming plug-in that'll generate the required streaming container on the fly
1)使用lighttpd和它的mp4流媒体插件,它将动态生成所需的流式传输容器
2) create a keyframed FLV and use a psuedo-streaming script (like XMOOV) to stream your file.
2)创建一个关键帧FLV并使用伪流式脚本(如XMOOV)来流式传输文件。
if you need mp4/aac you can just put them inside the FLV container, much to adobe's chagrin, but it works.
如果你需要mp4 / aac,你可以将它们放在FLV容器内,这对adobe的懊恼很重要,但它确实有效。
#1
2
The flash player can only start playing H.264 video once it's downloaded the MOOV atom. Existing pseudo-streaming providers just give you an FLV header - either the first 13 bytes of the file or a hardcoded one - and then serve the file from the given offset. If you want to make an H.264 pseudo-streamer, you'll need to have it output the FLV header, then a MOOV atom, and then serve the rest of the file from the given offset. If you don't use an FLV container, you won't need the FLV header, but you'll still need the MOOV atom.
一旦下载了MOOV原子,flash播放器才能开始播放H.264视频。现有的伪流式提供程序只为您提供FLV标头 - 文件的前13个字节或硬编码的 - 然后从给定的偏移量提供文件。如果你想制作一个H.264伪流,你需要让它输出FLV头,然后输出一个MOOV原子,然后从给定的偏移量中提供文件的其余部分。如果你不使用FLV容器,你将不需要FLV头,但你仍然需要MOOV原子。
Unfortunatley, I don't think you'll be able to use the MOOV atom from the file on disk; the information it contains won't be right for the file fragment that you serve. So you'd have to parse the existing atom and generate one of your own which was appropriate to the served part of the file.
不幸的是,我认为你不能从磁盘上的文件中使用MOOV原子;它包含的信息不适合您所服务的文件片段。所以你必须解析现有的atom并生成一个适合于文件服务部分的原子。
If there are complicated structures within the H.264 file it could be even more complicated to pseudo-stream. If parsing the file isn't feasible, I'm afraid you may not be able to pseudo-stream your media.
如果H.264文件中存在复杂的结构,则伪流可能更复杂。如果解析文件不可行,我担心您可能无法伪流媒体。
#2
3
@yoavf - I think the OP is interested in server-side aspects of streaming on-demand h.264 inside of FLV files. Reuse of existing players would be nice for him, I think. Or maybe that is my own needs coming out? <:S
@yoavf - 我认为OP对FLV文件中流媒体点播h.264的服务器端方面感兴趣。我想,重用现有球员对他来说会很好。或许这是我自己的需求出来? <:S
From yoavf's second link, there is another link to Tinic Uro's What just happened to video on the web? . A relevant quote:
从yoavf的第二个链接开始,还有另一个链接到Tinic Uro的网站上的视频发生了什么? 。相关报价:
Will it be possible to place H.264 streams into the traditional FLV file structure? It will, but we strongly encourage everyone to embrace the new standard file format. There are functional limits with the FLV structure when streaming H.264 which we could not overcome without a redesign of the file format. This is one reason we are moving away from the traditional FLV file structure. Specifically dealing with sequence headers and enders is tricky with FLV streams.
是否可以将H.264流放入传统的FLV文件结构中?它会,但我们强烈建议每个人都接受新的标准文件格式。当流式传输H.264时,FLV结构存在功能限制,如果不重新设计文件格式,我们无法克服这些限制。这是我们摆脱传统FLV文件结构的一个原因。具体处理序列标题和enders对于FLV流来说是棘手的。
So, it seems one can either tinker with ffmpeg encoding (if that is how you are getting your FLVs, like I am) or one can get into the new format. Hmmmm....
所以,似乎人们可以修补ffmpeg编码(如果这就是你获取FLV的方式,就像我一样)或者可以进入新的格式。 Hmmmm ....
#3
0
two things you can do:
你可以做两件事:
1) use lighttpd and it's mp4 streaming plug-in that'll generate the required streaming container on the fly
1)使用lighttpd和它的mp4流媒体插件,它将动态生成所需的流式传输容器
2) create a keyframed FLV and use a psuedo-streaming script (like XMOOV) to stream your file.
2)创建一个关键帧FLV并使用伪流式脚本(如XMOOV)来流式传输文件。
if you need mp4/aac you can just put them inside the FLV container, much to adobe's chagrin, but it works.
如果你需要mp4 / aac,你可以将它们放在FLV容器内,这对adobe的懊恼很重要,但它确实有效。