How to split OGX file (video)?
I am trying to create a PHP script that will supply a given .ogx file based on the search position (passed as a parameter to the script). The goal is to make an HTML5 video player with server side search functionality.
I did a little research on the container format and made a .php script to start delivering data from the first instance of the "OggS" string that occurs before the search position (given in bytes).
The problem is that although my new .ogx file starts with the line "OggS", it does not completely play in HTML5, VLC or any other player if the search position is other than 0.
If I set the search position to 0, the script will give me the entire file and the one to play.
So how do I trim the beginning of the .ogx file while still producing the correct bitstream?
a source to share
You should take a look at FFMpeg, which is a library that allows you to manipulate video and audio files in various ways. http://www.ffmpeg.org/
From your site
FFmpeg is a complete, cross-platform solution for recording, converting and streaming audio and video. It includes libavcodec, a host of audio / video codec libraries.
a source to share
First of all, I must point out what a common extension for videos in an Ogg container is .ogv
. The one you are using .ogx
is reserved for executable code in the Ogg container, but there are currently no threads that can carry such code (there was an attempt to create a replacement for Flash, but it has not been removed).
Second, the very first frame of the theory contains all the metadata about the stream. Because of this, players cannot play. If you intend to allow this search option, you will need to resubmit that first frame (you probably won't even need to decode it, just resubmit it).
So you are looking for:
- Find the first package of OggS theory, write it down.
- Look for the point you need.
- Send recorded packet.
- Skip data until next "OggS".
- Start by streaming as usual.
Since your file will most likely contain a Vorbis stream as well as Theora, you can also send it the first packet.
a source to share