User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Thu Jan 21, 2016 9:34 am

Nidez wrote:
jacksonliam wrote:The video streaming method might actually work though. But if you want me to look into it you'd have to gift me some hardware.
this is not a problem at all !
jacksonliam wrote:Have you considered using the raspberry pi compute module with two cameras hooked up? It might even be possible to combine the images in the GPU if you went that way.
did not understand what you mean
jacksonliam wrote:Or could you use two raspberry pis and combine the image at the other end? Or stream one pi to the other and combine the images there?
if i cannot succesfully get a multiplexed video this will be the final solution, but the overall device cost will be too high.

can we PM and try to find an agreement ?
I mean that the raspberry pi "compute module" allows you to connect two cameras at once and it would certainly have better performance than the ivport.
The ivport may be easier/cheaper/simpler though.

Feel free to pm me.

ronnyvdbr
Posts: 68
Joined: Sun Mar 01, 2015 8:42 pm

Re: Streaming mjpg from Raspberry Cam

Sat Feb 06, 2016 8:26 pm

Very nice tool, wonderfull programming, coudln't do it myself because I lack the necessary C programming skills. Thank you for this.
I'm currently building a Raspberry Pi IP Camera with easy configurable bootstrap/php web interface, and want to incorporate your version of mjpeg streamer into it since it has a direct input plugin for the mmal camera api, I believe that's key to success instead of having to work with any file sink since these wear out the sd card.

I'm trying to compare this solution against my already built Raspberry Pi's with UV4L2 and H.264 RTSP streaming.
I do need to note that these are currently performing better if it comes to full resolution, 1080p x 30 fps streaming.
When using your mjpg streamer on this resolution the image seems to be a bit choppy.
I doubt the bottleneck here is bandwidth related.
When measuring with iftop, I can measure around 85 Mbps in 1280x720x30 mode, while I only measure around 65 Mbps in 1920x1080x15 mode.

My Raspi's currently running this H.264 streaming are using the UV4L2 framework and raspicam drivers from linux-projects. I don't know from which source they have compiled there raspicam drivers though, perhaps they are a better and faster breed?

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Sat Feb 06, 2016 8:55 pm

ronnyvdbr wrote:Very nice tool, wonderfull programming, coudln't do it myself because I lack the necessary C programming skills. Thank you for this.
I'm currently building a Raspberry Pi IP Camera with easy configurable bootstrap/php web interface, and want to incorporate your version of mjpeg streamer into it since it has a direct input plugin for the mmal camera api, I believe that's key to success instead of having to work with any file sink since these wear out the sd card.

I'm trying to compare this solution against my already built Raspberry Pi's with UV4L2 and H.264 RTSP streaming.
I do need to note that these are currently performing better if it comes to full resolution, 1080p x 30 fps streaming.
When using your mjpg streamer on this resolution the image seems to be a bit choppy.
I doubt the bottleneck here is bandwidth related.
When measuring with iftop, I can measure around 85 Mbps in 1280x720x30 mode, while I only measure around 65 Mbps in 1920x1080x15 mode.

My Raspi's currently running this H.264 streaming are using the UV4L2 framework and raspicam drivers from linux-projects. I don't know from which source they have compiled there raspicam drivers though, perhaps they are a better and faster breed?
The issue is mjpg, it's very inefficient compared to h.264.
I looked into the UV4L2 implementation, this mmal code is actually more efficient for mjpg.

15fps video will obviously look more choppy than 30fps. You can't run 1080p at 30fps because it goes above 100mbit - the limit for the ethernet interface on the Pi.

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming mjpg from Raspberry Cam

Sat Feb 06, 2016 9:11 pm

ronnyvdbr wrote:I'm trying to compare this solution against my already built Raspberry Pi's with UV4L2 and H.264 RTSP streaming.
UV4L incorporates a very efficient and highly tunable MJPEG server (see the manuals for details). In particular, it scales better than any other existing server in case of multiple clients because of special employed algorithms. No need of other software if you are already using UV4L for H264.

