Video Recording & Streaming - UMDBPP/LIVE GitHub Wiki

Video Recording and Streaming Setup:

  • To capture the video feed on the Raspberry Pi camera module, we modified to source code of the native raspivid application in order to allow us to simultaneously stream the video feed and save it as segmented clips.
  • For our purposes, the modified version of the raspivid application and all the other dependent applications must be downloaded.
  • Preliminary Steps:
    1. For good practice, run sudo apt-get update and sudo apt-get upgrade before downloading any other applications.
    2. Download VLC on the Raspberry Pi by typing sudo apt-get install vlc in the terminal.
    3. Download github on the Raspberry Pi by typing sudo apt-get install git in the terminal.
    4. Download cmake on the Raspberry Pi by typing sudo apt-get install cmake in the terminal.
    5. Once github has finished downloading, clone the UMDBPP/userland repository containing the modified source code of the raspivid application by typing git clone https://github.com/UMDBPP/userland.git in the terminal.
    6. When the repository is successfully cloned on the Pi, navigate to the userland directory by typing cd userland in the terminal window.
    7. Run git status command in the terminal and verify you are on the devel branch. If you are not, run git checkout devel to switch over to the devel branch.
    8. Compile all of the code in the repository by typing ./buildme in the terminal window.
    9. When all of the code finishes compiling, type raspivid in the terminal window. You can now see that under the list of commands, there is an additional command "-send" which is not native to the default raspivid application that comes pre-installed on the Pi.
    10. To verify that the application works and that the Pi Camera Module is connected properly, run raspivid -t 0 in the terminal. A window should pop up, displaying video feed from the Pi Camera Module. To exit this window, press Ctrl + C on the keyboard.
  • VLC media player must be installed on the Pi, as it is the application through which the h264 raw video feed will be piped. The VLC media player will turn this video feed into an RTSP stream, which can be viewed via the VLC media player on other devices.
    • If not already downloaded, the VLC media player can be installed on the Pi by typing sudo apt-get install vlc in the terminal window.
    • The VLC media player should also be downloaded on another computer, from which you would like to also watch the video stream. The application can be downloaded from the internet.

Recording, Streaming, and Watching the Video:

  • Once everything is setup, run the video streaming and recording script for the modified raspivid application, which can be found here: https://github.com/UMDBPP/LIVE/blob/video_recording/PiVideo/modified_raspivid_script.bash
  • If executed properly, the LIVE/segmented_videos directory will begin to populate with the segmented video clips.
  • To view the stream on another device, first make sure that it is connected to the same local network as the Raspberry Pi from which you are running the script. Open the VLC media player on this device, click on 'File', navigate to 'Open Network', and input the following url, replacing <RaspberryPi_IPaddress> with the IP address of the Raspberry Pi from which you are streaming: rtsp://<RaspberryPi_IPaddress>:2431/
  • After clicking 'Open', you will be able to access and view the video stream.
  • If not already known, you can find the IP address of the Raspberry Pi by typing in ifconfig into the terminal window.

Video Processing:

  • When the script is either terminated or has finished running, the segmented video clips will need to be concatenated and converted to a readable MP4 format. This can be achieved by running the video processing script, which can be found here: https://github.com/UMDBPP/LIVE/blob/video_recording/PiVideo/video_processing.bash
  • Before the script is ran, the MP4Box application must first be downloaded on the Raspberry Pi. This can be achieved by typing sudo apt install -y gpac in the terminal window.
  • When running the script, it will prompt you to enter the total number of segmented video clips saved. Since the video clips will be saved in order in the LIVE/segmented_videos folder, this number can be found by scrolling to the bottom of the folder and looking at the string of numbers (excluding any leading zeros) that appear after "video" in the file name. The processed and merged video file will be saved as 'finalvideo.mp4' in the same directory.

Notes from Natalie subsystem checkout:

  • as best practice, run sudo apt-get update and sudo apt-get upgrade as first step
  • to install vlc sudo apt get-install vlc is an invalid operation. I used sudo apt install -y vlc and it successfully installed vlc
  • make note to git status and if not already on devel branch, git checkout devel so users build your modified code
  • to install cmake (before ./buildme): sudo apt-get install cmake

good troubleshooting tips:

  • as a check runraspivid -t -0 and video from your PiCam should show, verifying connection