Fantom
Posts: 5
Joined: Sun Dec 14, 2014 9:58 am

Re: Streaming mjpg from Raspberry Cam

Tue Dec 16, 2014 1:02 pm

I have one question : wchich do I version mjpg-stream install ??

http://www.raspberrypi.org/forums/viewt ... 15#p655415

Fantom

User avatar
liudr
Posts: 685
Joined: Sat Jun 01, 2013 12:11 am
Location: Central MN, USA
Contact: Website

Re: Streaming mjpg from Raspberry Cam

Sat Dec 27, 2014 5:42 am

Liam,

If you are still watching this thread, I have a question:

I am able to run your code but I'm not able to view the video. I tried opening browser on my PC using RPI's IP address and on RPI itself inside a browser. On RPI inside a browser, the error 404 has invalid input plugin number error message. Any idea what is going on? Thanks.
Arduino data loggers, user interface, printed circuit board designer since 2009, RPI 3B 2B 2B Zero Jessie, assembly/C/C++/java/python programmer since the 80's

kenmoore
Posts: 5
Joined: Thu Jul 04, 2013 7:33 am

Re: Streaming mjpg from Raspberry Cam

Thu Apr 09, 2015 4:27 am

I have a serious issue to report, which has cost me at least 6 hours of troubleshooting -- the default fps for input_raspicam.so is 1 fps. When I try to stream at fps 1, the video is almost completely black (I can very faintly see the bright can lights in the ceiling of my room, but nothing else). Higher frame rates show proper exposure, but interestingly a frame rate of 2 fps starts out very dim but brightens up over the next few frames.

I've tested and gotten this same outcome using 2 different cameras, and using both a RPi 1 Model B and RPi 2.

It seems to me to be a very serious bug. Is anyone else able to reproduce this result?

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

Re: Streaming mjpg from Raspberry Cam

Sun Apr 12, 2015 1:15 pm

kenmoore wrote:I have a serious issue to report, which has cost me at least 6 hours of troubleshooting -- the default fps for input_raspicam.so is 1 fps. When I try to stream at fps 1, the video is almost completely black (I can very faintly see the bright can lights in the ceiling of my room, but nothing else). Higher frame rates show proper exposure, but interestingly a frame rate of 2 fps starts out very dim but brightens up over the next few frames.

I've tested and gotten this same outcome using 2 different cameras, and using both a RPi 1 Model B and RPi 2.

It seems to me to be a very serious bug. Is anyone else able to reproduce this result?
Try the -usestills option with fps < 5, There's nothing I can do about it, See: viewtopic.php?f=43&t=44066

Possibly I could make the default for fps == 1 to usestills, with a usevid option.

codeforge
Posts: 9
Joined: Fri May 01, 2015 10:09 pm

Re: Streaming mjpg from Raspberry Cam

Mon May 04, 2015 9:53 pm

Hi,
when I use the output_http.so plugin mjpeg-streamer will make a http-server. I already have apache2 running and making 2 http server make my raspberry very slow. Is there a way to load /?action=stream in a html page or javascript code using a http server already existent?

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

Re: Streaming mjpg from Raspberry Cam

Tue May 05, 2015 6:11 am

codeforge wrote:Hi,
when I use the output_http.so plugin mjpeg-streamer will make a http-server. I already have apache2 running and making 2 http server make my raspberry very slow. Is there a way to load /?action=stream in a html page or javascript code using a http server already existent?
Nope, the http server is required to serve the jpeg images too.
It won't use a lot of resources if used correctly. How many users are viewing the stream at the same time and what command are you using to launch mjpg streamer?

braddo
Posts: 9
Joined: Wed May 06, 2015 2:20 am

Re: Streaming mjpg from Raspberry Cam

Wed May 06, 2015 4:14 pm

Hey guys, I'm wondering if anyone knows about using "advanced" uvc camera controls with mjpg-streamer when a usb webcam is in place?

I'm using something called OctoPi, which is a Raspbian OS with Octoprint and mjpg-streamer installed, it's great for controlling a 3d printer remotely.

My challenge is that the camera is blurry because the default focus distance isn't right for the application. In previous cases I have been able to run the following: guvcview and uvcdynctrl to add some controls (Focus distance especially) to the uvc camera and then actually make changes while mjpg-streamer is running.

Currently though, the camera seems to be locked by mjpg-streamer and I can't run those commands. If I turn streamer off then I can. But useless without being able to use them together.

The OctoPi installation seems to use base mjpg-streamer rather than experimental, could this be the difference? The OctoPi installation deletes the experimental directory so I can't really try it, besides there are a bunch of automated dependencies, I'm pretty sure I would just break it :-)