NewToRpi
Posts: 2
Joined: Thu Jun 23, 2016 5:02 pm

Re: Streaming mjpg from Raspberry Cam

Thu Jun 23, 2016 5:12 pm

Hi Liam,
I have installed your code and it is working fine. Thank you for this great project.
However, I need to set the shutter speed to a fixed value to control the exposure for the RPI camera. I noticed that the MMAL in the current project is not the most recent. The most recent MMAL includes more parameters including the shutter speed (-ss). Do you have any plan to integrate the latest MMAL in near future?

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Thu Jun 23, 2016 8:32 pm

NewToRpi wrote:Hi Liam,
I have installed your code and it is working fine. Thank you for this great project.
However, I need to set the shutter speed to a fixed value to control the exposure for the RPI camera. I noticed that the MMAL in the current project is not the most recent. The most recent MMAL includes more parameters including the shutter speed (-ss). Do you have any plan to integrate the latest MMAL in near future?
I have a pull request waiting for me to get around to testing on older pis that adds in some of the newer options https://github.com/jacksonliam/mjpg-streamer/pull/27

You can checkout that branch if you need that feature now!

NewToRpi
Posts: 2
Joined: Thu Jun 23, 2016 5:02 pm

Re: Streaming mjpg from Raspberry Cam

Fri Jun 24, 2016 6:34 pm

jacksonliam wrote:
NewToRpi wrote:Hi Liam,
I have installed your code and it is working fine. Thank you for this great project.
However, I need to set the shutter speed to a fixed value to control the exposure for the RPI camera. I noticed that the MMAL in the current project is not the most recent. The most recent MMAL includes more parameters including the shutter speed (-ss). Do you have any plan to integrate the latest MMAL in near future?
I have a pull request waiting for me to get around to testing on older pis that adds in some of the newer options https://github.com/jacksonliam/mjpg-streamer/pull/27

You can checkout that branch if you need that feature now!
Thank you. I was able to download the modified project
wget https://github.com/jacksonliam/mjpg-streamer
/archive/6a48626bffd818c3d8655e5aae095e62f0db8328.zip

It complied and worked fine (limited testing). MMAL is up to date. however as likeitlikeit mentioned, seems he only added 2 options. The other options such as -ss have not been integrated. If I could make any positive contribution in the code here, I will let you know.

I have another question
since I have to use non-stock lens in our project, I have to do some kind of shading correction or lens distortion compensation. What do you think is the most efficient way to integrate this in mjpg-streamer? I was thinking of somewhere in the middle of image flow, I would need to decode the jpeg image and encode it back to jpeg again for streaming. Is this really the best I can do? Could it be somewhere just before rendering the final image?

User avatar
jbeale
Posts: 3500
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Streaming mjpg from Raspberry Cam

Fri Jun 24, 2016 9:01 pm

NewToRpi wrote:since I have to use non-stock lens in our project, I have to do some kind of shading correction or lens distortion compensation.
Automatic lens shading compensation was added as the raspistill "-st" option (force image statistics pass) in Sept. 2014. This is done inside the GPU (ISP) before image encoding, so there is no CPU overhead. Here is the thread on that topic: viewtopic.php?t=84416&p=623444#p615529

Presumably the same could be done with MJPEG streaming output(?)

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Fri Jun 24, 2016 11:03 pm

NewToRpi wrote:
jacksonliam wrote:
NewToRpi wrote:Hi Liam,
I have installed your code and it is working fine. Thank you for this great project.
However, I need to set the shutter speed to a fixed value to control the exposure for the RPI camera. I noticed that the MMAL in the current project is not the most recent. The most recent MMAL includes more parameters including the shutter speed (-ss). Do you have any plan to integrate the latest MMAL in near future?
I have a pull request waiting for me to get around to testing on older pis that adds in some of the newer options https://github.com/jacksonliam/mjpg-streamer/pull/27

