Hello,



I am trying to mux audio and video streams to a webm file using libavformat. 
For video stream, when I call av_interleaved_write_frame(), write_packet()

is called, which calls mkv_write_flush_packet()  in matroskaenc.c. 



In that method, av_packet_unref(&MatroskaMuxContext.cur_audio_pkt) is 
called. MatroskaMuxContext.cur_audio_pkt is basically a cached audio packet. If 
we have a cached audio packet we are writing it with 
mkv_write_packet_internal(). And after that we are calling av_packet_unref() to 
free that packet. But, in that method it is throwing the following error for 
AVPacket->AVBufferRef->AVBuffer->data, when it is freed.



"malloc: *** error for object 0x7fda5f816200: pointer being freed was not 
allocated"



I am not freeing any modules prior to this. I have debugged it so far using 
lldb tool to analyze core dump. I am unable to find the exact cause for this. 
Am I missing something uninitialized or am I passing some argument wrong? 
Please help me out. 



P.S:



I am attaching my three C source files here. In that, test.c contains 4 
methods, 



initLibrary() - to initialize library

writeVideo()

writeAudio()

closeFile()



which i call accordingly to write audio and video frames to the webm file. And 
these methods call methods from writewebm.c file.

writewebm.c contains actual FFMpeg library calls. So, this error occurs when I 
call writeVideo() with AVPacket containing a video frame. But it is not 
consistent though. 

And, the same issue also occurs when in order to close the file I call 
av_write_trailer(), where it checks for all cached audio packets and tries to 
write them to the file.






Thanks.

Ravi Kiran B S









Attachment: test.c
Description: Binary data

Attachment: writewebm.c
Description: Binary data

Attachment: writewebm.h
Description: Binary data

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to