How to Stream Live Feed From DSLR on Raspberry Pi using FFServer

In this short post, I will walk you through the steps for streaming a live camera feed from a DSLR connected to the Raspberry Pi. We will be using gphoto2 for interfacing with the camera, FFmpeg for encoding the video, and FFserver for hosting the feed on a local webserver.
Prerequisites
Hardware
For this tutorial, I am assuming that you have a Raspberry Pi with Raspbian or Noob OS installed on it. You can get a Raspberry Pi from Amazon if you don’t already have one.
Also, I am assuming that you already have one of the supported cameras listed here:
I used the Canon Rebel T7 camera which I got from Amazon.
Software
Install libghoto2 and ghoto2. Check out the setup instructions in this post for installing these libraries on a Rasberry Pi.
Install FFmpeg and FFserver. Check out this post for step by step instructions.
Setup FFServer
We will be creating a mpeg
stream available at /test.swf
. Create a file at /etc/ffserver.conf
and the following contents in it.
Note: I am using the configs as mentioned in this thread. Checkout FFserver docs for more configuration options.
Start the server:
ffserver -d -f /etc/ffserver.conf
Publish the Stream
We would be using ghoto2 to capture live camera preview from the DSLR and will then be encoding it to mjpg format using ffmpeg. Finally, we will be serving this file to feed1.ffm
as defined in the ffserver.conf
file. This command achieves all of the above:
gphoto2 --capture-movie --stdout | ffmpeg -re -i pipe:0 -listen 1 -f swf http://localhost:8090/feed1.jpg
View the Stream
Create a simple HTML page and embed the stream URL in it.
<html>
<body>
<object style="width: 600px; height: 600px;" data="http://192.168.0.4:8090/test1.swf"></object>
</body>
</html>
Open the HTML file in the browser and you should be able to view the stream.
Note: You will need to enable Flash support in your browser. Also, keep in mind that Flash support might permanently be gone from the browsers by the end of the year.
That’s it for this post. I hope you will find this post useful. I found the above information in a comment on this thread. All credits to vincent for suggesting this solution.