You can checkout that branch if you need that feature now!
Thank you. I was able to download the modified project
wget https://github.com/jacksonliam/mjpg-streamer
/archive/6a48626bffd818c3d8655e5aae095e62f0db8328.zip

It complied and worked fine (limited testing). MMAL is up to date. however as likeitlikeit mentioned, seems he only added 2 options. The other options such as -ss have not been integrated. If I could make any positive contribution in the code here, I will let you know.

I have another question
since I have to use non-stock lens in our project, I have to do some kind of shading correction or lens distortion compensation. What do you think is the most efficient way to integrate this in mjpg-streamer? I was thinking of somewhere in the middle of image flow, I would need to decode the jpeg image and encode it back to jpeg again for streaming. Is this really the best I can do? Could it be somewhere just before rendering the final image?
Cool! Erm right the handling in mjpg-streamer is pretty much copy paste from the raspivid so you can probably look how they do the option in there, otherwise I'll get to it at some point... Ha!

Lens correction sounds like an interesting problem. You can probably make the MMAL libs output something like a YUV or RGB888 buffer rather than jpeg so that you don't have to decode. You can probably also set up a separate pipeline and feed the buffer back into the GPU to the video encoder set to mjpeg, but I haven't done any of that before and I'm not sure that you can run the camera and encode seperately and simultaneously.

On a Raspberry Pi 2/3 (as long as you keep the resolution and framerate sane) software encoding of the frames isn't too bad. The uvc plugin is setup to do yuv to jpeg in software so you can use the code from there.

If you do figure out how to send frames back into the encoder I'd like to use it for the uvc plugin!
jbeale wrote:
NewToRpi wrote:since I have to use non-stock lens in our project, I have to do some kind of shading correction or lens distortion compensation.
Automatic lens shading compensation was added as the raspistill "-st" option (force image statistics pass) in Sept. 2014. This is done inside the GPU (ISP) before image encoding, so there is no CPU overhead. Here is the thread on that topic: viewtopic.php?t=84416&p=623444#p615529

Presumably the same could be done with MJPEG streaming output(?)
Or that, that sounds easier!

mitchallen
Posts: 2
Joined: Fri Jul 15, 2016 11:14 pm
Location: Arizona USA
Contact: Website

Re: Streaming mjpg from Raspberry Cam

Fri Jul 15, 2016 11:21 pm

I'm having an issue with a Pi 3 + a NoIR Camera V2. I pointed the camera at a thermometer and noticed that the text and reading were backwards (as if looking in a mirror). Here is the history of what I did, with two different commands at the end:

$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/
$ cd mjpg-streamer-experimental/
$ sudo apt-get install cmake
$ sudo apt-get install python-imaging
$ make CMAKE_BUILD_TYPE=Debug
$ sudo make install
$ export LD_LIBRARY_PATH=.
$ ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"
$ ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so -x 1280 -y 720 -fps 15 -ex night"

Any ideas what the issue might be?

Thanks.
https://desertbot.io

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Sat Jul 16, 2016 9:54 am

mitchallen wrote:I'm having an issue with a Pi 3 + a NoIR Camera V2. I pointed the camera at a thermometer and noticed that the text and reading were backwards (as if looking in a mirror). Here is the history of what I did, with two different commands at the end:

$ git clone https://github.com/jacksonliam/mjpg-streamer.git
$ cd mjpg-streamer/
$ cd mjpg-streamer-experimental/
$ sudo apt-get install cmake
$ sudo apt-get install python-imaging
$ make CMAKE_BUILD_TYPE=Debug
$ sudo make install
$ export LD_LIBRARY_PATH=.
$ ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so"
$ ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so -x 1280 -y 720 -fps 15 -ex night"

Any ideas what the issue might be?

Thanks.
Try adding -hf to the input_raspicam options

xenonhex
Posts: 2
Joined: Sun Jul 17, 2016 4:36 am

Re: Streaming mjpg from Raspberry Cam

Sun Jul 17, 2016 5:05 am

Hi new to the forum/thread;

