<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4176">>I am using ffmpeg libararies to create an AVI file as mentioned in the post (<a class="ecxedited-link-editor" id="ecxyui_3_16_0_1_1449223893102_4188" href="http://stackoverflow.com/questions/27454936/make-avi-file-from-h264-compressed-data" target="_blank">Make AVI file from H264 compressed >data</a>), this guy had the same problem as i currently have (i-e getting error value -22.</div></div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4171"><div dir="ltr" id="ecxyui_3_16_0_1_1449223893102_4170"><div dir="ltr" id="ecxyui_3_16_0_1_1449223893102_4190">>Please anyone can explain me what's the meaning of this error code "-22" that i get from >"av_interleaved_write_frame" ?</div></div></div></div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4171"><div dir="ltr" id="ecxyui_3_16_0_1_1449223893102_4170"><div id="ecxyui_3_16_0_1_1449223893102_4192">>he suggested that "By setting pts and dts with AV_NOPTS_VALUE I've 
solved the problem." please share any >example how to set pts value with 
AV_NOPTS_VALUE  ? and what should be the value of pts any rought 
estimate >?</div></div></div></div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4171"><div dir="ltr" id="ecxyui_3_16_0_1_1449223893102_4170"><div id="ecxyui_3_16_0_1_1449223893102_4614">></div></div></div></div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4171"><div dir="ltr" id="ecxyui_3_16_0_1_1449223893102_4170"><div id="ecxyui_3_16_0_1_1449223893102_4616" dir="ltr">>I found that this error "-22" is coming from "error.h" from the function <span id="ecxyui_3_16_0_1_1449223893102_4353">#define
 FFERRTAG(a, b, c, d) (->>(int)MKTAG(a, b, c, d)) but there are no details
 what MKTAG function does. I shall be very thankful if some one can also
 explain what MKTAG does ? and what error code "-22"  means ?</span></div><div id="ecxyui_3_16_0_1_1449223893102_4616" dir="ltr"><span><br></span></div><div id="ecxyui_3_16_0_1_1449223893102_4616" dir="ltr"><span><br></span></div></div></div></div></blockquote><font face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br></font><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;"><div id="ecxyui_3_16_0_1_1449223893102_4152"></div><div id="ecxyui_3_16_0_1_1449223893102_4176"><a id="ecxyui_3_16_0_1_1449223893102_4182" href="http://stackoverflow.com/questions/34063647/create-avi-file-from-compressed-data#" title="This is a favorite question (click again to undo)" target="_blank"></a>
        


</div>

            
            

</div><div><font face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">(-22) is a standard linux error which translates to invalid arguments.</font></div><div><font face="HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">you can see at <a href="https://ffmpeg.org/doxygen/2.8/mux_8c_source.html#l00932">line 950</a> inside the </font><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">av_interleaved_write_frame what returns the </span><a class="code" href="https://ffmpeg.org/doxygen/2.8/group__lavu__error.html#gae4bb6f165973d09584e0ec0f335f69ca" style="text-indent: -53px; color: rgb(70, 101, 162); text-decoration: none; font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">AVERROR</a><span style="text-indent: -53px; font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">(EINVAL);</span></div><div><span style="text-indent: -53px; font-family: monospace, fixed; font-size: 13px; line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">you can always check the errors using strerror or av_strerror to get a string representation</span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">of the error code</span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">The cause of the error is that the write interleaved is used to write the audio and video</span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">frames in the video containers, so you must set the presentation time stamp (pts) and duration </span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">time </span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">stamp (dts), so the correct audio frame get with the corresponding video frame.</span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">In case you have only video stream, you can ignore that all and use av_write_frame</span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);"><br></span></font></div><div><font face="monospace, fixed" size="3"><span style="line-height: 13px; white-space: pre-wrap; background-color: rgb(251, 252, 253);">if you want to use the </span></font><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">av_interleaved_write_frame</span><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"> , then you will have to adjust these two values</span></div><div><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">check the samples for more info on how to use them.</span></div><div><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">Regards.</span></div>                                     </div></body>
</html>