gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
988 stars 316 forks source link

Read .mjpeg (and stop?) #398

Open aolbrechts opened 5 years ago

aolbrechts commented 5 years ago

Hello,

I'm writing a small page/app that is used via the web to control the basic functions of a camera (change settings + take picture and download).

It rather works as I want for the moment (haven't implemented the timelapse functions I'm planning on) but I have issues with the liveview capture.

I'm using this code to start the capture : exec("gphoto2 --capture-movie --stdout | ffmpeg -i pipe:0 /var/www/html/fifo.mjpg");

I get a fifo.mjpg file but I can't open it anywhere (even VLC ... ?). I can't display it in a webpage either, I only get the first frame.

What could I do to verify that the live capture works?

(additional question : elsewhere in my script I have to end the live capture but I can't find what code to use? I have the code to bring the mirror down but it doesn't work because the live capture process is still in action).

Any help on this? Thanks for your help!

pReya commented 4 years ago

@aolbrechts Did you find a solution for this, yet?

aolbrechts commented 4 years ago

Unfortunately, no :(

[Adret & Ubac]https://www.adret-ubac.be Antoine Olbrechts | Web & Social media Consultant | Adret & Ubac [http://www.carmeldesign.be/signature_email/email_16.png] antoine@adret-ubac.bemailto:antoine@olbrechts.eu [http://www.carmeldesign.be/signature_email/web_16.png] www.adret-ubac.behttps://www.adret-ubac.be [http://www.carmeldesign.be/signature_email/twitter_16.png] @aolbrechtshttps://twitter.com/aolbrechts [http://www.carmeldesign.be/signature_email/facebook_16.png] sur facebookhttp://www.facebook.com/antoine.olbrechts.eu 5 sur les heids | 4053 Embourg | Belgique Tél +32 496 879 865

Le 18 oct. 2019 à 13:44, Moritz Stückler notifications@github.com<mailto:notifications@github.com> a écrit :

@aolbrechtshttps://github.com/aolbrechts Did you find a solution for this, yet?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/gphoto/libgphoto2/issues/398?email_source=notifications&email_token=AAKCZQJM4HEFK7S3AMHD5IDQPGOQDA5CNFSM4HA5AEFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBUBYOI#issuecomment-543693881, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKCZQJ5CNBTWBT2NWRJJA3QPGOQDANCNFSM4HA5AEFA.

msmeissn commented 4 years ago

to verify it works, you can run gphoto2 --capture-movie=10s on the commandline and see if that is playable in e.g. mplayer?

Parallel instances of gphoto2 accessing the same device will be tricky, as the cameras only support 1 session, so if you want to do configuration, capture and preview capture in parallel, it needs to be in one process.

Someone has likely written something like it already, i dont know it from the top of my head though.

pReya commented 4 years ago

To look at the live preview in VLC, you don't need ffmpeg or a FIFO, just the right CLI parameter for VLC. You need to specifiy a framerate at which the MJPEG should be played. You can test the framerate of your cam if you just run gphoto2 --capture-movie=10s. After 10s you will see how many frames were captured. Just divide this by 10 and you have a good value to put into this VLC parameter: gphoto2 --capture-movie --stdout | vlc - --mjpeg-fps 30