jschmid1 / gopro_as_webcam_on_linux

Allows to use your GoPro camera as a webcam on linux
Apache License 2.0
531 stars 67 forks source link

Using this asseet with VideoCapture in OpenCV #58

Closed otets-u closed 8 months ago

otets-u commented 11 months ago

Hello, I really appreciate your great work about this repository.

Now, I'm trying to use this assets with VideoCapture in C++ OpenCV like below. But, neither of them doesn't work. Could you give me some advice?

    cv::VideoCapture cap("udp://@0.0.0.0:8554");  
    // or below
    // cv::VideoCapture cap("udp://@:8554");
    if (!cap.isOpened()) {
        std::cout << "camera error." << std::endl;
        return -1;
    }

On the other hand, I could confirm that the below command work well after I entered 'sudo gopro webcam' and see video stream.

# command for ffmepg
ffmpeg -nostdin -threads 1 -i 'udp://@0.0.0.0:8554?overrun_nonfatal=1&fifo_size=50000000' -f:v mpegts -fflags nobuffer -vf format=yuv420p -f v4l2 /dev/video42

# command for VLC
vlc -vvv --network-caching=300 --sout-x264-preset=ultrafast --sout-x264-tune=zerolatency --sout-x264-vbv-bufsize 0 --sout-transcode-threads 4 --no-audio udp://@:8554

Thank you.

danlahatk commented 9 months ago

Hi, do you have any conclusions from your issue ? I am facing the same issue and would love some help. Thanks!

otets-u commented 8 months ago

I'm sorry about late reply.

Finally, I could access the below python code after starting the gopro webcam and ffmpeg.

terminal

# start gopro webcam
cd ~/gopro_as_webcam_on_linux
sudo gopro webcam

# start ffmpeg
ffmpeg -nostdin -threads 1 -i 'udp://@0.0.0.0:8554?overrun_nonfatal=1&fifo_size=50000000' -f:v mpegts -fflags nobuffer -vf format=yuv420p -f v4l2 /dev/video42

OpenCV VideoCapture

    self.capture = cv2.VideoCapture("/dev/video42")