<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
h1
        {mso-style-priority:9;
        mso-style-link:"Heading 1 Char";
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:24.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.Heading1Char
        {mso-style-name:"Heading 1 Char";
        mso-style-priority:9;
        mso-style-link:"Heading 1";
        font-family:"Times New Roman","serif";
        font-weight:bold;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I am trying to figure out how to use the ffmpeg libraries inside an application.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have used the ffmpeg binary directly on a set of pgm files to generate an mp4 file using the following command:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>ffmpeg -r 1 -b 18000 -i frame_%05d.pgm -vcodec libx264 -vpre slow foobar.mp4<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The source data used to create the pgm files is jp2 files.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My goal is to be able to do RTSP streaming of buffers created from the jp2 files to a remote server running ffserver.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>To start though, I am trying to create an mp4 file from a list of jp2 files without having to go thru the step of creating the pgm files.  That is I just want to encode the data that I get from a series of buffers created from the jp2 files.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have spent a fair amount of time looking at the ffmpeg.c code, and instrumenting it or running it under gdb and have found that part of what it does when it creates the mp4 file is to write out a 48 byte header,  then write each of the frames for the mp4 file, and then to finally write out  a 1000+ byte trailer to the mp4 file.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>By including pieces of the ffmpeg.c file inside my  application,  I have been able to write out the header, and perform all of the encoding and write out the frames, and to write out most of the trailer.  But a number of the tags inside the trailer are missing.   I am quite sure that I am missing those tags due to not having the AVFormatContext structure set up correctly for the data that resides in the priv_data area.  I have not been able to figure out how the ffmpeg binary actually fills in that area when it generates the its AVFormatContext  object.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><h1><span style='font-size:11.0pt;font-weight:normal'>So I am looking for some help on how to do this.  The libavcodec/api-example.c does not provide the needed info on how to do this type of encoding.  Are there other examples that might help me?<o:p></o:p></span></h1><h1><span style='font-size:11.0pt;font-weight:normal'><o:p> </o:p></span></h1><h1><span style='font-size:11.0pt;font-weight:normal'>Thanks,<o:p></o:p></span></h1><h1><span style='font-size:11.0pt;font-weight:normal'>Arnie<o:p></o:p></span></h1><h1><span style='font-size:11.0pt;font-weight:normal'><o:p> </o:p></span></h1><h1><span style='font-size:11.0pt;font-weight:normal'><o:p> </o:p></span></h1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>