Fixin Raspistill and Raspivid for Headless Streaming on the Raspberry Pi
Recently I got 2 Raspberry Pi Camera modules for my Raspberry Pi boards for some projects I have in mind. I was sad to find out I could not stream unless I had a monitor connected to the Pi and after some additional digging I found out that the initial version of the tools Raspistill and Raspivid the no preview option was broken causing it to not work. After some digging in the forums and trial and error I found how to fix it while the tools are updated and added to the package repo. Plus it was a good exercise in compiling files for ARM.
Update your system applications and download the required software to compile userland:
sudo apt-get update sudo apt-get upgrade sudo apt-get install git gcc build-essential cmake vlc
Download and configure sources
Create a folder to hold development files and clone the latest userland for raspian.
cd ~ mkdir Development git clone git://github.com/raspberrypi/userland.git cd userland
Create the proper make files:
sed -i 's/if (DEFINED CMAKE_TOOLCHAIN_FILE)/if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)/g' makefiles/cmake/arm-linux.cmake
Fix Raspistill
Open Raspistill command source file at line 1034:
nano +1034 host_applications/linux/apps/raspicam/RaspiStill.c
Modify the line from:
MMAL_STATUS_T status = -1;
to:
MMAL_STATUS_T status = MMAL_SUCCESS;
Fix Raspivid
Open the raspivid source file at line 852:
nano +852 host_applications/linux/apps/raspicam/RaspiVid.c
Modify the line from:
MMAL_STATUS_T status = -1;
to:
MMAL_STATUS_T status = MMAL_SUCCESS;
Build and Install the Latest Userland
Configure a build folder and build and install the userland binaries. This should take around 30 to 45 minutes:
mkdir build cd build sudo cmake -DCMAKE_BUILD_TYPE=Release .. sudo make sudo make install
You should now be able to create a steam with VLC and connect to it on a headless system using the -n parameter for no preview:
raspivid -o - -t -1 -w 920 -h 540-n | cvlc -vvv --network-caching=0 stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264