Just curious if someone else has solved this challenge of getting Focus (even better would be pan/tilt for cams that support) control into mjpg-streamer or just making it not clamp the camera process so uvcdynctrl can't adjust it.

Thanks!

braddo
Posts: 9
Joined: Wed May 06, 2015 2:20 am

Re: Streaming mjpg from Raspberry Cam

Wed May 06, 2015 5:58 pm

BTW, I looked more closely at the OctoPi script and it does use the experimental build of mjpg-streamer.

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

Re: Streaming mjpg from Raspberry Cam

Wed May 06, 2015 6:49 pm

I run octoprint and am very familiar with octopi. Are you using a USB webcam or the pi cam? What mjpg streamer did you use to view when they did work? What do those commands output when they don't work?

semofa
Posts: 21
Joined: Mon Jun 01, 2015 8:18 pm

audio and video streaming

Tue Jun 09, 2015 4:22 pm

Hi Liam,
I've successfully used your code and streamed video to my computer. everything was grate!no latency!
now I wanna stream video with audio. I have two raspberry pi. first one stream video and audio and second one just display it. how can i do that ? please help me

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

Re: audio and video streaming

Tue Jun 09, 2015 5:24 pm

semofa wrote:Hi Liam,
I've successfully used your code and streamed video to my computer. everything was grate!no latency!
now I wanna stream video with audio. I have two raspberry pi. first one stream video and audio and second one just display it. how can i do that ? please help me
Unfortunately you cannot stream audio with mjpg, you'll need to find another method!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23931
Joined: Sat Jul 30, 2011 7:41 pm

Re: audio and video streaming

Tue Jun 09, 2015 5:25 pm

semofa wrote:Hi Liam,
I've successfully used your code and streamed video to my computer. everything was grate!no latency!
now I wanna stream video with audio. I have two raspberry pi. first one stream video and audio and second one just display it. how can i do that ? please help me
You could try putting together a gstreamer pipeline that does both video and audio. Bit difficult to explain how here, I'd suggest googling for how to do this. You will need a microphone on the Pi first...
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

kenmoore
Posts: 5
Joined: Thu Jul 04, 2013 7:33 am

Re: Streaming mjpg from Raspberry Cam

Sat Jun 13, 2015 4:17 am

Hi Liam,

I'm hoping you can give a little guidance on a related crash I'm encountering. I'm streaming from my RPi to a VM in the cloud which processes the frames using node.js and OpenCV. Every once in a while a corrupt file comes across and crashes OpenCV's readImage() function call. I'd love to fix the source issue, but I'd settle for some way to skip the corrupt images, though I don't know what tool would allow me to detect them.

Here's a good image and a bad image:
good: https://drive.google.com/file/d/0B8_Soj ... sp=sharing
bad: https://drive.google.com/file/d/0B8_Soj ... sp=sharing

I used SynalizeIt to analyze the file contents and found that whereas the good JPG shows a ImageData length of 157700, the bad JPG shows ImageData length of 14, which is obviously bad:
good: https://drive.google.com/file/d/0B8_Soj ... sp=sharing
bad: https://drive.google.com/file/d/0B8_Soj ... sp=sharing