I have had success installing and using mjpeg-streamer on a raspi zero, but ran into some issues I thought I would share; specifically no manual shutter speed and invalid timestamps. Before that though, thanks for the great software.

There does not seem to be a way to manually set the exposure time with input_raspicam, so I dug around and patched the current github version to have it. In order to make this work I also had to switch out the mmal directory with the one on my raspbian install due to the shutter speed stuff not being in the current github one. I basically copy pasted from this commit https://github.com/JamesH65/userland/co ... c1b1ebf3b4 "Userland issue #76 Added option to set the exposure/shutter time." in the most appropriate places I could find. Getting the option exposed as a command line arg (-shutter) took some digging, but it seems to work now (taking microseconds i think).

The other issue I ran into was that the timestamps for each jpeg were all set to 0.00000 (I think the timestamp was being read from a v4l structure but it was being set to 0 for every image). I tried just sampling the time on the receiving end in the python script as soon as the jpeg magic sequence end was found but there was still a lot of variance/delay with this approach. I tested it by taking consecutive images of a time app (with 0.1s precision display) on my phone with the camera, and this approach gave 1-3s offset.

I worked around this by also patching my local copy of mjpeg-streamer inside the send_stream function of plugins/output_http/httpd.c to call gettimeofday immediately following pthread_cond_wait /* wait for a fresh frame */ and using that value instead for the X-Timestamp field of the jpeg. https://github.com/jacksonliam/mjpg-str ... tpd.c#L458 Doing the same test of free running capture of the time display app on a phone in front of the camera, the offset of the jpeg timestamp vs the time shown on the app in the image dropped down to a much more consistent ~0.2s. I still need to do more tests to confirm the consistency of this, but 0.2s is good enough for my needs for now.

I have attached a sample image of the offset test I did.

Is there an easy way I can share thee changes to perhaps be integrated into the repo? Hopefully I didn't break a bunch of conventions thus making the changes worthless :)
Attachments
2016-07-16_03-55-19-246796_img.jpg
2016-07-16 03:55:19.246796 timestamp from gettimeofday inside send_stream() (~0.2s offset)
2016-07-16_03-55-19-246796_img.jpg (29.46 KiB) Viewed 8036 times

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Jul 17, 2016 8:07 pm

xenonhex wrote:Hi new to the forum/thread;

I have had success installing and using mjpeg-streamer on a raspi zero, but ran into some issues I thought I would share; specifically no manual shutter speed and invalid timestamps. Before that though, thanks for the great software.

There does not seem to be a way to manually set the exposure time with input_raspicam, so I dug around and patched the current github version to have it. In order to make this work I also had to switch out the mmal directory with the one on my raspbian install due to the shutter speed stuff not being in the current github one. I basically copy pasted from this commit https://github.com/JamesH65/userland/co ... c1b1ebf3b4 "Userland issue #76 Added option to set the exposure/shutter time." in the most appropriate places I could find. Getting the option exposed as a command line arg (-shutter) took some digging, but it seems to work now (taking microseconds i think).

The other issue I ran into was that the timestamps for each jpeg were all set to 0.00000 (I think the timestamp was being read from a v4l structure but it was being set to 0 for every image). I tried just sampling the time on the receiving end in the python script as soon as the jpeg magic sequence end was found but there was still a lot of variance/delay with this approach. I tested it by taking consecutive images of a time app (with 0.1s precision display) on my phone with the camera, and this approach gave 1-3s offset.

I worked around this by also patching my local copy of mjpeg-streamer inside the send_stream function of plugins/output_http/httpd.c to call gettimeofday immediately following pthread_cond_wait /* wait for a fresh frame */ and using that value instead for the X-Timestamp field of the jpeg. https://github.com/jacksonliam/mjpg-str ... tpd.c#L458 Doing the same test of free running capture of the time display app on a phone in front of the camera, the offset of the jpeg timestamp vs the time shown on the app in the image dropped down to a much more consistent ~0.2s. I still need to do more tests to confirm the consistency of this, but 0.2s is good enough for my needs for now.

