Find the frames which are similar in two videos - python

I am trying to find out the audio lag during a video call (in Zoom/ Google Meet). The r goal is to measure the lag in audio and video in the output (meeting attender's side).
For that, I have two video :
Vid1 (recording at presenter's side).
Vid2 (recording at attender's side).
Both the recordings can be started at any time during the meeting.
Now since I am comparing the videos, I need to find out the common frame between two videos. So that if I play the videos side by side, they should play in sync.
Since V1 and V2 is not same (V2 maybe pixelated), so how can two videos be compared to find the common frame?

Related

OpenCV - Apply multiple image analysis algorithms with different runtimes and synchronize the results to one image

I'm struggling with a real-time application I'm currently writing. I capture a webcam stream and apply multiple image processing algorithms to each individual frame, e.g. to get the emotion of a person in the frame and to detect objects in it.
Unfortunately, the algorithms have different runtimes and since some are based on neural networks, those in particular are slow.
My goal is, that I want to show a video stream without lags. I don't care if an image processing algorithm grabs only every n-th frame or shows the results with a delay.
To get rid of the lags, I put the image processing in different threads but I wonder if there is a more sophisticated way to synchronize my analysis on the video stream's frames - or maybe even a library that helps building pipelines for real time data analytics?
Every hint is welcome!

3D point cloud from continuous video stream of two (stereo) cameras

I have continuous videos taken from two cameras placed on up right and up left corners of my car's windshield (please note that they are not fixed to each other, and I aligned them approximately straight). Now I am trying to make a 3D point cloud out of that and have no idea how to do that. I surfed the internet a lot and still couldn't find any useful info. Can you send me some links or hints on how can I make that work in Python.
You can try the stereo matching and point cloud generation implementation in the OpenCV library. Start with this short Python sample.
I suppose that you have two independent video streams that are not exactly synchronized. You will have to synchronize them first, because the linked sample expects two images, not videos. Extract images from videos using OpenCV or ffmpeg and find an image pair that shares exactly the same timepoint (e.g. green appearing on a traffic light). Alternatively you can use the audio tracks for synchronization, see https://github.com/benkno/audio-offset-finder. Beware: synchronization based on a single frame pair or a short audio excerpt will probably work only for few minutes before and after the synchronized timepoint.

How to split video in python into 4 equal sections?

Are there any libraries in python that allow the input of a video file and then output 4 equal quadrants of that video files (eg: top left, top right, bottom left, bottom right)?
At the moment I have only seen examples that split the video in terms of length (eg: a 20 minute video into 5 minute sections)
I know its probably possible by using something like opencv to split the video into frames and then split each frame into 4 and the make the individual frames back into the video but I think this is very resource hungry and not the most efficient solution.
Any suggestions or examples will be appreciated.
You are right about OpenCV. You don't need to split into frames. You can used OpenCV or scikit-video to read videos into 4 dimensional array (height, width, frames, channel). Then once you have size of weidth and height, you can just extract 4 videos by indexing. e.g. if (400,600, 122, 3) is your video dimension, you can get 4 videos by:
v1=vid[:200,:300,:,:]
v2=vid[200:,:300,:,:]
v3=vid[200:,300:,:,:]
v4=vid[:200,300:,:,:]
You can find solution using ffmpeg on: related question
This may be memory-wise cheaper (specially required RAM) compared to OpenCV or scikit-video solution. But the solution I mentioned above using scikit-video is not computationally expensive.
read/write videos with scikit-video

Python image analysis - Check whether picture matches video frames

I have a problem, not so easy to solve i guess. In general, I have a database of frames from different videos and I want to find for a given picture (which is not necessarily one of the frames but from some same source video) the matching source video.
So lets say I have some videos and extracted frames each x seconds. The frames are stored in the db.
My guess would now be to loop over all video frames in the db and try to find matching features. So I would somehow have to find features in the source image and then try to find these in the frames stored in the db.
My question is how can I achieve this? The problem is that camera angle and vieweing distance can be quite different when the picture in question was not taken quite close to the time the frame was extracted previously.
Is this even feasible?
I'm working with Python and OpenCV.
Thanks and best regards

Multitrack Recording in PsychoPy

Is it possible to record from a mic while playback of an audio file continues?
If so, can I use a headphone splitter to record exactly what the listener hears to the same track?
Ideally, I would like a stereo audio file wherein one track is the original audio file, and the second track is what the mic simultaneously recorded.
Context:
In my experiment, participants will listen to audio clips, then attempt to synchronize with them using a musical instrument, while the audio clip continues to play.
It's really important I'm able to analyze how closely they are able to reproduce/temporally coordinate with the stimulus. I'm not too concerned with quality, as long as I can accurately compare event onsets.

Categories

Resources