Giter Site home page Giter Site logo

How to use nvdec/nvenc about vidgear HOT 7 CLOSED

johnnynunez avatar johnnynunez commented on September 26, 2024
How to use nvdec/nvenc

from vidgear.

Comments (7)

abhiTronix avatar abhiTronix commented on September 26, 2024 1

I am trying to make a yolo detector using mp4 video or real time camera. I am trying to speed up my pipeline because the fps of the model is much higher than the video and the fps marked. How can I use hardware e.g. nvdec and nvenc to encode and decode the video?
I have opencv and ffmpeg with cuda. The device is a jetson agx orin

@johnnynunez Don't use OpenCV for video IO, but FFmpeg directly which supports both nvenc and nvenc to encode and decode the video. For this purpose, You could use my deffcode library instead which will be integrated soon in #148. The complete HW transcoding example is given in this docs: https://abhitronix.github.io/deffcode/latest/recipes/advanced/transcode-hw-acceleration/#hardware-accelerated-video-transcoding

Goodluck!

from vidgear.

welcome avatar welcome commented on September 26, 2024

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

from vidgear.

johnnynunez avatar johnnynunez commented on September 26, 2024

I am trying to make a yolo detector using mp4 video or real time camera. I am trying to speed up my pipeline because the fps of the model is much higher than the video and the fps marked. How can I use hardware e.g. nvenc and nvenc to encode and decode the video?
I have opencv and ffmpeg with cuda. The device is a jetson agx orin

@johnnynunez Don't use OpenCV for video IO, but FFmpeg directly which supports both nvenc and nvenc to encode and decode the video. For this purpose, You could use my deffcode library instead which will be integrated soon in #148. The complete HW transcoding example is given in this docs: https://abhitronix.github.io/deffcode/latest/recipes/advanced/transcode-hw-acceleration/#hardware-accelerated-video-transcoding

Goodluck!

but Does it have threaded-queue-mode too?? https://abhitronix.github.io/vidgear/v0.3.2-stable/bonus/TQM/#threaded-queue-mode

class FrameCapture:
    def __init__(self, source=0, stabilize=False, stream_mode=False, logging=False):
        self.source = source
        if isinstance(self.source, int):
            # Use CamGear for optimized live stream handling
            self.vcap = CamGear(source=self.source, stream_mode=stream_mode, logging=logging)
            height, width, _ = self.vcap.frame.shape
            self.fps = self.vcap.framerate
        else:
            # Use VideoGear for general video file handling
            self.vcap = VideoGear(source=self.source, stabilize=stabilize, stream_mode=stream_mode, logging=logging)
            height, width, _ = self.vcap.stream.frame.shape
            self.fps = self.vcap.stream.framerate
        self.video_info = sv.VideoInfo.from_video_path(self.source)
        self.frame_count = 0
        self.frame_size = (width, height)
        self.stopped = False

    def start(self):
        self.stopped = False
        self.vcap.start()

    def read(self):
        if not self.stopped:
            frame = self.vcap.read()
            if frame is None:
                self.stop()
                return None
            self.frame_count += 1
            return frame
        return None

    def get_frame_count(self):
        return self.frame_count

    def get_fps(self):
        return self.fps

    def get_frame_size(self):
        return self.frame_size

    def get_stop(self):
        return self.stopped

    def stop(self):
        # Safely close the video stream
        self.frame_count = 0
        # self.vcap.release()
        self.vcap.stop()
        self.stopped = True


if __name__ == '__main__':
    # Example usage:
    stream = FrameCapture(0)  # 0 for default webcam
    stream.start()

    try:
        input("Press Enter to stop...")
    finally:
        stream.stop()
        print("Exiting program")

from vidgear.

abhiTronix avatar abhiTronix commented on September 26, 2024

You don't need multi-threading here.

from vidgear.

johnnynunez avatar johnnynunez commented on September 26, 2024

You don't need multi-threading here.

and deffcode uses queue? Or only decoding?

from vidgear.

abhiTronix avatar abhiTronix commented on September 26, 2024

and deffcode uses queue? Or only decoding?

@johnnynunez No queue, just decoding. You could learn more about it here: https://abhitronix.github.io/deffcode/latest/recipes/advanced/decode-hw-acceleration/#hardware-accelerated-video-decoding

from vidgear.

johnnynunez avatar johnnynunez commented on September 26, 2024

and deffcode uses queue? Or only decoding?

@johnnynunez No queue, just decoding. You could learn more about it here: https://abhitronix.github.io/deffcode/latest/recipes/advanced/decode-hw-acceleration/#hardware-accelerated-video-decoding

Yeah it is working for me

from vidgear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.