I have attached a sample image of the offset test I did.

Is there an easy way I can share thee changes to perhaps be integrated into the repo? Hopefully I didn't break a bunch of conventions thus making the changes worthless :)
I would like to add all the available raspicam options but still thinking of the best way to go about it.

I'm not sure calling gettimeofday on every frame is something I'd want to add by default but I think it needs to be set in the raspicam plugin not in the default output. Perhaps I need a -timestamp option.

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Fri Aug 05, 2016 10:26 pm

xenonhex wrote:Hi new to the forum/thread;

I have had success installing and using mjpeg-streamer on a raspi zero, but ran into some issues I thought I would share; specifically no manual shutter speed and invalid timestamps. Before that though, thanks for the great software.

There does not seem to be a way to manually set the exposure time with input_raspicam, so I dug around and patched the current github version to have it. In order to make this work I also had to switch out the mmal directory with the one on my raspbian install due to the shutter speed stuff not being in the current github one. I basically copy pasted from this commit https://github.com/JamesH65/userland/co ... c1b1ebf3b4 "Userland issue #76 Added option to set the exposure/shutter time." in the most appropriate places I could find. Getting the option exposed as a command line arg (-shutter) took some digging, but it seems to work now (taking microseconds i think).

The other issue I ran into was that the timestamps for each jpeg were all set to 0.00000 (I think the timestamp was being read from a v4l structure but it was being set to 0 for every image). I tried just sampling the time on the receiving end in the python script as soon as the jpeg magic sequence end was found but there was still a lot of variance/delay with this approach. I tested it by taking consecutive images of a time app (with 0.1s precision display) on my phone with the camera, and this approach gave 1-3s offset.

I worked around this by also patching my local copy of mjpeg-streamer inside the send_stream function of plugins/output_http/httpd.c to call gettimeofday immediately following pthread_cond_wait /* wait for a fresh frame */ and using that value instead for the X-Timestamp field of the jpeg. https://github.com/jacksonliam/mjpg-str ... tpd.c#L458 Doing the same test of free running capture of the time display app on a phone in front of the camera, the offset of the jpeg timestamp vs the time shown on the app in the image dropped down to a much more consistent ~0.2s. I still need to do more tests to confirm the consistency of this, but 0.2s is good enough for my needs for now.

I have attached a sample image of the offset test I did.

Is there an easy way I can share thee changes to perhaps be integrated into the repo? Hopefully I didn't break a bunch of conventions thus making the changes worthless :)
I have added the timestamp option to the raspicam input plugin to fetch and attach the timestamp to every frame, which sets the X-Timestamp header if you use output_http. Use it like so:

Code: Select all

./mjpg_streamer -i "input_raspicam.so -x 1280 -y 720 -timestamp" -o "output_http.so -w ./www"

xenonhex
Posts: 2
Joined: Sun Jul 17, 2016 4:36 am

Re: Streaming mjpg from Raspberry Cam

Fri Aug 05, 2016 10:42 pm

jacksonliam wrote:
xenonhex wrote:Hi new to the forum/thread;
[...]
I have added the timestamp option to the raspicam input plugin to fetch and attach the timestamp to every frame, which sets the X-Timestamp header if you use output_http. Use it like so:

Code: Select all

./mjpg_streamer -i "input_raspicam.so -x 1280 -y 720 -timestamp" -o "output_http.so -w ./www"
YOU DA MAN!! Thank you for integrating this CLI option; I've been using it to show sequences of patterns on a display/projector and capture images of each one (hopefully avoiding images taken while the pattern was changing, getting a blurred mix etc), and the timestamps are very useful in tightening up that sync loop between changing patterns and saving selected images. :)

Waszker
Posts: 6
Joined: Sun Sep 11, 2016 1:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 1:17 pm

Hi all,
I have question regarding re-streaming video from IP cameras.
I want to buy FOSCAM FI8904W camera and according to this thread: http://foscam.us/forum/how-to-fetch-sna ... t4328.html getting MJPEG stream is as simple as entering URL in form of: [url]http://ip_address:port/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr=admin&pwd=xxx[/url]

