I've successfully installed mjpg-streamer-experimental from jacksonliam/mjpg-streamer.

I just can't figure out how to set the parameter I need in order to rotate my camera 180 degrees (I have my webcam mounted upside down for a custom mount I made).

I'm using a Logitech C270. I've been searching online for hours for a solution to this issue and just can't find what I'm looking for. Doesn't help that I'm not very proficient when it comes to this stuff.

If I run the command suggested in GiF's answer:

mjpg_streamer -i 'input_uvc.so -rot 180'

I get the following error:

 libv4l2: error setting pixformat: Device or resource busy Unable to set format: 1196444237 res: 640x480 Init v4L2 failed !! exit fatal i: init_VideoIn failed 

I seem to get that error when setting any parameters. I'm running Octoprint, if that makes any difference. There doesn't seem to be a rotate option in Octoprint.

Information just seems extremely sparse on this particular fork of mjpg-streamer. Searching for that error just gets me a bunch of people that have non-working webcams while mine works perfectly, I just need to rotate it 180 degrees.

I would really appreciate some help!


Edit: Having now installed Octopi myself, I have found that they made it easy to rotate the image right from the interface. If you open the "Settings" and look under "Webcam & Timelapse", there are settings for flipping the image horizontally or vertically and for rotating 90 degrees.

There are a few ways to rotate the image of which I am aware. You can do it via the input plugin, the client, or post-processing.

The "input_uvc" and "input_raspicam" plugins both have options to rotate the image. If you are using one of these plugins see the documentation at input_uvc or input_raspicam (it is worth noting that the input options may not be supported by all cameras). You should be able to run the command like the following to get a stream that is rotated 180 degrees:

mjpg_streamer -i 'input_uvc.so -rot 180'

I'm not sure how you are handling the stream, but it is possible that your client can perform the rotation. For example, if you are using VLC you can set the angle of rotation by doing something like this:

  • Open the “Tools” menu and select “Effects and Filters”
  • In the “Adjustments and Effects” window, on the “Video Effects” tab, select the “Transform” check box
  • Select a rotation from the dropdown menu and then click “Close”.

Finally, if you are saving the stream and are only concerned with rotating it afterwards, you can post-process it with a utility like ffmpeg. See this post as an example and look for "Rotate" in the accepted answer.

If your stream is being rendered via a browser you may be able to add some CSS3 formatting to the video element. For example, you could add an ID of videoElement to the stream and then add the following to your CSS:

 #videoElement {
    transform: rotateZ(180deg);
    -webkit-transform:rotateZ(180deg); /* Safari and Chrome */
    -moz-transform:rotateZ(180deg); /* Firefox */ 

With respect to Octoprint, it appears that Octoprint is an HTML interface, so you could probably edit the markup to use CSS3's transform rotateX. That would rotate the image at the client end (browser). BTW, googling for your error code did have some potentially useful information as well.


From the help for input plugin "raspicam", the following parameters can be passed to this plugin:

[-fps | --framerate]...: set video framerate, default 5 frame/sec
[-x | --width ]........: width of frame capture, default 640
[-y | --height]........: height of frame capture, default 480
[-quality].............: set JPEG quality 0-100, default 85
[-usestills]...........: uses stills mode instead of video mode
[-preview].............: Enable full screen preview
[-timestamp]...........: Get timestamp for each frame
-sh : Set image sharpness (-100 to 100)
-co : Set image contrast (-100 to 100)
-br : Set image brightness (0 to 100)
-sa : Set image saturation (-100 to 100)
-ISO : Set capture ISO
-vs : Turn on video stablisation
-ev : Set EV compensation
-ex : Set exposure mode (see raspistill notes)
-awb : Set AWB mode (see raspistill notes)
-ifx : Set image effect (see raspistill notes)
-cfx : Set colour effect (U:V)
-mm : Set metering mode (see raspistill notes)
-rot : Set image rotation (0-359)
-stats : Compute image stats for each picture (reduces noise for -usestills)
-drc : Dynamic range compensation level (see raspistill notes)
-hf : Set horizontal flip
-vf : Set vertical flip

The -rot parameter can rotate the image.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.