-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to read lenght of file in frame and how to jump to specific frame #53
Comments
I want to use vidgear with for webcam and also the file loading. video_pos =int(cap.get(cv2.CAP_PROP_POS_FRAMES)) but I get error Some question is how I can jump to specific frame. Thanks for the answer |
@TomasTrnkaPLC This is not a bug or issue with vidgear, you can easily access frame position with vidgear as follows: from vidgear.gears import CamGear
import cv2
cap = CamGear(source='test.mp4').start()
video_pos =int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES)) Why it is not advisable to use VidGear for jumping/seeking specific frame?VidGear provides a high-level Threaded wrapper around OpenCV's API that targets only specific methods and classes related to Video Processing. It is possible to access other methods too but not advisable with VidGear as it uses Threads and Queue structure for capturing frame, which can result in undesired effects with those methods. Therefore you should refrain yourself from using frame jumping/seeking in VidGear but rather use OpenCV directly for this purpose. Why it is not advisable to use Frame Jumping/Seeking in OpenCV at all?OpenCV is still in beta stage, with many bugs that remain unsolved. The Here is the comment from Alexander Alekhin(Lead developer at OpenCV):
Hence, Kindly refrain from using Frame Jumping/Seeking with OpenCV at all. Hope this helps good luck. |
Thanks for the reply.
That is a nice example. I already implement and definitely I move from cv
to your solution. Really soon you get a new "example" how is
implement VidGear in app :)
I have one more question
when I try run = cap.stream.set(cv2.CAP_PROP_POS_FRAMES,trackbarValue) I
get reply True but stream never jump there. I talking about the jump when
is file loaded.
And one more thing. write.gear run really well. I just use an example and
on Windows 7 64bit is everything ok but, on Windows 10 scripts only create
an empty .mp4 file and never record anything. Why?
I does receive any error everything looks fine the only mp4 is empty.
Thanks
…On Mon, Sep 9, 2019 at 5:00 AM Abhishek Thakur ***@***.***> wrote:
My program is based on frame position so I use code like this:
video_pos =int(cap.get(cv2.CAP_PROP_POS_FRAMES))
but I get error
AttributeError: 'CamGear' object has no attribute 'get' how I can fix it?
Some question is how I can jump to specific frame.
@TomasTrnkaPLC <https://github.com/TomasTrnkaPLC> This is not a bug or
issue with vidgear, *you can easily access frame position with vidgear as
follows:*
from vidgear.gears import CamGear
import cv2
cap = CamGear(source='test.mp4').start()
video_pos =int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES))
*
|
@TomasTrnkaPLC I already told you that OpenCV is still buggy and cannot reliably seek/jump frame due to a inherit bug. You can see this issue in OpenCV Github repository related to this bug: opencv/opencv#9053 which is still unsolved.
@TomasTrnkaPLC Wrong, I tested all my VidGear scripts on Windows 10 x64 machine, There must a problem at your end. Kindly paste the terminal log here for further debugging the error which is causing this problem. |
Thanks for the reply.
1. Jump to the frame. Yes, you are right but I use the latest version
OpenCV 4 and jump is without the problem.
OK, I made some test and now I not sure if I do something wrong.
This is a code
if (trackbar_new == True):
cap.stream.set(cv2.CAP_PROP_POS_FRAMES,trackbarValue)
print('I try to jump')
video_pos = int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES))
globals().update(current_video_position = video_pos)
if I do this then nothing happens. Funny is video_pos be updated correctly
but the video continues without any effect.
If I do this so stop-cap before. (I cannot figure out how to only "pause
streaming"). Then I jump to position how I want but video be stoped and
don't want to continue.
if (trackbar_new == True):
cap.stop() #TO DO How to pause????
cap.stream.set(cv2.CAP_PROP_POS_FRAMES,trackbarValue)
cap.start()
print('I try to jump')
video_pos = int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES))
globals().update(current_video_position = video_pos)
If you load your video and have for example 100 frames you start play from 1 to .... So far so good. you use this
if (trackbar_new == True): cap.stream.set(cv2.CAP_PROP_POS_FRAMES,trackbarValue) print('I try to jump') video_pos = int(cap.stream.get(cv2.CAP_PROP_POS_FRAMES)) globals().update(current_video_position = video_pos)
If you want to jump to frame 50 and your position is under 50 nothing happens. If is your frame position more like 50 you jump to frame 50. Seems to be ok. So the problem is if you want to jumpto frame what you don't play yet. I hope this helps you of course if I'm not doing anything wrong.
2. Thanks for the tip I forgot about that.
Thanks for your time.
|
Hi.
I want to use vidgear with for webcam and also the file loading.
For webcam or youtube run everything well problem is when I load the video.
My program is based on frame position so I use code like this:
video_pos =int(cap.get(cv2.CAP_PROP_POS_FRAMES))
but I get error
AttributeError: 'CamGear' object has no attribute 'get' how I can fix it?
Some question is how I can jump to specific frame.
Thanks for the answer
Question
Acknowledgment
Context
Your Environment
Optional
The text was updated successfully, but these errors were encountered: