Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to capture movie to stdout #15

Closed
mfk-smart opened this issue Jun 5, 2016 · 3 comments
Closed

How to capture movie to stdout #15

mfk-smart opened this issue Jun 5, 2016 · 3 comments
Labels

Comments

@mfk-smart
Copy link

Hi,

I'm trying to capture movie to stdout and pipe it to ffmpeg to stream video to another computer. I can do it from shell with the following command in shell :

gphoto2 --capture-movie --stdout | ffmpeg -i pipe:0 http://localhost:8080/feed1.ffm

As first step I tried to capture a movie :
gp.gp_camera_capture(camera, gp.GP_CAPTURE_VIDEO, context)

but i got the following error:

gphoto2.GPhoto2Error: [-6] Unsupported operation

Is capturing video not supported in python-gphoto2?

@jim-easterbrook
Copy link
Owner

python-gphoto2 should support everything libgphoto2 does, so the real question is how to do movie capture (with your camera model) in libgphoto2. It may be that the gphoto2 command line application is doing something else, e.g. capturing a sequence of preview stills.
I can't find any examples of movie capture with libgphoto2 - they're all using the command line program. Asking on the gphoto2 mailing list might help - no need to mention Python as once we know how to do it in C/C++ it should be easy to write the Python equivalent.

@roipoussiere
Copy link
Contributor

Looking at gphoto sources, it seams that --capture-movie is an infinite loop of capture previews, which can be done with gp.gp_camera_capture_preview(camera) (as used in the preview image example).

@ofrzeta
Copy link

ofrzeta commented Jun 29, 2020

For everyone coming here later:


import gphoto2 as gp
from subprocess import Popen, PIPE

camera = gp.Camera()
camera.init()
ffmpeg = Popen(['ffmpeg', '-i', '-', '-vcodec', 'rawvideo', '-pix_fmt', 'yuv420p', '-f', 'v4l2', '/dev/video1'], stdin=PIPE)

while True:
  capture = camera.capture_preview()
  filedata = capture.get_data_and_size()
  data = memoryview(filedata)
  ffmpeg.stdin.write(data.tobytes())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants