Ask Your Question

Revision history [back]

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

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 = 0;
        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

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

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 = 0;
        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

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

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 = 0;
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

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

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 sharedshared:

// 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

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

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;

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