Raspivid save to disk and stream concurrently - raspberry-pi

I am trying to run a home security camera using Rasberry Pi Model B
I want to save the stream to a file locally (USB if possible) and also stream so I can pick this up on my network
The command I have is not working for both - any suggestions?
raspivid-o security.h264 -t 0 -n -w 600 -h 400 -fps 12 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

Try this command:
raspivid -o - -t 0 -n -w 600 -h 400 -fps 12 | tee security.h264 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
The tee command writes the output to the standard output and to the specified files.

Related

What could cause tpm_unsealdata to be unable to write to a file?

I have successfully sealed a file to the tpm after having taking ownership of it using sudo tpm_sealdata -i inputfile -o encryptedfile -p 0 -p 1 -p 2 -p 3 -p 4 -p 5 -p 6 -z, however upon attempting to run sudo tpm_unsealdata -i encryptedfile -o newfile -z I simply recieve an error of "Unable to write to output file" however, the new file has been created and is simply empty. what could be causing tpm_unsealdata to successfully create the file, but then fail to write to it?

cannot open connection network is unreachable

I want live streaming on YouTube from my Raspberry Pi 3. The script properly work when I run the manually from shell. When I add that script in the file sudo nano /etc/rc.local to run it automatically on startup it run only first time when the Raspberry Pi starts next time its stop working and give an error 'cannot open connection network is unreachable'.
here is the script that i use for live streaming on YouTube from Raspberry Pi.
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/[your-secret-key-here]
I want to run this script automatically each time when the Raspberry Pi startup without any error.
for more information check this link.
After caring out many attempts I found the solution.
It is very Simple. just make a new python file with any name in my case livestream.py and paste the code.
import os
os.system(raspivid -o - -t 0 -vf -hf -fps 25 -b 600000 | avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/[your-secret-key-here]
)
It can be be run by installing php in Raspberry Pi by using this script
sudo apt-get install php5-fpm php5-mysql
and run file livestream.php the php code is
<?php
exec("raspivid -o - -t 0 -vf -hf -fps 25 -b 600000 | avconv -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/[your-secret-key-here]
");
?>

Image dump fails during operation

I use the openocd script below to dump the flash memory of a STM32 microcontroller.
mkdir -p dump
openocd -f board/stm3241g_eval_stlink.cfg \
\
-c "init" \
-c "reset halt" \
-c "dump_image dump/image.bin 0x08000000 0x100000" \
-c "shutdown" \
FILENAME=dump/image.bin
FILESIZE=$(stat -c%s "$FILENAME")
echo "Size of $FILENAME = $FILESIZE bytes."
The script is supposed to read the whole memory which is 1MB in my case but it does it very rarely. Generally it stops reading the memory before the end.
Why can't I obtain 1MB each time I execute this script? What is the problem here to cause openocd stop dumping the rest of the memory?
You can use dfu-utils to reflash your STM32 micros.
In Ubuntu/Debian distros you can install dfu-utils with apt:
$ sudo apt-get install dfu-util
$ sudo apt-get install fwupd
Boot your board in DFU mode (check datasheet). Once in DFU mode, you should see something similar to this:
$ lsusb | grep DFU
Bus 003 Device 076: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
Once booted in DFU mode, reflash your binary:
$ sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/$(PROJECT).bin
With -d option you choose product:vendorid such as listed by lsusb in DFU mode.
With the -a 0 option you select alternate mode 0, check the options available as in the following example:
$ sudo dfu-util -l
Found DFU: [0483:df11] ver=2200, devnum=101, cfg=1, intf=0, alt=1, name="#Option Bytes /0x1FFFF800/01*016 e", serial="FFFFFFFEFFFF"
Found DFU: [0483:df11] ver=2200, devnum=101, cfg=1, intf=0, alt=0, name="#Internal Flash /0x08000000/064*0002Kg", serial="FFFFFFFEFFFF"
As you can see, alt=0 is for internal flash memory.
With the -s option you specify the flash memory address where you save your binary. Check your memory map in datasheet.
Hope this helps! :-)

Rotating per packets receiving by TCPDUMP

How can I use 'tcpdump' command to capture and save each received packets to separate files (having rotatation per packet without losing any packets).
How about saving dump to a file and then splitting that to separate files?
$ sudo tcpdump -c 10 -w mycap.pcap
tcpdump: data link type PKTAP
tcpdump: listening on pktap, link-type PKTAP (Packet Tap), capture size 65535 bytes
10 packets captured
you'll need to have wireshark installed for this to work (e.g. with brew install wireshark on Mac or apt-get on Ubuntu)
$ editcap -c 1 mycap.pcap output.pcap
10 packets captured -> 10 files created
$ ls -la output* | wc -l
10

How to stop or uninstall screenly on raspberry pi?

As I am implementing digital signage with Dell Monitor.
First thing as I already google there is no option to stop or uninstall screenly & get back to raspberry pi desktop.
I want to know, how we can do that?
pi#raspberrypi ~ $ /opt/vc/bin/tvservice -s
state 0x120016 [DVI DMT (4) RGB full 4:3], 640x480 # 60Hz, progressive
My monitor maximum resolution is 1920x1200 with 16:10 aspect ratio, why tvservice giving me above mentioned output?
thanks in advanced,
Bhushan Vaiude
Here is ans:
ps aux | grep creen
less ~/screenly/misc/gtkrc-2.0
less ~/.config/openbox/lxde-rc.xml.bak
less ~/.config/openbox/lxde-rc.xml
less ~/.config/lxpanel/LXDE/panels/panel.bak
less /etc/xdg/lxsession/LXDE/autostart.bak
ulink /etc/supervisor/conf.d/screenly.conf
unlink /etc/supervisor/conf.d/screenly.conf
sudo unlink /etc/supervisor/conf.d/screenly.conf
sudo unlink ~/.gtkrc-2.0
ls -l ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/
unlink ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/
ls -l ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/mv ~/.config/openbox/lxde-rc.xml.bak ~/.config/openbox/lxde-rc.xml
mv ~/.config/openbox/lxde-rc.xml.bak ~/.config/openbox/lxde-rc.xml
ls -l ~/.config/openbox/lxde-rc.xml
ls ~/.config/lxpanel/LXDE/panels/panel
ls ~/.config/lxpanel/LXDE/panels/pane*
mv ~/.config/lxpanel/LXDE/panels/panel.bak ~/.config/lxpanel/LXDE/panels/panel
sudo ls -l /etc/xdg/lxsession/LXDE/autostart
sudo ls -l /etc/xdg/lxsession/LXDE/autostart*
sudo mv /etc/xdg/lxsession/LXDE/autostart.bak /etc/xdg/lxsession/LXDE/autostart
less /etc/lightdm/lightdm.conf
sudo nano /etc/lightdm/lightdm.conf
#comment xserver-command
sudo shutdown -r now
thanks!