Now what I would like to achieve is to run mjpg-streamer on my rasoberry pi that gets the stream from camera and creates its own stream. The reason I want it that way is that my ip cam won't be accessible from outside of lan whereas raspberry pi is connected to wan.

I would like to know if something like this can be achieved? Camera supports also streaming via rtsp.

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 3:57 pm

Waszker wrote:Now what I would like to achieve is to run mjpg-streamer on my raspberry pi that gets the stream from camera and creates its own stream.
http://www.linux-projects.org/uv4l/tuto ... to-camera/

User avatar
jacksonliam
Posts: 181
Joined: Tue Feb 07, 2012 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 5:16 pm

RpiName wrote:
Waszker wrote:Now what I would like to achieve is to run mjpg-streamer on my raspberry pi that gets the stream from camera and creates its own stream.
http://www.linux-projects.org/uv4l/tuto ... to-camera/
I tend to avoid the 'linux projects.org' uv4l stuff. It's closed source.

mjpg-streamer can proxy other streams but it expects them to come from other instances of mjpg-streamer, but might work with some modification of the source.
If not there is an input rtsp plugin which you could try out, but I've never tried it.

Alternatively setup a reverse proxy to forward requests to your actual camera e.g https://github.com/foosel/OctoPrint/wik ... n-examples

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 5:40 pm

jacksonliam wrote: I tend to avoid the 'linux-projects' uv4l stuff. It's closed source.
You should not be using the Raspberry Pi at all then, as part of the GPU having to do with the camera is notoriously closed source too? I'd tend not to look a gift horse in the mouth and use what best fits my needs. Good luck.

Waszker
Posts: 6
Joined: Sun Sep 11, 2016 1:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 6:35 pm

Thank you both for your input.
Solution with uv4l generally works fine but I got error when trying to stream video over VPN.
I managed to add device by this command:

Code: Select all

uv4l --driver mjpegstream --video_nr 0 --uri "http://10.8.0.1:8080/?action=stream"
and got /dev/video0 device

Now when I try to stream video:

Code: Select all

LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so mjpg_streamer -i "input_uvc.so -n -f 25 -d /dev/video0" -o "output_http.so -p 7777"
I get this error:

Code: Select all

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video4
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 25
 i: Format............: JPEG
 i: TV-Norm...........: DEFAULT
 i: Could not obtain the requested pixelformat, got: Test
 Init v4L2 failed !! exit fatal 
 i: init_VideoIn failed
This happens when I try to stream video between two different devices over the VPN. One of them has USB webcam connected (IP address 10.8.0.1) with working mjpg_streamer service and I want the second one (IP address 10.8.0.2) to re-stream video. Everything works fine if I do the same steps as mentioned above but on the device with webcam connected (IP address 10.8.0.1) (in other words: no errors when creating second mjpg_streamer instance for the device created by uv4l command).

Could this be related to very poor bandwidth?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 6:54 pm

Waszker wrote:and got /dev/video0 device

Now when I try to stream video I get this error:

Code: Select all

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video4
[/quote]

from the above mjpeg-streamer is trying to access /dev/video4 while you said you got /dev/video0? This does not seem ok.

[quote]
This happens when I try to stream video between two different devices over the VPN. One of them has USB webcam connected (IP address 10.8.0.1) with working mjpg_streamer service and I want the second one (IP address 10.8.0.2) to re-stream video. Everything works fine if I do the same steps as mentioned above but on the device with webcam connected (IP address 10.8.0.1) (in other words: no errors when creating second mjpg_streamer instance for the device created by uv4l command).

Could this be related to very poor bandwidth?[/quote]

It's not totally clear what you are trying to achieve, but have you considered to get rid of mjpeg-streamer at all in your chain (or at least on 10.8.0.2) as UV4L both supports USB webcams and already provides a built-in MJPEG server? Moreover it can turn the HTTP(S)/MJPEG stream into WebRTC which works better in low bandwidth conditions.

