Livestreaming using ffmpeg and v4l2


#1

Hello,

I have recently asked a question on the developer.theta360 forum, but Jesse suggested i ask it here and tag @David_Hunter and @Bob_White.

I have been trying to live stream video from the RICOH THETA V to YouTube using a raspberry pi, but i been having a lot of issues.
I have used the following command (not related to YouTube, only for testing):
“ffmpeg -f v4l2 -i /dev/video0 out.mpg”
on the following machines:
Ubuntu, Ubuntu mate, and Raspbian,
the output is always the same “/dev/video is not a file or a directory”. The camera is listed when executing lsusb, but does not appear as a device. I’m wondering if this is a driver issue, because i was successful in doing something similar on windows and mac.

Thanks!


#2

I don’t think the Linux kernel has a driver that supports UVC 1.5, which the THETA V uses for video live streaming.

See this:

Possible fix at the end:


#3

Thanks for the tag. I don’t know anything about video streaming (only still image capture and control via Bash commands in Linux). But something I want to learn later this year is exactly what you’re doing, so I’m keen to hear how you get on.

Would you mind please letting me know if/how you manage to do this?

Thanks. :slight_smile:


#4

I would start by checking permissions of /dev/video0


#5

Greetings Bob,

I actually have no /dev/video* when i plug in the camera.

Thanks


#6

So far i only got it to work on Windows 10 and macOS. First of all for both OS’s you need to make sure you have ffmpeg. Second of all, i did not need to install the Thata V driver on macOS, but had to on Windows 10. To list video and audio devices compatible with ffmpeg, execute the following:
macOS:
ffmpeg -f avfoundation -list_devices true -i ""

Windows 10:
ffmpeg -list_devices true -f dshow -i dummy

Both should output a list of video and audio devices. Finally choose a video device and execute the following,
macOS:
ffmpeg -f avfoundation -i “[camera_name]” -f flv rtmp://a.rtmp.youtube.com/live2/[stream_key] out.mpg

Windows 10:
ffmpeg -f dshow -i video="[camera_name]" out.mp4 (i have not tryed streaming to YouTube on windows but it should be the same).

Please Note that the ffmpeg command is basic and that there are a lot of setting you can change.


#7

Someone did write a driver to stream the THETA V with Linux. However, it was for work and the person could not open source it. There’s an open source project here for Android.

It might be possible to get that to work on the Raspberry Pi.

It could be easier to install Android on Rasbperry Pi first.

Are you streaming from the Raspberry Pi primarily because of the low cost of the Raspberry Pi?

Although it’s easier to use Raspbian on Raspberry Pi, the GitHub repo for UVC Camera is for Android, so it could be easier to use Android unless you find a Raspian device driver to support a UVC 1.5 webcam.


#8

Thank you, i will try the android OS next.

I’m using the Raspberry Pi for its small form factor and the fact that it runs linux.


#9

I went through the guide below, but did not achieve a satisfactory result.

I flashed a 32GB microSD card with Android, which was barely enough space. ETA is 12 minutes with an additional 7 minutes for image validation.

Even after installing Android, I’m not sure if live streaming with the THETA V will work. I’m hoping that I’ll get a better understanding of Android development on single board computer Android devices. There may be technical limitations. For example, I’m not sure if Android on RPi3 has hardware graphics acceleration working properly.

If the Raspberry Pi doesn’t work due to performance reasons, then there are many other boards that can run Android.

This one might be interesting due to a combination of price and performance.
https://wiki.odroid.com/odroid-xu4/odroid-xu4

There’s some cause for skepticism about the Android on Rpi performance in this section from the article from the LoverPi blog:

However, some applications will have problems downloading them. Also as said in the introduction, this is an experimental setup and the GPU is not very well supported. It is therefore likely that Android is experiencing slowdowns. If you want a card that can run Android well, we recommend using an Odroid . We did not test on it but the returns are good.

I decided to test the Raspberry Pi first as I had a unit on my desk and it was easy to get some form of Android running on it fairly easily.

boots nicely

Raspberry Pi 3 running Android 7.1.1
image

I’m able to use Ethernet and a web browser.

Google Play Store Problems

I’m getting this error when I try to access the Google Play Store.

