Home > Back-end >  How to read ffmpeg AVPacket inside. The data of data, and save to a local file
How to read ffmpeg AVPacket inside. The data of data, and save to a local file

Time:11-02

Help you bosses:
Recently, I am ffmpeg novice, curriculum design need raw yuv data acquisition UVC infrared camera, and then through the operation temperature value of the object, the reference code on the net, grabbing a frame with ffmpeg av_read_frame function of original image, I want to put the AVPacket data pointer corresponding uint8_t data read into the memory (separate memory area, and the AVPacket completely independent), and then you can custom on the frame data for operation, at the same time can also keep the data is written to the local,

Below is my actual code, PKT is AVPacket structure pointer, but out of the test. The raw file size is not right, I'm looking forward to is 640 * 480 * 2 original yuv data, but the actual size is beyond this value, the , every brother please help me to find out which step cause the problem,

Ret=av_read_frame (CTX, & amp; PKT);//data read from the stream to the AVPacket

For (size_t I=0; I & lt; 640 * 480; I++) {
Buf_pkt [I]=PKT. Data [I];
Ofstream rawFile;
RawFile. Open (" Test. Raw ");
For (size_t I=0; I & lt; I & lt; 640 * 480; I++) {
RawFile & lt; }
RawFile. Close ();

Av_packet_unref (& amp; PKT);

  • Related