# Second Camera Auto Run

**URL:** <https://discuss.bluerobotics.com/t/second-camera-auto-run/11067>\
**Category:** Software\
**Created:** [November 23, 2021, 8:05pm UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067 "2021-11-23T20:05:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 23, 2021, 8:05pm UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/1 "2021-11-23T20:05:45Z")

</div>

Hi,

I have 2 camera on my ROV. When rov runs, I want the code I prepared for the second camera to return but it must be a .sh file.

I tried with crontab but it did not work when I tried with crontab. I did it with my raspberry pi 4 but when I do same things with raspberry pi 3 it does not work. (companion version: 0.0.28-18-g690ba0c . I have to use this version because it is the only version that works with DVL)

Thanks.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [November 25, 2021, 4:35am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/2 "2021-11-25T04:35:30Z")

</div>

Hi @ugurdemirezen,

> [@ugurdemirezen](#):
>
> When rov runs, I want the code I prepared for the second camera to return

Without information on the camera you’re using or the code you’ve written it’s difficult to help.

By “when rov runs” do you mean when it gets powered on, or when the vehicle is armed?

> [@ugurdemirezen](#):
>
> it must be a .sh file.

Is this a limitation on your end? The [`.companion.rc`](https://github.com/bluerobotics/companion/blob/master/.companion.rc) file that’s used for setup when the ROV is turned on doesn’t have any file type requirements (it runs various python and shell files without issues).

> [@ugurdemirezen](#):
>
> I did it with my raspberry pi 4 but when I do same things with raspberry pi 3 it does not work. (companion version: 0.0.28-18-g690ba0c . I have to use this version because it is the only version that works with DVL)

What is the “it” that you did? Companion 0 isn’t expected to run on Raspberry Pi 4 by default, so I’m unsure how you tried something with Companion 0 that apparently worked on Raspberry Pi 4 but not Raspberry Pi 3.

* * *

Assuming your extra camera has a H264-encoded output option, you might want to try the approach I detailed [here](https://discuss.bluerobotics.com/t/streaming-multiple-usb-cameras-at-once/10479/6), which allows setting up multiple streams with only relatively minor modifications to the existing Companion video streaming code.

---

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 25, 2021, 8:29am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/3 "2021-11-25T08:29:27Z")

</div>

> [@EliotBR](#):
>
> Without information on the camera you’re using or the code you’ve written it’s difficult to help.
> 
> By “when rov runs” do you mean when it gets powered on, or when the vehicle is armed?

Yes I mean when it gets powered on second camera will start streaming. I am using a usb camera for testing.

I am using this code :

```auto
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=\(fraction\)30/1 ! videoconvert ! jpegenc ! udpsink host=192.168.2.1 port=5001

```

when I run it in the terminal it is working. But I want it to work when the robot gets powered on.

---

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 25, 2021, 10:11am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/4 "2021-11-25T10:11:27Z")

</div>

‘libgstreamer-1.0.so.0’ is missing so it is not working i guess. How can i add this library ? I am trying

```auto
$sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

```

this code. But output is :

```auto
E: Unable to locate package libgstreamer0.10-dev
E: Couldn't find any package by regex 'libgstreamer0.10-dev'
E: Unable to locate package libgstreamer-plugins-base0.10-dev
E: Couldn't find any package by regex 'libgstreamer-plugins-base0.10-dev'

```

Can you help me about that ?

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [November 26, 2021, 1:56am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/5 "2021-11-26T01:56:54Z")

</div>

> [@ugurdemirezen](#):
>
> I am using this code :
> 
> ```auto
> gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=\(fraction\)30/1 ! videoconvert ! jpegenc ! udpsink host=192.168.2.1 port=5001
> 
> ```
> 
> when I run it in the terminal it is working. But I want it to work when the robot gets powered on.

Probably the best way to do that is to create a shell script that runs that command, and run that shell script in its own `screen` session from the `.companion.rc` file. You could also modify `scripts/start_video.sh` to be agnostic of stream type (i.e. allow it to take in `video/x-h264` or `video/x-raw` as part of the settings), in which case you’d be able to use the rest of the approach I linked to in my previous comment.

> [@ugurdemirezen](#):
>
> ‘libgstreamer-1.0.so.0’ is missing so it is not working i guess. How can i add this library ? I am trying
> 
> ```auto
> $sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
> 
> ```
> 
> this code.

gstreamer 1.0 (one-point-zero) and 0.10 (zero-point-ten) are not the same. You mentioned that it was working before from the terminal - what changed? I don’t expect you should need to install any extra dependencies/libraries, and it’s possible that doing so may cause issues with the normal video streaming functionality.

---

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 26, 2021, 11:09am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/6 "2021-11-26T11:09:22Z")

</div>

> [@EliotBR](#):
>
> Probably the best way to do that is to create a shell script that runs that command, and run that shell script in its own `screen` session from the `.companion.rc` file. You could also modify `scripts/start_video.sh` to be agnostic of stream type (i.e. allow it to take in `video/x-h264` or `video/x-raw` as part of the settings), in which case you’d be able to use the rest of the approach I linked to in my previous comment.

I tried it but it did not work. But it should not be that difficult.

> [@EliotBR](#):
>
> gstreamer 1.0 (one-point-zero) and 0.10 (zero-point-ten) are not the same. You mentioned that it was working before from the terminal - what changed? I don’t expect you should need to install any extra dependencies/libraries, and it’s possible that doing so may cause issues with the normal video streaming functionality.

I tried [this](https://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html?m=1). and the output was “libgstreamer-1.0.so.0” is missing.

---

<div class="post-metadata">

**Author:** ![ugurdemirezen](https://avatars.discourse-cdn.com/v4/letter/u/9de053/32.png) [@ugurdemirezen](https://discuss.bluerobotics.com/u/ugurdemirezen)\
**Post date:** [November 26, 2021, 11:53am UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/7 "2021-11-26T11:53:49Z")

</div>

It is not about the streaming. There should be a method that allows any program to run automatically when reboot.( like crontab)

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [November 26, 2021, 12:23pm UTC](https://discuss.bluerobotics.com/t/second-camera-auto-run/11067/8 "2021-11-26T12:23:15Z")

</div>

> [@ugurdemirezen](#):
>
> I tried [this](https://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html?m=1). and the output was “libgstreamer-1.0.so.0” is missing.

That webpage is from 2012, and also doesn’t mention gstreamer anywhere, so I’m not sure how you could’ve ended up with that error.

> [@ugurdemirezen](#):
>
> There should be a method that allows any program to run automatically when reboot.( like crontab)

As mentioned, that’s what we use [`.companion.rc`](https://github.com/bluerobotics/companion/blob/master/.companion.rc) for.

If for some reason you can’t or don’t want to use that, then try [one of these general alternatives](https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/). I would note that our normal video streaming functionality is started from `.companion.rc`, so I’d expect that’s a safer bet since you know any required components should be loaded/available at that point in the booting process.
