Video file length is 3 times lesser than the original video based on the resolution [closed]

asked 2019-12-16 01:35:37 -0600

nrajasekar gravatar image

updated 2020-01-03 06:57:56 -0600

supra56 gravatar image

Hi Thank you for the reply.

Is there any relationship between the Height and Width with FPS?

in my application I have set the FPS as 30 and Resolution: Width = 640 Height = 480;

the output saved video seems 90% Okay.

but when i set the resolution as below Width = 1280; Height = 720;

the video file length is 3 times lesser than the original video.(especially when checking with external camera. not laptop camera) for example, if i record the video for 3 minutes, but the video file has only 1 minute length.

Note: the code snippet is shared:

// This resolution working fine.
        private static int Width = 640;
        private static int Height = 480;
// This resolution is not working
        private static int Width = 1280;
        private static int Height = 720;

            capture = new VideoCapture(CaptureDevice.Any,index:1);

            capture.Fps = 30;
            capture.FrameWidth = Width;
            capture.FrameHeight = Height;

            // Read movie frames and write them to VideoWriter 
            // Size dsize = new Size(Width, Height);
            using (VideoWriter writer = new VideoWriter(longVideoName, FourCC.H264,capture.Fps, new Size(Width, Height)))
            {
                Console.WriteLine("Converting each movie frames...");
                Mat frame = new Mat();
                while (true)
                {
                    System.Diagnostics.Debug.WriteLine(System.DateTime.Now.ToString("O"));
                    // Read image
                    capture.Read(frame);
                    //  frame = capture.RetrieveMat();
                    if (frame.Empty())
                        break;

                    // Console.CursorLeft = 0;
                    Console.WriteLine("{0} / {1}", capture.PosFrames, capture.FrameCount);
                    Cv2.PutText(frame,
                                        System.DateTime.Now.ToString("O"),
                                        TimePoint,
                                        HersheyFonts.HersheySimplex,
                                        0.8,
                                        TimeScalar,
                                        1,
                                        LineTypes.Link8);
                    writer.Write(frame);

                }

Please help me on this.

Thanks, Rajasekar

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2019-12-16 01:52:18.742305

Comments

Is there any relationship between the Height and Width with FPS?

no, there isn't.

unfortunately we cannot help with your c# app, opencv does not support any c# bindings

berak gravatar imageberak ( 2019-12-16 01:43:32 -0600 )edit

Actually, if we increase the resolution of the video frame, the capture.Read method delays, due to that the eventhough if i set FPS as 30, only 10 frames are taken in a second

nrajasekar gravatar imagenrajasekar ( 2019-12-16 06:17:12 -0600 )edit

this probably never worked:

    capture.Fps = 0;
    capture.FrameWidth = Width;ain
    capture.FrameHeight = Height;

but again, we cannot know, what your code does there

berak gravatar imageberak ( 2019-12-16 06:23:19 -0600 )edit

Sorry. that is a type, the FPS is 30.

Actually, if we increase the resolution of the video frame, the capture.Read method delays, due to that the eventhough if i set FPS as 30, only 10 frames are taken in a second. is my understanding correct?

nrajasekar gravatar imagenrajasekar ( 2019-12-16 06:39:34 -0600 )edit