Home > Net >  Using FFmpeg. AutoGen read camera error
Using FFmpeg. AutoGen read camera error

Time:09-16

Using FFmpeg. AutoGen read camera, according to the picture on the controls, and save the image to a file, read the normal at the beginning, voice, image can be saved, but read a few minutes later, the program when using av_read_frame, will read the data, error code - 5, camera also shut down automatically, direct use of FFmpeg. Exe to read the camera, save the file, can't have a problem for hours, read the logic of using is thor, how does this kind of error code returned to 5 come from, how should handle?
Logic code is as follows:
 
While (1)
{
If ((ret=ffmpeg. Av_read_frame (m_pVidFmtCtx dec_pkt))==0)
{
Ret=ffmpeg. Avcodec_send_packet (m_pVidFmtCtx - & gt; Streams [dec_pkt - & gt; stream_index] - & gt; The codec, dec_pkt);
While (ret & gt;=0)
{
Ret=ffmpeg. Avcodec_receive_frame (m_pVidFmtCtx - & gt; Streams [dec_pkt - & gt; stream_index] - & gt; The codec, pframe);
Ffmpeg. Sws_scale (img_rgb_ctx pframe - & gt; Data, pframe - & gt; Linesize, 0, cy, dstData, dstLinesize);
Var bitmap=new bitmap (, dstWidth, dstHeight dstLinesize [0], PixelFormat. Format24bppRgb, convertedFrameBufferPtr);
}
}
}
  •  Tags:  
  • C#
  • Related