[FFmpeg-devel] [PATCH] jp2 image2 muxer

Michael Niedermayer michaelni
Sun Dec 21 01:40:10 CET 2008


On Wed, Dec 17, 2008 at 12:11:38AM -0800, Baptiste Coudurier wrote:
> Hi,
> 
> $subject,
> 
> You can extract jp2 files from .R3D files and also from .mov/.mj2
> 
> ffmpeg -i <file.mj2/.r3d> -vcodec copy test%d.jp2
[...]
> @@ -358,6 +359,29 @@
>          url_fclose(pb[1]);
>          url_fclose(pb[2]);
>      }else{
> +        if(codec->codec_id == CODEC_ID_JPEG2000){
> +            AVStream *st = s->streams[0];
> +            if(st->codec->extradata_size > 8 &&
> +               AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
> +                if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
> +                    goto error;
> +                put_be32(pb[0], 12);
> +                put_tag (pb[0], "jP  ");
> +                put_be32(pb[0], 0x0D0A870A); // signature
> +                put_be32(pb[0], 20);
> +                put_tag (pb[0], "ftyp");
> +                put_tag (pb[0], "jp2 ");
> +                put_be32(pb[0], 0);
> +                put_tag (pb[0], "jp2 ");
> +                put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
> +            }else if(pkt->size < 8 ||
> +                     (!st->codec->extradata_size &&
> +                      AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
> +            error:
> +                av_log(s, AV_LOG_INFO, "malformated jpeg2000 codestream\n");
> +                return -1;
> +            }
> +        }

The thing ive used image2 for most often is debuging.
this code makes image2 unuseable for debuging jpeg2k, because what it
writes is not what is in the packets besides it even refuses malformated
packets, which is desireable if one wants actual j2k files but not when one
like a developer wants to look at the output of a buggy demuxer.

maybe a "rawframes" demuxer could be added that did what image2 does just
without such modifications.
Or the code could be moved to a bitstream filter ... sadly that brings back
the problem of auto loading bsfs.

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- 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-devel/attachments/20081221/a3c757c2/attachment.pgp>



More information about the ffmpeg-devel mailing list