📜 ⬆️ ⬇️

Live video streaming from the Orange Pi One



This post will give an example of implementing online video streaming using a webcam and Orange Pi One single board.

Well, let's start with what is used here:

1) Shawl from the image
2) webcam
')
And this is 810 + 155 = 965r. even a schoolboy can afford it.

So streaming is broadcasting content to the network. Those. need a server that will distribute the information flow. Distribute can be broadcast or on request. In our case will be on request.

First you need to check whether the camera driver rises:

opigaz@orangepione:~$ lsusb ... Bus 002 Device 002: ID 1908:2311 GEMBIRD ... 

The camera picked up. Now try to take a picture of the camera. I went the easy way and put the OpenCV library:

 opigaz@orangepione:~$ sudo apt install python-opencv 

Found an example on the Internet:

 import cv2 import numpy cap = cv2.VideoCapture(0) #ignore the errors cap.set(3, 960) #Set the width important because the default will timeout #ignore the error or false response cap.set(4, 544) #Set the height ignore the errors r, frame = cap.read() cv2.imwrite("photo.jpg", frame) 

And took the first shot:

 opigaz@orangepione:~$ python cam.py 


Not very picture turned out, but there is a contact! You can also use the video for Linux API directly to capture images from the camera.

For streaming you need to organize a distribution server. This will require significantly more time, because among other things, you need to implement support for any distribution format (and preferably several). And, moreover, there are ready-made solutions. I put ffmpeg and vlc, respectively.

To start the server you can use this command:

 cvlc v4l2:///dev/video0 :v4l2-standard=mpeg2 :input-slave=alsa://hw:0,0 :live-caching=300 :sout="#transcode{vcodec=WMV2,vb=800,scale=1,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}" 

And to check the video stream on the client, you can do this:

 vlc -vvv http://192.168.100.10:8080/stream.wmv 

The iron part looks like this:



And the result is:



You can also connect to this stream from mobile devices. I tried from my smartphone with vlc installed on it.

PS: For me, the most amazing thing was that both the camera and the handkerchief work. Moreover, the loading of the board is approximately the same during the broadcast:


PPS: It is a pity that my last publication was cut out. I wanted to convey to the people that even a student can afford to take a deshmansky piece of iron and it will work.

Source: https://habr.com/ru/post/328892/


All Articles