Monday 15 July 2013

ffmpeg - Video decoding using ffms2 (ffmpegsource) -


I am using ffms2 (aka FFMPGSOS) to decode video frames and display on a UI based on wxWidgets. My player works fine for low resolution video (320 * 240, 640 * 480), but it is very slow for high resolution (1080) I am not able to prepare the desired frame for high-resolution video. After the time analysis I found that the FFMS_GetFrame () frame function takes a lot of time for high resolution frames. Here are the results 1. 320 × 240 FFMS_Getframes takes 4-6 MS 2. 640 × 480 FFMS_Getframe takes & gt; 20 ms 3. 1080 × 720 ffms_getframe takes & gt; 40

Which means that I will not fulfill 30 FPS requirements for 1080P frame with FFMS 2 but I'm not sure this is the case. Please suggest what could be wrong.

  zero set (int64 pos) {uint8_t * data_ptr = NULL; / * Check that the status is valid / or if (! M_track? Pos & lt; 0 & amp; amp; p; M_VideoPop-> NumFrames - 1) return; // ERR_POS; WxMilliClock_t start_wx_t = wxGetLocalTimeMillis (); Long start_t = start_wx_t.getValue (); M_frameId = pos; If (m_video) {m_frameProp = FFMS_GetFrame (m_video, m_frameId, and m_errInfo); If return (! M_frameProp); If (m_frameProp) {m_width_ffms2 = m_frameProp-> Encodedwidth; M_height_ffms2 = m_frameProp-> Encoded; } WxMilliClock_t end_wx_t = wxGetLocalTimeMillis (); Long-term end_to = end_wox_t.get value (); Long diff_t = end_t - start_t; WxLogDebug (wxString (wxT ("Frame Grab Milisek") + ToString (diff_t)); // m_frameInfo = FFMS_GetFrameInfo (m_track, FFMS_TYPE_VIDEO); / * If you want to change the size of the output colors or resize the output frame size, then it is time to do this now. Important: This phase is also required to prevent changes between resolutions and colors coming in between. You can always tell the original properties of the frame by checking the encoded properties in FFMS_frame. * / / * A -1 finished list of acceptable output formats (see pixfmt.h for a list of pixel formats / colors). To get the name of a given pixel format, strip the key PIX_FMT_ and convert it to lowercase. For example, PIX_FMT_YUV420P becomes "yuv420p" * / #if 0in pixfmt [2]; Pixfmt [0] = FFMS_GetPixFmt ("bgr24"); Pixfmt [1] = -1; #endif // FFMS_SetOutputFormatV2 returns 0 to success. It returns non-zero and sets an error message on failure. Full failure = FFMS_SetOutputFormatV2 (m_video, pixfmt, m_width_ffms2, m_height_ffms2, FFMS_RESIZER_BICUBIC, & amp; m_errInfo); If (failure) {// FFMS_DestroyVideoSource (m_video); // m_video = NULL; Return; // return ERR_POS; } Data_ptr = m_frameProp-> data [0]; } And {m_width_ffms2 = 320; M_height_ffms2 = 240; } If (data_ptr) {memcpy (m_buf, data_ptr, 3 * m_height_ffms2 * m_width_ffms2); } Other {Invitations (m_buf, 0, 3 * m_height_ffms2 * m_width_ffms2); }}    

Slow video decoding with large frames is completely normal, around 1080x720 10 times pixels are 320x240, so do not wonder about GetFrame ten times long (this is not strictly linear relationship because there are many other factors that play in decoding speeds, but the time to count and decode pixels is quite correlated ).

Setting the output format for each frame is unnecessary and it is making very slow unless you want to change the output format specifically unless you call it once after opening the video. And after that there will be application on all frames.

No comments:

Post a Comment