Waszker
Posts: 6
Joined: Sun Sep 11, 2016 1:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 7:07 pm

RpiName wrote:
Waszker wrote:and got /dev/video0 device

Now when I try to stream video I get this error:

Code: Select all

MJPG Streamer Version.: 2.0
 i: Using V4L2 device.: /dev/video4
[/quote]

from the above mjpeg-streamer is trying to access /dev/video4 while you said you got /dev/video0? This does not seem ok.
[/quote]

Whooops sorry. The error mentioned /dev/video0 but I tried to add device few times and ended up with 5 different names. I just copied wrong error message.

[quote="RpiName"][quote]
This happens when I try to stream video between two different devices over the VPN. One of them has USB webcam connected (IP address 10.8.0.1) with working mjpg_streamer service and I want the second one (IP address 10.8.0.2) to re-stream video. Everything works fine if I do the same steps as mentioned above but on the device with webcam connected (IP address 10.8.0.1) (in other words: no errors when creating second mjpg_streamer instance for the device created by uv4l command).

Could this be related to very poor bandwidth?[/quote]

It's not totally clear what you are trying to achieve, but have you considered to get rid of mjpeg-streamer at all in your chain (or at least on 10.8.0.2) as UV4L both supports USB webcams and already provides a built-in MJPEG server? Moreover it can turn the HTTP(S)/MJPEG stream into WebRTC which works better in low bandwidth conditions.[/quote]

Ok so I'll try to explain more clearly. I just wanted to test your solution. I have one RaspberryPi with USB webcam connected which currently has mjpg_streamer service that provides video streaming that I can access via browser. First thing I did was to check your solution and add new video device on this Raspberry to check if I can spawn additional mjpeg_streamer that would provide video stream using newly-created device. It worked well.

The next thing I wanted to check was how this solution will behave over the Internet. I have second RaspberryPi device elsewhere with no webcams connected. Both Raspberries are in the same VPN. So I tried to add video device using uv4l command on this second Raspberry. It worked but when trying to test quality of stream I got this mjpg_streamer error. And right now I don't know what should be blamed - bandwidth or something else. Eventually I'd like to install IP camera which video stream I'd like to forward via this second Raspberry (the one without USB webcam). This camera is quite expensive and that's why I'm trying to test all possibilities to minimize the risk of failure :)

Waszker
Posts: 6
Joined: Sun Sep 11, 2016 1:09 pm

Re: Streaming mjpg from Raspberry Cam

Sun Sep 11, 2016 8:02 pm

RpiName wrote:(...) but have you considered to get rid of mjpeg-streamer at all in your chain (or at least on 10.8.0.2) as UV4L both supports USB webcams and already provides a built-in MJPEG server? Moreover it can turn the HTTP(S)/MJPEG stream into WebRTC which works better in low bandwidth conditions.
It does the job indeed and I think I'll use that if mjpg_streamer won't work. Thanks.

jester32
Posts: 16
Joined: Wed Aug 31, 2016 1:33 am

Re: Streaming mjpg from Raspberry Cam

Fri Sep 16, 2016 1:48 am

would someone look over my issue and see if you can tell me a solution.

viewtopic.php?f=28&t=159940&p=1038188#p1038188

Nem2k
Posts: 2
Joined: Sat Sep 24, 2016 4:18 am

Re: Streaming mjpg from Raspberry Cam

Sun Oct 09, 2016 4:17 am

I have a daily cronjob that starts my mjpeg stream. It runs the following script:

Code: Select all

#!/usr/bin/env bash
cd /home/pi/Desktop/mjpg-streamer/mjpg-streamer-experimental

./mjpg_streamer -o "output_http.so -w ./www -p 7272" -i "input_raspicam.so -x 640 -y 480 -fps 15"
What can I add to the script so that it checks whether the stream is already running, and only starts the streamer if its not already running?

Return to “Camera board”