I have a Raspberry Pi 2 Model B and am running Raspbian.
I have a capture device (USB easycap) connected to the pi, and it is recognized and am able to open the video capture stream in VLC. I also have a python script I wrote that connects me to my server and fetches information for me.
I want to be able to run both of these tasks simultaneously. I need the VLC network stream to run, while also having the python script pull data down from my server (just simple json info). I need both of these thing to happen continuously and simultaneously . What is the best way to go about doing this?
Edit: Giving an overview of the project so that it may give a better understanding of what is being done so that you can better help out
I have the Raspberry Pi 2 with (NOOBS/Raspbian?) installed. The goal of the project is to receive the video output from a computer and have it inputted into the Pi. To do this, I have an HDMI2AV converter device (something like this) that takes in the PC's video output (via an HDMI cable) as an input to the HDMI input port on the device. The other end of the device outputs the video through composite cables that are then connected to a EasyCap DC60 USB capture device (something like this). The EasyCap is an stk1160 chipset so it worked right out of the box.
I have a powered USB hub with the USB host cable connected to one of the 4 Pi USB ports. I have the EasyCap DC60 plugged into the powered USB hub because I had read the the Pi could not provide enough power from its native USB ports for the DC60 with other peripherials connected as well (mouse and keyboard).
From there, the goal is to take the video that is coming in from the EasyCap DC60 capture and stream it from the Pi (using VLC/Mplayer/Omxplayer via RTSP) to a Android tablet or smart phone using an Android app I have written.
To handle the streaming and where it is streamed to, I have a server set up that the Pi connects to (as a form of authentication). The Android app that I have written also connects to the same server, so that the app and the Pi have all the information needed to connect to each other such as IP address and port (sending the transmission through the server would induce additional lag and latency).
I have a Python script running on the Pi that handles all the communication between the various system components (Pi, server, app, PC) and authentication between the Pi and the app (through the server). With the app, the user is able to issue mouse and keyboard commands/events (using a Bluetooth mouse and keyboard connected the the tablet/phone) that are transmitted to the Pi over TCP in JSON format. The Python script parses the JSON and passes the mouse/keyboard events (mouse coordinates. left/right clicks, key presses) to the computer that is providing the video source. This is done with a Teensy module connected to the Pi (UART pins on the Pi connect to the UART pins on the Teensy, micro usb port on Teensy connects to a USB port on PC) where the parsed JSON mouse/keyboard events are sent over UART from the Pi to the Teensy. The C code running on the Teensy takes the mouse/keyboard events from the Pi and using a library for mouse/keyboard HID, transmits the events received over UART to the PC that is providing the video source in USB-HID format in order to emulate a mouse/keyboard.
I have each part working independently:
- I can use the Python script to connect the Pi to the server, I can connect the Android app the to server, I can send mouse/keyboard commands directly from the Android app to the Pi, and I can send the app-received mouse/keyboard commands from the Pi to the Teensy and finally to the connect PC to properly emulate the PC's mouse and keyboard.
- I can open the DC60 video capture device and view the stream on the Pi, and am on the verge of being able to stream it to the app (fine tuning the best media player to use to do this and what parameters to use to optimize the video quality).
- How do I run both tasks 1. and 2. continuously and simultaneously?
TL;DR:I need the streaming of the video from the Pi to the app, and the listening for mouse/keyboard commands issued from the app (and subsequently the transmission of those commands to the PC via UART from Pi to UART on Teensy and then from Teensy to PC via microusb) to take place simultaneously. How do I accomplish this? The streaming of the video is handled by a string in the raspbian terminal (or a bash file), and the listening for and subsequent transfer of the mouse/keyboard commands is all being handled by a Python script. Do I create a bash file that runs the command to open the capture device' raw video and stream it, and then have that same bash file also call the python script? Would that work or is some sort of forking/threading needed to have both of these tasks run continuously or simultaneously?