[FFmpeg-devel] [PATCH] jp2 image2 muxer

Baptiste Coudurier baptiste.coudurier
Sun Jan 18 02:48:55 CET 2009


Michael Niedermayer wrote:
> On Sat, Jan 17, 2009 at 01:52:54PM -0800, Baptiste Coudurier wrote:
>> Hi Michael,
>>
>> Michael Niedermayer wrote:
>>> 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.
>> I undestand, I changed the check to use av_str2id which will match
>> CODEC_ID_JPEG2000 when ".jp2" extension is used, in this case I think
>> the code makes all its sense, since user want valid .jp2 files.
>>
>> What do you think ?
> 
> looks ok
> 

Cool, applied.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no




More information about the ffmpeg-devel mailing list