freeMXF.org
http://freemxf.org/forum/

Indexing an MXF file when using a custom EssenceSource
http://freemxf.org/forum/viewtopic.php?f=2&t=147
Page 1 of 1

Author:  Pardus [ Fri Apr 18, 2008 12:25 pm ]
Post subject:  Indexing an MXF file when using a custom EssenceSource

I've been trying to create a Partial Restore application for XDCAM pal d10 imx 50 mxf files.
As a first step I'm trying to duplicate an example XDCAM file.

The Essence in our XDCAM file is framewrapped.
I've written a custom EssenceSource (RAW_essenceSource) that has a Smartpointer to the Partition that contains the essence in the original file, and also an UL defining the essence stream we wish to extract from this Partition.

When the RAW_essenceSource::BaseGetEssenceData() function is called, it returns the Data(Chunk) of the next retrieved KLVObjectPtr (Partition->NextElement()) that matches with the chosen UL

Thus, I'm able to create an unindexed file.

Code:
...

EssenceSourcePtr Source = new RAW_EssenceSource(ThisPartition,elementUL,UInt8(0x05),UInt8(0x01));
EssenceSourcePtr Source2 = new RAW_EssenceSource(ThisPartition,elementUL_2,UInt8(0x06),UInt8(0x01));

BodyStreamPtr Stream = new BodyStream(BodySID,Source);
Stream->AddSubStream(Source2);

Stream->SetWrapType(BodyStream::StreamWrapFrame);

BodyWriterPtr Writer = new BodyWriter(OutFile);

Writer->SetKAG(512);
Writer->SetForceBER4(true);
Writer->SetMetadataSharing(true, true);
Writer->AddStream(Stream);
            

PartitionPtr NewPart = new Partition(OpenHeader_UL);

...

NewPart->AddMetadata(HMeta);
               
Writer->SetPartition(NewPart);
Writer->WriteHeader(true,true);
Writer->WriteBody();
Writer->WriteFooter(false);

OutFile->Close();




The original XDCAM file however contains an index of the type (or so I think):

Code:
Stream->SetIndexType( (BodyStream::IndexType) ( BodyStream::StreamIndexCBRHeader
                                                         | BodyStream::StreamIndexCBRBody
                                                         | BodyStream::StreamIndexCBRFooter) );


I've tried indexing the file but my console output always returns an infinite number of error messages:

Quote:
ERROR: Attempted to index a stream with no index manager


I've created an IndexManager but I don't know how and cannot find an example on how to link it to the BodyWriter.

Code:
IndexManagerPtr IndexMan = new IndexManager(0,Source->GetEssenceDataSize());
IndexMan->SetBodySID(BodySID);
IndexMan->SetIndexSID(1);
IndexMan->SetEditRate(Source->GetEditRate());
IndexMan->SetValueRelativeIndexing(false);


How does one ceate and add a valid IndexManager, that works with a custom EssenceSource? And how does one link this IndexManager to the considered EssenceSources/BodyStream/BodyWriter ?

Author:  Pardus [ Fri Apr 18, 2008 1:33 pm ]
Post subject: 

I should write more forum posts.
Half an hour after posting I find half of the answer:

First, it's

Code:
Stream->SetIndexType( (BodyStream::IndexType) ( BodyStream::StreamIndexCBRHeader
                                                         | BodyStream::StreamIndexCBRBody) );


It seems that apart from a few more obvious steps
Stream->SetIndexSID(1);
is nescessary.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/