As this is a fairly big problem, I’m going to switch my testing to a commercial version of Android so that I can at least evaluate the hardware performance of the Raspberry Pi 3 running Android.


Changing Strategy

For evaluation purposes, I’m going to try the demo version of Emteria OS Android 7.1.2 on Raspberry Pi 3.

There’s a couple of interesting pieces to this, including the OpenGapps.org site.

http://opengapps.org/#aboutsection

As the Emteria OS will reboot every 8 hours and the commercial version is 69 Euros per device, it’s unlikely this is a long-term solution. However, it may be useful for testing.


#10

Wow, this looks like a really good investigative start @codetricity ! Though I know Android can run on Raspberry Pi, it’s the first time I’ve seen it installed. Thanks for the screenshots, that’s really interesting to see up and running. I wonder why it won’t connect to Google Store.


#11

I suspect that the Google servers are blocking the connection because it’s an obscure device attempting to connect.

I’m able to access the Google Play store with Emteria.

If you recall, at the last TechCrunch Disrupt hackathon we went to, the developers from Spain used an embedded Android device. I don’t think the Raspberry Pi hardware is going to be able to stream the THETA V, but as I have it on my desk, it’s worthwhile to try it out as I’ll learn something.

I downloaded Termux from the Google Play Store and I can use it to access the Android console with a keyboard.

Other apps work as well.

The system comes with a file manager with the base installation.

The web browser is quite usable on the RPi3 hardware.

Right now, I have no idea how to connect a USB camera to the USB ports of the RPi and have it be detected as a webcam.

It’s possible that an app like the one below might work. I’ll do more testing in the future.

http://www.infinitegra.co.jp/en/solution/AndroidApp1.htm

I also found this interesting library called FFmpeg Android.

http://writingminds.github.io/ffmpeg-android/

The Android YouTube app works fine for video, but I could not figure out how to get the audio to work. Chrome browser works.

I’m now thinking that it might be easier to run Android x86 in a VM and see if I can get the virtual USB ports to work with first a webcam, then the THETA V.


#12

Thanks a lot, these are really interesting results. Have you tried the Android Theta V driver you mentioned a while ago?

I suspect you need a ffmpeg library that could stream video from a USB device. On linux that would be video4linux2 or v4l2. I did a fast search and it seems v4l2 is not supported on Android OS, but there seems to be some libraries created by user, but i doubt that they would work with Theta V.


#13

I’ve been thinking about this more and due to the CPU of the Raspberry Pi, I think that the THETA V’s internal Android OS and Snapdragon 625 is going to be much higher performance. You’ll soon be able to write your own plug-ins for the THETA V that can access the streaming capability directly, potentially eliminating the need for a separate device to relay the 4K stream to YouTube or Facebook or other service.

With the internal plug-in, the Android OS inside the THETA V accesses the spherical cameras of the THETA V using the normal Android camera API.

The new Raspberry Pi 3 B+ has a Broadcom BCM2837B0 that runs at 1.4GHz, quad core, 1 GB LPDDR2 RAM.

The Snapdragon 625 inside of the THETA V has eight cores, Cortex A53, with speeds up to 2GHz, and an Adreno 506GPU. The THETA V also has 3GB of LPDDR3 SDRAM.

While I still plan on experimenting with the Raspberry Pi for educational purposes, it seems like the plug-in might be a better path toward getting something usable. The Raspberry Pi is also easier to experiment on because I have a monitor and keyboard connected to it, but it just doesn’t have the same power as the THETA V and the THETA V is directly connected to the integrated cameras.

BTW, I decided to install Android 7.1 x86 into a VirtualBox VM for testing. It’s running significantly smoother and faster in the VM compared to natively on the Raspberry Pi 3. Sound also works in the VM and things like YouTube function as you would normally expect on a regular Android device. If I have time, I’ll try and experiment with the UVC 1.5 driver inside of the VM first as it is easier to work on.

Ultimately, I want to focus more on Android development directly on the THETA V, but running Android in a VM is a good step for personal education.

Although I could just use the Android SDK HAXM emulator for Android development, I am enjoying the large screen of my Android desktop in the VM and the smooth workflow to use the keyboard and mouse as my primary way to work with Android. Last night, I also learned some nice techniques to use alsa_aplay tools to test my sound card from inside of Android.

I have the Google Play Store and all the apps running inside of Android in the VM.