ffmpegcv icon indicating copy to clipboard operation
ffmpegcv copied to clipboard

Different behavior with Opencv.

Open simonlsp opened this issue 1 year ago • 2 comments

Issue:

In H264 encoded MTS files, ffmpegcv read twice frames than cv2. Other programs (including Premere Pro and Windows) report same results as cv2, not ffmpegcv.

Code

>>> import cv2
>>> import ffmpegcv
>>> capture_cv2 = cv2.VideoCapture("1-1.MTS")
>>> capture_cv2.get(cv2.CAP_PROP_FPS)
25.0
>>> capture_cv2.get(cv2.CAP_PROP_FRAME_COUNT)
15086.0
>>> capture_cv2.release()
>>> capture_ffmpegcv = ffmpegcv.VideoCapture("1-1.MTS")
>>> capture_ffmpegcv.fps
50.0
>>> capture_ffmpegcv.count
30134
>>> capture_ffmpegcv.release()

simonlsp avatar May 13 '24 18:05 simonlsp

I cannot reproduct your bug. Things look all fine for me.

ffmpeg -i input.mp4 -c:v libx264 output.mts
In [1]: import ffmpegcv

In [2]: vid1 = ffmpegcv.VideoCapture('input.mp4')

In [3]: len(vid1)
Out[3]: 27026

In [4]: vid2 = ffmpegcv.VideoCapture('output.mts')

In [5]: len(vid2)
Out[5]: 27026

In [6]: for i in range(10000000):
   ...:     ret, frame = vid1.read()
   ...:     if ret == False:
   ...:         break
   ...: 
   ...: print('frame count', i)
frame count 27026

In [7]: for i in range(10000000):
   ...:     ret, frame = vid2.read()
   ...:     if ret == False:
   ...:         break
   ...: 
   ...: print('frame count', i)
frame count 27026

Can you send me a short piece of your video or link. I'll check it.

[email protected]

chenxinfeng4 avatar May 14 '24 01:05 chenxinfeng4

I'll send the video in about a week.

simonlsp avatar May 15 '24 14:05 simonlsp