Re: Recording to Multiple MPEG2 files
- From: "Iain Downs" <iainTAKEAWAY@xxxxxxxxxx>
- Date: Fri, 18 May 2007 10:30:06 +0100
"Jon E" <JonE@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AB41FB24-446F-494A-B89F-D2BE0E4682A8@xxxxxxxxxxxxxxxx
I need to record in MPEG format continuously (as in for weeks or months).....
To
be usable, I need to split the recording into smaller blocks (lets say 1/2
hour for the sake of argument). In addition I need to use a hardware MPEG2
encoder.
So the only solution is to take the MPEG stream and do my own file writer.
Looking at the MPEG2 samples, they are always 16K big, and at semi-random
the
samples are marked IsSyncPoint(). There are big gaps between some of them
so
I assume at that point we have the start of an 'I' frame - a logical
splittin
point ?
So, am I right in thinking I can start writing to another file at this
point
? If so, what on earth do I do about an initial header so that the file
will
be playable ?
There are three ways of writing out an MPEG file, elementary streams,
transport streams and program streams. The first of these simply the raw
data (one format - e.g. video only). The second is optimised for low
reliability transports (broadcast) and the third for reliable transports
(file). Transport and Program streams contains Elementary streams. This of
course, is probably oversimplified sufficiently to be nearly wrong, but it's
a good start.
In all cases you want to be sure that a file starts AND ends with an IFrame
(because most MPEG configurations will include some backward prediction so
you need a following frame).
The elementary stream is easiest to write out as it is contains exactly what
emerges from the encoder. To split wait till there is an IFrame and write
it to file A, then Write teh same Frame to FileB and continue.
To write Program and Transport streams is more complicated and you will need
to mux the ESes in a stream. They have the advantage that you can have
audio AND video.
You will find the PS and TS standards knocking around the web (can't recall
the numbers offhand) or you can pay for them from one of the standards
bodies. You may find source code for muxers on the oddly named doom9.org or
sourceforge and so on.
Geraint's MPEG parser maybe a useful resource too - (knowing how to unpack
helps to understand how to pack!) www.gdcl.co.uk
Iain
.
- Follow-Ups:
- Re: Recording to Multiple MPEG2 files
- From: Alessandro Angeli
- Re: Recording to Multiple MPEG2 files
- Prev by Date: Re: Recording to Multiple MPEG2 files
- Next by Date: Re: enum filter's supported MEDIASUBTYPE
- Previous by thread: Re: Recording to Multiple MPEG2 files
- Next by thread: Re: Recording to Multiple MPEG2 files
- Index(es):
Relevant Pages
|