Open Page-David opened 5 years ago
Good catch.
Hi, it is now that I finally find that simply replacing pLocalCodec
with pLocalCodecParameters
might not be a perfect solution. Instead, it might be better to firstly state that when we do the while
loop to read AVPacket
we need to distinguish video track from sound track. Also, when we create pCodecContext
and call avcodec_parameters_to_context
, we must use AVCodec
and AVCodecParameters
from the video track. Thus we need to "remember" them with pCodec
etc. What do you think about?
Btw, could you please explain why do we need avformat_alloc_context()
for *pFormatContext
and why do we need av_frame_unref(pFrame);
? So far, assigning NULL
to *pFormatContext
or remove av_frame_unref
did not cause any problem for me. In chapter 2, AVFormatContext
was assigned like AVFormatContext *input_format_context = NULL;
why this time not avformat_alloc_context()
?
Hi, I noticed this line of code in README.md
in which
pLocalCodec
is not declared in the article before used which might cause confusion in my view. Digging into the c code, I found this line.https://github.com/leandromoreira/ffmpeg-libav-tutorial/blob/cdd616ce871078ebb67601af207f10a299914e19/0_hello_world.c#L110
As for a guess, maybe the author firstly write the c code and copy-and-paste these important parts into README and lead to this issue. By the way, I think adding
\n
afterwardprintf
s could make output looks better. Hope that useful.UPDATE This line of code has the same problem:
Maybe it will be better to replace
pCodec
withpLocalCodec
.