# Integration of MJPG Format Camera

**URL:** <https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932>\
**Category:** Blue Robotics Software\
**Created:** [December 17, 2018, 8:12pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932 "2018-12-17T20:12:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@Jake](https://discuss.bluerobotics.com/u/Jake)\
**Post date:** [December 17, 2018, 8:12pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/1 "2018-12-17T20:12:29Z")

</div>

Hey all,  
I’ve been doing some research trying to get a camera I have working. This particular camera is only capable of MJPG pixel formatting. Is there any chance I can integrate it with the existing BlueROV2 software? I’ve read around the forum and it seems to be a common issue as Qground control apparently does not support anything other that h264 pixel formatting. Has anyone had success with MJPG formatting? Is there a known workaround? Or am I out of luck?

Jake

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [December 17, 2018, 8:23pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/2 "2018-12-17T20:23:10Z")

</div>

Hi Jake,

Yes it’s possible, the only problem is the encode that’ll be necessary to convert MJPG to H264.  
This is an example of how to create a gstreamer pipeline from MJPG to H264.

```auto
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=720,type=video,framerate=30/1 ! jpegdec ! videoscale ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! udpsink host=192.168.1.146 port=5600

```

Try to read more about gstreamer and figure out the best configuration for your camera.

> Note: the encode process will use 100% of the cpu and may result in a unstable system and low fps.

Also, take a look here:

> [@Companion C270 logitech camera](https://discuss.bluerobotics.com/t/companion-c270-logitech-camera/3617/6):
>
> Hi Ryan, Yes it is possible, but you’ll have 2s+ delays in the video and can be much more worst if the processor or the system start to hangs (high cpu temperature and power consumption). But… If you really really want to use it, you’ll need to study gstreamer pipelines and read some good documentation to build your own gstreamer pipeline, start with [x264enc](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-ugly-plugins/html/gst-plugins-ugly-plugins-x264enc.html), but the final result will not work as the way you want.

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [December 18, 2018, 2:11am UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/3 "2018-12-18T02:11:43Z")

</div>

If you are running on a raspbery I strongly suggest that you use the omx encoder, as it can use hardware encoding in the gpu. This won’t be enough to stream 1080p at any decent framerate, but you can tweak resolution and framerate and maybe get something acceptable.

You can get it with `apt install gstreamer1.0-omx` and then  
Then replace `x264enc` with ` omxh264enc` (you might need to tweak other things in the pipeline).

I’ve used this for streaming an analog thermal camera on another application, as the camera had a small resolution (around 640x480) and framerate (9 fps) the CPU usage was negligible.

---

<div class="post-metadata">

**Author:** ![Jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@Jake](https://discuss.bluerobotics.com/u/Jake)\
**Post date:** [December 18, 2018, 4:06pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/4 "2018-12-18T16:06:18Z")

</div>

@patrickelectric great! I’m having a slight issue with getting the images on the topside machine now here are my gstreamer parameters, can you see any issue? The error messages are pretty vague, “GLib.Error: gst\_parse\_error: could not link videoconvert0 to videoconvert1 (3)”

udpsrc port=4777 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! x264enc ! decodebin ! videoconvert ! video/x-raw,format=(string)JPEG ! videoconvert ! appsink emit-signals=true sync=false max-buffers=2 drop=true

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [December 18, 2018, 5:33pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/5 "2018-12-18T17:33:16Z")

</div>

That is because you have two “videoconvert” nodes.  
try something simpler like this:

```auto
gst-launch-1.0 -v udpsrc port=4777 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

```

---

<div class="post-metadata">

**Author:** ![Jake](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@Jake](https://discuss.bluerobotics.com/u/Jake)\
**Post date:** [December 18, 2018, 6:28pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/6 "2018-12-18T18:28:42Z")

</div>

That did the trick, I also am looking into your earlier post. I installed omx and tired using omxh264enc and got the following “WARNING: erroneous pipeline: no element “omxh264enc””

Any idea what’s up? Did I drop the ball on the install?

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [December 18, 2018, 7:37pm UTC](https://discuss.bluerobotics.com/t/integration-of-mjpg-format-camera/3932/7 "2018-12-18T19:37:09Z")

</div>

looks like something is broken:  
[https://www.raspberrypi.org/forums/viewtopic.php?t=192855](https://www.raspberrypi.org/forums/viewtopic.php?t=192855)

that package linked seems to work, try this:

```bash
sudo apt remove gstreamer1.0-omx* 
wget http://steinerdatenbank.de/software/gstreamer1.0-omx-rpi_1.10.5-2+rpi+patches_armhf.deb
dpkg -i gstreamer1.0-omx-rpi_1.10.5-2+rpi+patches_armhf.deb

```

then `gst-inspect1.0 | grep omx`

you should see something like this:

```auto
pi@raspberrypi:~ $ sudo gst-inspect-1.0 | grep omx
omx: omxmpeg2videodec: OpenMAX MPEG2 Video Decoder
omx: omxmpeg4videodec: OpenMAX MPEG4 Video Decoder
omx: omxh263dec: OpenMAX H.263 Video Decoder
omx: omxh264dec: OpenMAX H.264 Video Decoder
omx: omxtheoradec: OpenMAX Theora Video Decoder
omx: omxvp8dec: OpenMAX VP8 Video Decoder
omx: omxmjpegdec: OpenMAX MJPEG Video Decoder
omx: omxvc1dec: OpenMAX WMV Video Decoder
omx: omxh264enc: OpenMAX H.264 Video Encoder
omx: omxanalogaudiosink: OpenMAX Analog Audio Sink
omx: omxhdmiaudiosink: OpenMAX HDMI Audio Sink

```
