Finding closest IFrame position in bytes in an MP4 file from the time offset position

787 views
Skip to first unread message

Sanjay Madhavan

unread,
Oct 15, 2012, 5:17:03 AM10/15/12
to mp4parser-...@googlegroups.com
I am trying to implement a HTTP Pseudo streaming solution for MP4 files.

One of the issues I am facing is that the client video player can optionally send a start parameter that refers to the offset in seconds within the mp4 file being streamed.

 e.g: /stream?file=sample.mp4&start=30.45

I am trying to figure out based on the start parameter the closest IFrame position (in bytes) to that offset and start streaming from that point.

Any suggestions?

/sanjay


Message has been deleted

Sanjay Madhavan

unread,
Oct 16, 2012, 8:23:31 AM10/16/12
to mp4parser-...@googlegroups.com
I meant key-frame not IFrame

NITIN GOYAL

unread,
Oct 16, 2012, 8:34:52 AM10/16/12
to mp4parser-...@googlegroups.com
offset in seconds?

Cant this be managed as cue points putting them into the header boxes?

Using the different box tables we already have the position of all the offset values so i think it can be managed easily.

Sanjay Madhavan

unread,
Oct 16, 2012, 8:41:55 AM10/16/12
to mp4parser-...@googlegroups.com
Nitin,

Thanks for the reply.

Yes. Offset in seconds.

What I want to do is given an offset in seconds find the closest key-frame in the file and return the offset in bytes of the key-frame so the server can stream the file from that byte offset

Not exactly sure whet you mean by cue points.

Would you have a sample of something I can look at to get started?

/sanjay

NITIN GOYAL

unread,
Oct 16, 2012, 9:03:00 AM10/16/12
to mp4parser-...@googlegroups.com
Yeahok.

That is pure pseudoStreaming.

If you streaming on HTTP you can us the HTTP byte ranges as well.

For the mp4 file also, you need to associate the Keyframes with the timings like if your data is 25fps, then at 30th sec u know which frame will come and thus you will be able to calculate the required offset as well and then decode that particular NAL and the subsequent ones.

but every file which don't have the equal number of frames or don't ave a predefined GOP size, it will be difficult to manage i guess as you don't know which frame to call.

There are few solution which implements pseudo Streaming.  You may take a look on the source code of this http streamer:


it is not calling using the timestamp but using the frame number but the similar thing can be manged by ,mapping the offset of the key frame with the timestamps.

Sanjay Madhavan

unread,
Oct 16, 2012, 9:08:12 AM10/16/12
to mp4parser-...@googlegroups.com
I am implementing the server side so need to figure out where to start streaming for given a time offset.
byte ranges does not work for mp4 files hence need to figure out the timeoffset->byte position map

/sanjay

Sebastian Annies

unread,
Nov 3, 2012, 6:27:56 PM11/3/12
to mp4parser-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages