<div dir="ltr">Hi all,<div><br></div><div>I have a web cam that can stream MJPEG or raw video. By default libav API initializes raw video.</div><div>How can I read MJPEG stream?</div><div><br></div><div>Code below shows how I am doing it right now (my VideoEncoder reads stream from webcam and encodes it into MPEG):</div>
<div><br></div><div><div>m_pInputFormat = av_find_input_format("video4linux2");</div><div><br></div><div>AVFormatParameters formatParams;</div><div>formatParams.channel   = 0;</div><div>formatParams.standard  = 0; // no standard</div>
<div>formatParams.width     = m_VideoEncoderSettings.WidthIn();</div><div>formatParams.height    = m_VideoEncoderSettings.HeightIn();</div><div>formatParams.time_base = (AVRational){1,m_VideoEncoderSettings.FramesPerSecond()};</div>
<div>//formatParams.video_codec_id = CODEC_ID_MJPEG;</div><div><br></div><div>if (!OpenVideoFile  (m_pFormatCtx, m_VideoEncoderSettings.DeviceName().c_str(), m_pInputFormat, &formatParams)) return (false);</div><div>if (!FindStreamInfo (m_pFormatCtx, m_VideoEncoderSettings.DeviceName().c_str()))                                                    return (false);</div>
<div>if (!FindVideoStream(m_pFormatCtx, m_VideoStream))                                                                                                return (false);</div></div><div><br></div><div>I can set the resolution and the framerate using the above code but switching do MJPEG doesn't work.</div>
<div><br></div><div>Any help will be highly appreciated.</div><div><br></div><div>Thank you,</div><div>Vlad.</div></div>