Raspivid on startup

Hello everyone.

Here is the string that I use to feed video to my tablet via UDP.

raspivid -n -w 680 -h 480 -fps 20 -t 0 -hf -b 2500000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.8.101 port=5600

How can I change this so that it starts automatically ?

We use systemd to manage services. That’s why I recommend this page to get started. Even though it looks kinda intimidating at first, this is just robust and rigorous. In the nutshell all you need to do:

  1. create a simple service file (for example, let it be raspicam.service) which contains something like this:
[Unit]
Description=raspivid
After=network.target

[Service]
ExecStart=/usr/bin/raspivid -n ....

[Install]
WantedBy=default.target
  1. put it in /etc/systemd/system/

  2. sudo systemctl daemon-reload to let systemd know of this service

  3. sudo systemctl start raspivid to test it out

  4. sudo systemctl enable raspivid to enable on boot

3 Likes

This is really helpful. One of those things that can save everyone a few hours of google time. Suggest it goes in with streaming dev docs.

2 Likes

yeah that is really helpful indeed;
i assume rc.local is not being called anymore on boot (as I couldn’t make my scripts start on boot - they work fine on manual start)?
also crontab (@reboot) didn’t work;

Thank you so much George :slight_smile:

systemd is now the default service manager in Raspbian since Jessie. caused a bit of a rift in the debian community apparently.

https://wiki.debian.org/systemd

2 Likes

Here is what I did and its simple and straight forward

sudo nano /etc/rc.local

insert the raspivid line before the exit

CTRL X and save and reboot. The camera starts when the Rasberry PI starts

This is a solution indeed but this is not recommended. I recommend the one I suggested above.

Good day again. What is the reason that you do not recommend that method?

What I am a little unsure of is the steps I need to take in the command line to create the service file

I assume i have to create it with something like this ?

sudo nano /lib/systemd/system/raspivid.service

OK so here is what i did

1 touch startup.sh

2 nano startup.sh

Then added raspivid........

3 chmod +x startup.sh

4 sudo nano /etc/rc.local

5 /home/pi/startup.sh

6 /home/pi/startup.sh &

I’d like to point out that the answer has been already given.

I told you I didnt understand that but its ok will ask someone else

As the matter of fact, you did figure out what’s needed. This is the only thing to be done.

AHA fantastic. Thanks :slight_smile: