How to find out the frame rate of a video? - opencv

How to find out the frame rate of a video ?How to do in C++ OpenCV?
I want to read the different number of video with respective of frames per second.
It has to work on all Video formats? .Avi, .MP4, .Flv

easy (just take with a grain of salt, see remarks below):
VideoCapture cap("ma.avi");
double fps = cap.get(CV_CAP_PROP_FPS);

Related

Obtaining matching image frames from videos with two different frame rates

I am in the process of converting videos to images in python3.6 (i.e. cut videos to get images)
I have two types of videos
The first one is a RGB video recorded from Real sense D435i with a frame rate of 30 (i.e. fps= 30)
The second one is a thermal-IR video recorded from Flir Adas camera with a frame rate of 9 (It was originally a frame stream file which i converted to images and formulated it into a video with fps of 9 using python3-cv2).
The video formats are in mp4 and avi respectively (though I have converted the avi to mp4 and tested it out as well).
They are equal in length.
I am trying to create a matched image pair from the thermal and IR videos. However, when I seem to cut them using the same frame rate, it seems like they don't match (but differ by 5-6 images).
I have about 200 ish videos so it is very time consuming and difficult for me to track them down one by one.
Any ideas on how I can get this dataset to make it a paired one?
Many thanks
You might be able to recreate the 30 fps video as a matching 9 fps video by matching up the timestamps of the two videos. OpenCV lets you specify the framerate in the VideoWriter (I think you knew this, but just to be sure). OpenCV reports the timestamp of the current video with
cv2.VideoCapture.get(cv2.CAP_PROP_POS_MSEC);
Grab one frame and timestamp from the FLIR camera and then keep grabbing frames and timestamps from the color camera until the timestamp catches up or passes the FLIR timestamp. Then write the color frame to the vidwriter. So long as both of the videos had a consistent framerate and they both started/stopped recording at the same time then this should see both videos matched up as closely as possible.
What about just converting the 9 fps videos to 30 fps with a simple ffmpeg script over the list of files:
ffmpeg -i source9fps.mp4 -r 30 -c:v libx264 -c:b 10M out30fps.mp4
#-c:b ... bitrate
or:
ffmpeg -i source9fps.mp4 -r 30 -c:v copy out30fps.mp4
(Without reencoding, very fast)
30 vs 9 fps is a nasty combination though, there will be a skew and I'm not sure about the exact conversion algorithm (some blending might be better due to the skew at frames with a big temporal mismatch).
It'd be better if the second video was recorded at 5, 10 or 15 fps.

How to use Wireshark to get the bitrate of an online video

For example, set the resolution to auto and let the online video plays,
How can I measure the bit rate of this video transmission?
I've captured a pcapng file, it should be under TCP, but which ones are transmitting video clips? How should I check?

How to record video with low audio quality

I am working on a project, we want to minimize the size in the sound part of a video. I know we can use ACAudioSession to record a pure audio, and can set the quality detailed into sampling rate, number of channels.
But when I want to design a video taker which record records audio at the same time. I found for the AVCaptureSession, I can only set the quality of video and audio together using sessionPreset, which leads the quality of video and audio decrease at the same time.
I am wondering whether there is a way to keep the video in high quality while manage to reduce the size of audio when taking a video?
Appreciate for the help.

OpenCV: GoPro video editing blur

I am attempting to post-process a video in OpenCV. The problem is that the GoPro video is very blurry, even with a high frame rate.
Is there any way that I can remove blur? I've heard about deinterlacing, but don't know if this applies to a GoPro 3+, or where even to begin.
Any help is appreciated.
You can record at a high frame rate to remove any blur, also make sure you are recording with enough natural light, so recording outdoors is recommended.
Look at this video: https://www.youtube.com/watch?v=-nU2_ERC_oE
At 30 fps, there is some blur in the car, but at 60fps the blur is non existant, just doubling the FPS can do some good. Since you have a HERO3+ you can record 720p 60 and that will remove the blur. WVGA 120fps can also do some justice (example is 1080p but still applies)

Process Slow Motion Video Effect iOS

How would I go about creating a slow motion effect on a portion of a video recorded or obtained from the camera roll in iOS? I am using the AVFoundation framework to select a video from the camera roll or record a video. I intend to add the effect from Time1 to Time2 and then let the video continue at a normal speed.
Generally speaking you create a slow motion effect by recording at a higher frame rate. So if you record at 60FPS but playback at 30FPS, then you have created a half time slow motion effect. This is how it is done with film. With prerecorded fixed frame rate footage you could playback at a fraction of the original frame rate. If this is to be saved back to a container file, then you will need to adjust the presentation time stamps accordingly.

Resources