[Libav-user] how to Write the compressed frame to the media file ?

Mohamed Moanis mohamed_moanis at outlook.com
Sat Dec 5 20:23:44 CET 2015

>I am using ffmpeg libararies to create an AVI file as mentioned in the post (Make AVI file from H264 compressed >data), this guy had the same problem as i currently have (i-e getting error value -22.>Please anyone can explain me what's the meaning of this error code "-22" that i get from >"av_interleaved_write_frame" ?>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 >?>>I found that this error "-22" is coming from "error.h" from the function #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 ?



(-22) is a standard linux error which translates to invalid arguments.you can see at line 950 inside the av_interleaved_write_frame what returns the AVERROR(EINVAL);
you can always check the errors using strerror or av_strerror to get a string representation
of the error code
The cause of the error is that the write interleaved is used to write the audio and video
frames in the video containers, so you must set the presentation time stamp (pts) and duration 
stamp (dts), so the correct audio frame get with the corresponding video frame.
In case you have only video stream, you can ignore that all and use av_write_frame
if you want to use the av_interleaved_write_frame , then you will have to adjust these two values
check the samples for more info on how to use them.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20151205/8159727c/attachment.html>

More information about the Libav-user mailing list