开发者

How do I split an OGX (video) file?

I'm trying to make a PHP script that will deliver a given .ogx file based on a seek position (transmited as a parameter to the script). The purpose is to make a HTML5 video player with server-side seeking functions.

I have studied the container format a bit and made the .php script to start delivering data from the first开发者_如何转开发 instance of the "OggS" string that occurs before the seek position (given in bytes).

The problem is, even though my new .ogx file starts with the "OggS" string, it is completely unplayable in HTML5, VLC or any other player as long as the seeking position is other than 0.

If I set the seeking position to 0, the script will give me the whole file and that's playable.

So how do I trim the start of an .ogx file while still producing a valid bitstream?


You should take a look at FFMpeg, which is a library that let's you manipulate in different kind of ways video and audio files. http://www.ffmpeg.org/

From their site

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.


First of all i should point out that the common extension for the video in the Ogg container is .ogv. The one you are using .ogx is reserved for the executable code within Ogg container, but currently there are no streams that can carry such code (there was an attempt to create the substitute for Flash, but it didn't take off).

Secondly, the very first frame of the theora holds all the metadata about the stream. The reason why players cannot play it is due to this fact. If you intend to allow for such a seeking option you'll need to resend that first frame (you will probably not even need to decode it, just resend it).

So what you are looking for is:

  1. Find the first theora OggS packet, record it.
  2. Seek to the point that you need.
  3. Send the recorded packet.
  4. Skip the data until the next "OggS".
  5. Begin streaming the data as you usually do.

Since your file is likely to contain Vorbis stream as well as Theora, you may want to send its first packet on as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