[FFmpeg-soc] MXF muxer version 0.0.2

Michael Niedermayer michaelni at gmx.at
Sun Aug 17 20:55:56 CEST 2008


On Mon, Aug 18, 2008 at 12:32:12AM +0800, zhentan feng wrote:
> Hi
> 
> 2008/8/17 Michael Niedermayer <michaelni at gmx.at>
> 
> > On Sun, Aug 17, 2008 at 11:27:41AM +0800, zhentan feng wrote:
> > > Hi
> > >
> > > 2008/8/17 Michael Niedermayer <michaelni at gmx.at>
> > >
> > > > On Sat, Aug 16, 2008 at 10:50:12PM +0800, zhentan feng wrote:
> > [...]
> > > > > +static int mxf_write_track(AVFormatContext *s, KLVPacket *klv, int
> > > > stream_index, enum MXFMetadataSetType type)
> > > > > +{
> > > > > +    ByteIOContext *pb = s->pb;
> > > > > +    AVStream *st;
> > > > > +    MXFStreamContext *sc;
> > > > > +    const MXFCodecUL *element;
> > > > > +    int i = 0;
> > > > > +    int
> > > > track_number_sign[sizeof(mxf_essence_element_key)/sizeof(MXFCodecUL)] =
> > { 0
> > > > };
> > > > > +
> > > > > +    AV_WB24(klv->key + 13, 0x013b00);
> > > > > +
> > > > > +    put_buffer(pb, klv->key, 16);
> > > > > +    klv_encode_ber_length(pb, 80);
> > > > > +
> > > > > +    st = s->streams[stream_index];
> > > > > +    sc = st->priv_data;
> > > > > +
> > > > > +    // write track uid
> > > > > +    mxf_write_local_tag(pb, 16, 0x3C0A);
> > > > > +    mxf_write_uuid(pb, Track * type, stream_index);
> > > > > +#ifdef DEBUG
> > > > > +    PRINT_KEY(s, "track key", klv->key);
> > > > > +    PRINT_KEY(s, "track uid", pb->buf_ptr - 16);
> > > > > +#endif
> > > > > +    // write track id
> > > > > +    mxf_write_local_tag(pb, 4, 0x4801);
> > > > > +    put_be32(pb, stream_index);
> > > > > +
> > > > > +    mxf_write_local_tag(pb, 4, 0x4804);
> > > > > +    if (type != MaterialPackage) {
> > > > > +        for (element = mxf_essence_element_key; element->id !=
> > > > CODEC_ID_NONE; element++) {
> > > > > +            if (st->codec->codec_id== element->id) {
> > > > > +                // write track number
> > > > > +                put_buffer(pb, element->uid + 12, 3);
> > > > > +                put_byte(pb, element->uid[15] +
> > track_number_sign[i]);
> > > >
> > > > track_number_sign will always be 0 here, i suspect this is not intended
> > ...
> > > >
> > >
> > > in material package, the track number is always 0 .
> > > but in source package,
> > > according to specs, track number should increment for same essence
> > element
> > > key.
> > > we use track_number_sign[] in order to record the times of same present
> > of
> > > the essence element key.
> >
> > and does it work? That is is it for source package ever non 0 ?
> >
> no.
> because the test.mpg is just 2 streams, which have not same essence element
> keyin all streams.
> so the track_number_sign[] won't increment.
> Do you mean remvoe it for now?

no, but i think your code is buggy
That is why i asked if it does work

i think it will not increase even when there are 2 equal streams
I think the array will be reset to 0 between the streams.


[...]
> > >
> > >
> > > >
> > > > [...]
> > > >
> > > > > @@ -87,6 +930,41 @@
> > > > >      return 0;
> > > > >  }
> > > > >
> > > > > +static int mxf_update_header_partition(AVFormatContext *s, int64_t
> > > > footer_partition_offset)
> > > > > +{
> > > > > +    MXFContext *mxf = s->priv_data;
> > > > > +    ByteIOContext *pb = s->pb;
> > > > > +
> > > > > +    if (!url_is_streamed(s->pb)) {
> > > > > +        url_fseek(pb, mxf->header_byte_count_offset, SEEK_SET);
> > > > > +        put_be64(pb, mxf->header_byte_count);
> > > > > +        put_flush_packet(pb);
> > > > > +
> > > > > +        url_fseek(pb, mxf->header_footer_partition_offset,
> > SEEK_SET);
> > > > > +        put_be64(pb, footer_partition_offset);
> > > > > +        put_flush_packet(pb);
> > > >
> > > > > +    } else {
> > > > > +        av_log(s, AV_LOG_ERROR, "update header partition failed, non
> > > > streamble out put\n");
> > > > > +        return -1;
> > > > > +    }
> > > >
> > > > we should support streamed files, not fail for them. I belive the
> > footer
> > > > partition is optional and when there is none also no pointer needs to
> > point
> > > > to one.
> > >
> > >
> > > 1)I understand like this:
> > > when files is not streamed, we can seek by offset freely,
> > > and when files is streamed, we can not seek.
> > >
> > > But if cannot, when wrting the header partition, we can not get the
> > correct
> > > value until end of the file, so how to update the correct field in header
> > > partition?
> > >
> >
> > > 2) according to s377m, footer partition is not optional.
> >
> > s377m says:
> > "An MXF File shall be divided into a number of partitions:
> >      one Header Partition which shall be followed by
> >      zero or more Body Partitions, the last of which shall be followed by
> >
> >      zero or one Footer Partition
> >      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > "
> >
> >
> It's my fault, I missed this improtant rule.
> should we remove footer partition?

I think the footer should be written for non streamed files and
ommited for streamed ones.


> btw: it will be very helpful to hear some suggestion from Baptiste.

yes, i hope he finds some internet access soon whereever he is


> 
> 
> >
> > >
> > > "Where present, a Footer Partition shall be located at the end of the
> > file.
> > > It shall comprise a Footer Partition Pack
> > > followed optionally by the Header Metadata, and optionally by Index Table
> > > segments. The Footer Partition may
> > > optionally be followed by a Random Index Pack. "
> >
> > "where present" means "if there is" so it says
> > "if there is a footer partition then it should be at the end of the file"
> >
> > baptiste probably can say more about all this, but i think he isnt here
> > ATM?
> >
> >
> > >
> > > 3) I run ./ffmpeg -i test.mpg test.mxf
> > > it generate unstreamed files, and how to generated streamed files?
> >
> > ./ffmpeg -i test.mpg -f mxf - >test.mxf
> >
> > I mention again the former issue which you seems missed here:
> 

> when files is not streamed, we can seek by offset freely,
>  and when files is streamed, we can not seek.

yes


> 
>  But if cannot, when wrting the header partition, we can not get the correct
>  value until end of the file, so we will write a default value and mark the
> position then update later.
> 
> so, if streamed file muxed , any solution about this?

if we ommit the footer then theres no need to update the pointer to it
and header_byte_count can be updated likely as there is a small internal
buffer that allow small seeks before put_flush_packet() even in streamed
files


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080817/4d45c30f/attachment.pgp>


More information about the FFmpeg-soc mailing list