(the circled byte is the first byte where the 2 files differ, for what it's worth)

The bad JPG image can be viewed in OSX Finder with no issues and renders fine in Chrome / Firefox, but...
- shows missing a ~20px strip at the bottom in Google Drive's viewer
- shows "an unexpected end of file was encountered" error when opened in Photoshop
- crashes OpenCV's readImage() function, which has me blocked

I tried using the ImageMagick module for node, but the identify() function yields lots of metadata but nothing indicating that it's anything other than a healthy image.

Thanks in advance for any light you can shed here.

Ken

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

Re: Streaming mjpg from Raspberry Cam

Sat Jun 13, 2015 9:24 am

kenmoore wrote:Hi Liam,

I'm hoping you can give a little guidance on a related crash I'm encountering. I'm streaming from my RPi to a VM in the cloud which processes the frames using node.js and OpenCV. Every once in a while a corrupt file comes across and crashes OpenCV's readImage() function call. I'd love to fix the source issue, but I'd settle for some way to skip the corrupt images, though I don't know what tool would allow me to detect them.

Here's a good image and a bad image:
good: https://drive.google.com/file/d/0B8_Soj ... sp=sharing
bad: https://drive.google.com/file/d/0B8_Soj ... sp=sharing

I used SynalizeIt to analyze the file contents and found that whereas the good JPG shows a ImageData length of 157700, the bad JPG shows ImageData length of 14, which is obviously bad:
good: https://drive.google.com/file/d/0B8_Soj ... sp=sharing
bad: https://drive.google.com/file/d/0B8_Soj ... sp=sharing

(the circled byte is the first byte where the 2 files differ, for what it's worth)

The bad JPG image can be viewed in OSX Finder with no issues and renders fine in Chrome / Firefox, but...
- shows missing a ~20px strip at the bottom in Google Drive's viewer
- shows "an unexpected end of file was encountered" error when opened in Photoshop
- crashes OpenCV's readImage() function, which has me blocked

I tried using the ImageMagick module for node, but the identify() function yields lots of metadata but nothing indicating that it's anything other than a healthy image.

Thanks in advance for any light you can shed here.

Ken
Hi Ken, interesting use of this. I can't help with the nodejs side, but if it's a problem I can reproduce here I could try to fix it. My first instinct is its in the mjpg streamer core and not my code though.

Can you give me more info about how you're using the plugin, e.g framerate, resolution, are you using the usestills flag? How are you getting the frames in the cloud, are you using the ?action=stream URI?

Are you saying the image is fine, full formed, but the length is wrong or are you saying that it's missing some information? Is the image datadata mostly identical to the previous frame?

kenmoore
Posts: 5
Joined: Thu Jul 04, 2013 7:33 am

Re: Streaming mjpg from Raspberry Cam

Tue Jun 16, 2015 2:55 pm

Hey Liam, thanks for the quick reply. For some reason the images are arriving corrupted / incomplete -- I don't know enough about the JPEG spec to say where the corruption source is though. Most of the image is identical to the other images, but the ImageData section (according to SynalizeIt) shows with a very short length (even though lots of image data actually is present in the file).

I'm going to track down the source of the incomplete JPGs, I want to do an experiment to save a copy of each image on the streaming server so when the system crashes I can see if perhaps the camera is failing. But I'm going on vacation soon and won't be able to follow up for a couple weeks. Will check back in...

YesPapa
Posts: 21
Joined: Wed Jun 03, 2015 1:24 pm

Re: Streaming mjpg from Raspberry Cam

Tue Jun 30, 2015 2:01 pm

HI,

Where can I find some step by step instructions to install this "mjpg-streamer" fork?

I try to do those of the github but I miss something. I have correctly installed the "mjpg-streamer" original but I can't do it with this one.

Thank you.

Trunyx
Posts: 3
Joined: Wed Aug 26, 2015 9:20 am

Re: Streaming mjpg from Raspberry Cam

Sat Oct 17, 2015 5:29 pm

Sorry, but I have to dig this thread up again...

I used this guide http://blog.miguelgrinberg.com/post/how ... spberry-pi to get the stream running.
But when I am trying to execute the final command I get an error.
"could not add watch: no such file or directory"
"can not run input plugin 0: input_file.so"

But I followed everything. All directories and files exist. Does somebody have a clue what the hell is going wrong here?

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

Re: Streaming mjpg from Raspberry Cam

Sat Oct 17, 2015 6:33 pm

Trunyx wrote:But I followed everything. All directories and files exist. Does somebody have a clue what the hell is going wrong here?
you want to stream MJPEG and/or JPEG Stills over HTTP? You might have a better luck with this alternative:

http://www.linux-projects.org/modules/s ... e&artid=14

Screenshots:

http://www.linux-projects.org/downloads ... /index.png
http://www.linux-projects.org/downloads ... /panel.png

User avatar
Demontager
Posts: 9
Joined: Thu Apr 24, 2014 11:27 am
Location: Ukraine
Contact: ICQ Website

Re: Streaming mjpg from Raspberry Cam

Tue Nov 17, 2015 9:54 pm

I am going to stream video from raspberry pi 2 to VLC with Logitech C910 webcam. Tried to use mjpeg_streamer, but can't compile it from source, getting "fatal error: bcm_host.h: No such file or directory"
Full log https://gist.github.com/Demontager/2f62ef2c684e4d331a8f

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

Re: Streaming mjpg from Raspberry Cam

Wed Nov 18, 2015 8:14 am

Demontager wrote:I am going to stream video from raspberry pi 2 to VLC with Logitech C910 webcam. Tried to use mjpeg_streamer, but can't compile it from source, getting "fatal error: bcm_host.h: No such file or directory"
Full log https://gist.github.com/Demontager/2f62ef2c684e4d331a8f
You do not need to / should not use my 'fork' if you want to use a USB webcam. It's only useful if you want to use the raspi cam. You can use the normal mjpeg streamer.

Anyone else having trouble compiling, let me know.

User avatar
Demontager
Posts: 9
Joined: Thu Apr 24, 2014 11:27 am
Location: Ukraine
Contact: ICQ Website

Re: Streaming mjpg from Raspberry Cam

Wed Nov 18, 2015 9:06 am

Ok, understood. And which one is the main repo ? Github has 83 repos https://github.com/search?utf8=%E2%9C%9 ... g-streamer
I compiled this one https://github.com/oliv3r/mjpg-streamer as it has latest commits. Camera is working but the problem that camera can start one time then failed because errors in kernel. https://gist.github.com/anonymous/3cc35c80c877053992d6

Nidez
Posts: 3
Joined: Mon Jan 18, 2016 9:52 pm

Re: Streaming mjpg from Raspberry Cam

Mon Jan 18, 2016 10:06 pm

Hi jacksonliam
.. and really thank you for your work.
for my project I need to stream from 2 different raspicams and I need 10/15 fps at 640x480 with -q 50% at least.
I was planning to use https://github.com/ivmech/ivport as multiplexer as I've seen the "stereo video capture" video.

I had successfully used your plugin with one raspicam and read all this thread, and I've understood you are piping the buffer from raspivid output inside of the http plugin, while you also have the -usestill option to switch to the classic raspistill way.

As far as I've understood from https://github.com/ivmech/ivport/blob/m ... rt_fast.sh the multiplexer code example uses the "still" way... and it seems to me it has some delay ( several sleeps: 1sec, 0.3 secs and 1 sec again here: https://github.com/ivmech/ivport/blob/m ... rt_fast.py )

My question for you:
is there a way to implement a real multiplexing from 2 cameras using the raspivid mode ?
or
is there a way to use the -usestill (and multiplexing) and obtain a 10 fps video ? (ok i can lower the fps down to 5, but i need no latency between reality and video)

I have some budget for the project, as I don't like to ask for help for free, I will return(some$) if you can find a way to do it.
tnx.

Nidez
Posts: 3
Joined: Mon Jan 18, 2016 9:52 pm

Re: Streaming mjpg from Raspberry Cam

Mon Jan 18, 2016 10:18 pm

my dummy idea is about:
keep on using the raspivid way but changing the pin setup at each function loop as described here https://github.com/ivmech/ivport/blob/m ... rt_fast.py then simply query the pin status and outputing the frame to a different http stream (and port) according to the pin status.

the resulting framerate will be the initial one, divided by the number of the output used, minus some overhead introduced by the pin change and query

can it be done ?

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

Re: Streaming mjpg from Raspberry Cam

Mon Jan 18, 2016 10:48 pm

Nidez wrote:Hi jacksonliam
.. and really thank you for your work.
for my project I need to stream from 2 different raspicams and I need 10/15 fps at 640x480 with -q 50% at least.
I was planning to use https://github.com/ivmech/ivport as multiplexer as I've seen the "stereo video capture" video.

I had successfully used your plugin with one raspicam and read all this thread, and I've understood you are piping the buffer from raspivid output inside of the http plugin, while you also have the -usestill option to switch to the classic raspistill way.

As far as I've understood from https://github.com/ivmech/ivport/blob/m ... rt_fast.sh the multiplexer code example uses the "still" way... and it seems to me it has some delay ( several sleeps: 1sec, 0.3 secs and 1 sec again here: https://github.com/ivmech/ivport/blob/m ... rt_fast.py )

My question for you:
is there a way to implement a real multiplexing from 2 cameras using the raspivid mode ?
or
is there a way to use the -usestill (and multiplexing) and obtain a 10 fps video ? (ok i can lower the fps down to 5, but i need no latency between reality and video)

I have some budget for the project, as I don't like to ask for help for free, I will return(some$) if you can find a way to do it.
tnx.
It's tricky because the raspberry pi GPU outputs the encoded jpeg in a buffer. I think with a bit of trickery and an image width divisible by 16 you can combine the image data and write new headers without a too much overhead.

I'd be surprised if you get even 8fps switching cameras, and that's halved because you have two cameras so effectively 4fps best case. The delays in ivport might even be necessary to stop the camera/multiplexer/gpu from locking up so after all that work we might still get poor performance.

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.

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.
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?

Nidez
Posts: 3
Joined: Mon Jan 18, 2016 9:52 pm

Re: Streaming mjpg from Raspberry Cam

Mon Jan 18, 2016 10:58 pm

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 ?

Return to “Camera board”