Please enable JavaScript.
Coggle requires JavaScript to display documents.
Open a File, Read a streams and capture the frames - Coggle Diagram
Open a File, Read a streams and capture the frames
Entry Point
Main
-
-
-
-
We have a debugging function to show us what's inside the dumping information using av_dump_format -> MetaData
-
Each stream has different codec is and the information about the codec is in what we call Codec Context This contains all the information about the codec that the stream is using.
Find the video Stream using pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
Find the video Stream using pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
-
Note that we must not use the CodecContext from the video stream directly. So we have to use avcodec_copy_context() to copy the context to the new location after allocating memory for it. avcodec_alloc_context3, avcodec_parameters_to_context and we can use avcodec_open2()
-
We have to convert the frame to 24-bit RGB format we have to allocate a new memory for the converted frames.
Even though we have allocated the frame, we still need a place to put the raw data when we convert it. We use av_image_get_buffer_size() and allocate the buffer manually
-
-
Now what we are doing is we will read through the entire video stream by reading in the packet (allocated memory for packet using av_packet_alloc()), decoding it into our. frame, once our frame is complete we will convert and save it. Also initialise the context for conversion of raw frame to RGB.
While av_read_frame() we will get a packet and send that packet to that buffer. Here the decoding is done by ffmpeg while recieving the frame using avcodec_recieve_frame() . Finally we use sws_scale() to convert the frame from native format to RGB format.