leandromoreira / ffmpeg-libav-tutorial

FFmpeg libav tutorial - learn how media works from basic to transmuxing, transcoding and more. Translations: πŸ‡ΊπŸ‡Έ πŸ‡¨πŸ‡³ πŸ‡°πŸ‡· πŸ‡ͺπŸ‡Έ πŸ‡»πŸ‡³ πŸ‡§πŸ‡·
https://github.com/leandromoreira/ffmpeg-libav-tutorial
BSD 3-Clause "New" or "Revised" License
9.82k stars 941 forks source link

Disagreement with FFmpeg example #44

Closed madphysicist closed 5 years ago

madphysicist commented 5 years ago

I am looking through 0_hello_world.c, line 238. According to the example in the latest FFmpeg docs, http://www.ffmpeg.org/doxygen/trunk/decode_video_8c-example.html, you don't need to unref the frame here. It's quite possible that I am misunderstanding the import of the comment

/* the picture is allocated by the decoder. no need to
   free it */

in the FFmpeg version of decode().

Overall, awesome tutorial. I found it extremely helpful despite any impression my nitpicking may give to the contrary. I can't wait to see it grow in both content and popularity.

leandromoreira commented 5 years ago

I agree with you the docs point to this:

int avcodec_receive_frame(AVCodecContext * avctx, AVFrame *frame)
# frame  This will be set to a  reference-counted video or audio frame 
(depending on the decoder type)  allocated by the decoder. 
Note that the function will always call  av_frame_unref(frame) 
before doing anything else.