CostasVav
Posts: 28
Joined: Fri Jan 30, 2015 10:49 pm

Low latency encoding and transmission possible?

Fri Jan 30, 2015 11:05 pm

Hi all,

I am looking into a project and not sure if I should use an RPi, and if I do, the RPi camera or a USB camera.

The key requirement for the project is to encode the camera input, transmit it to a remote device on the same wi-fi network, and have the remote device (an Android smartphone) play back the video stream with less than 200ms delay. Resolution should be 480p, but if 720p is possible, great.

1. Is this possible with the RPi A+ or B+?
2. If so, would it be better to use the ribbon camera or a USB camera?
3. If not, does anyone know which other SoC's can handle this? (E.g. BananaPi, Odroid, etc)

Thanks!
Current Project: PiMac

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10600
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Low latency encoding and transmission possible?

Sat Jan 31, 2015 10:04 am

Yes, it's possible, though latency through Android may be variable.
http://www.raspberrypi.org/forums/viewt ... 5&p=652324
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Low latency encoding and transmission possible?

Sat Jan 31, 2015 11:53 am

At work we have been doing some testing doing exactly this. Using gstreamer pipelines over RTP we have got very good results streaming from Pi to Pi, almost imperceptible latency and also Pi to PC (running VLC or similar). However, when using an Android phone over WIfi the latency was increased considerably. I think we fdid get it to go quicker, but not sure how - I wasn't doing the testing.

I think its one of those things you will need to try. I beleive it's the Android end that is the problem, not the Pi. SO probably will vary according to the handset.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10600
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Low latency encoding and transmission possible?

Sat Jan 31, 2015 12:11 pm

jamesh wrote:I think its one of those things you will need to try. I beleive it's the Android end that is the problem, not the Pi. SO probably will vary according to the handset.
With my experience of the Android stack, very much this. Low latency, efficient, and Android rarely happens.
With recording we ended with the last 2-3 SECONDS of recordings getting dropped due to inefficient ways that the standard Android framework worked and our output FIFO had just backed up that much. We had to do nasty hacks to get it to work nicely, and there was a nice clean way to solve the issue within the framework too :(
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

shubhamjan12
Posts: 11
Joined: Thu Apr 02, 2015 10:54 am

Re: Low latency encoding and transmission possible?

Thu Apr 02, 2015 12:47 pm

jamesh wrote:At work we have been doing some testing doing exactly this. Using gstreamer pipelines over RTP we have got very good results streaming from Pi to Pi, almost imperceptible latency and also Pi to PC (running VLC or similar). However, when using an Android phone over WIfi the latency was increased considerably. I think we fdid get it to go quicker, but not sure how - I wasn't doing the testing.

I think its one of those things you will need to try. I beleive it's the Android end that is the problem, not the Pi. SO probably will vary according to the handset.
Hi jamesh i want to receive the stream through Pi (Using GST-RTSP server on pi) to VLC (On Windows 7 PC). As you have mentioned here that you have done so. Can you please guide me through because i am having some problems. I have used following command on Pi side to create rtsp server:

Code: Select all

 raspivid -t 0 -h 320 -w 240 -rot 90 -fps 25 -b 2000000 -vf -hf -n -o - | gst-launch -v fdsrc ! h264parse ! gdppay ! tcpserversink host=192.168.1.15 port=5000 | ./test-launch "( tcpclientsrc host=192.168.1.15 port=5000 ! gdpdepay ! avdec_h264 ! rtph264pay name=pay0 pt=96 )"
Where 192.168.1.15 is the IP address of my pi
and i am receiving it using VLC on windows by the rtsp://192.168.1.15:8554/test The problem is VLC is showing only a single image (i.e a single frame). While it is working smoothly on GOM player by the same link. But i need to use VLC. Please guide me through. Thanks in advance.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28358
Joined: Sat Jul 30, 2011 7:41 pm

Re: Low latency encoding and transmission possible?

Thu Apr 02, 2015 1:22 pm

Here is a copy paste of some notes I made, I cannot guarantee these are the exact ones we used.

Code: Select all

// Source
raspivid -fps 15 -b 400000 -t 0 -n -w 640 -h 480 -o - | tee | gst-launch-1.0 fdsrc ! h264parse ! rtph264pay ! udpsink host=192.168.1.255 port=5000

// Destination (can be same machine)
gst-launch-1.0 --gst-debug 3 udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! omxh264dec ! "video/x-raw, format=(string)I420" ! eglglessink

More working Raspi send/receives

./raspivid --profile baseline --intra 15 -if cyclic -fps 15 -b 200000 -t 0 -n -w 640 -h 480 -o - | gst-launch-1.0 fdsrc ! h264parse ! rtph264pay ! udpsink host=192.168.1.255 port=5000

gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! omxh264dec !  fbdevsink

Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

shubhamjan12
Posts: 11
Joined: Thu Apr 02, 2015 10:54 am

Re: Low latency encoding and transmission possible?

Sat Apr 04, 2015 1:14 pm

jamesh wrote:Here is a copy paste of some notes I made, I cannot guarantee these are the exact ones we used.

Code: Select all

// Source
raspivid -fps 15 -b 400000 -t 0 -n -w 640 -h 480 -o - | tee | gst-launch-1.0 fdsrc ! h264parse ! rtph264pay ! udpsink host=192.168.1.255 port=5000

// Destination (can be same machine)
gst-launch-1.0 --gst-debug 3 udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! omxh264dec ! "video/x-raw, format=(string)I420" ! eglglessink

More working Raspi send/receives

./raspivid --profile baseline --intra 15 -if cyclic -fps 15 -b 200000 -t 0 -n -w 640 -h 480 -o - | gst-launch-1.0 fdsrc ! h264parse ! rtph264pay ! udpsink host=192.168.1.255 port=5000

gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! omxh264dec !  fbdevsink

Hi Jamesh, Thanks for your quick reply but none of your code worked for me (Bad luck this time...) I want to use a method so that i can receive video streaming from RPi(server) to VLC (Client) without any big lag. Although i am able to do so by using VLC on pi side but the lag is approx1-2 sec that is too much.

User avatar
eriktheitalian
Posts: 358
Joined: Thu Feb 19, 2015 1:03 pm

Re: Low latency encoding and transmission possible?

Sat Apr 04, 2015 2:50 pm

I'm not realy professional for this. I have questions.

Real time kernel is advantage for this process. ?
Encoding using sdcard or totaly done in sdram not ? ( for topic maker )
BFS cpu scheduler was good for screen render related latency. Is it usable for this process ?
I cant using enough English language. My writings can be wrong grammer.$
"in micro$oft we not trust"

luckyguy
Posts: 7
Joined: Fri Apr 17, 2015 5:50 pm

Re: Low latency encoding and transmission possible?

Sat Apr 18, 2015 11:28 pm

jamesh wrote:At work we have been doing some testing doing exactly this. Using gstreamer pipelines over RTP we have got very good results streaming from Pi to Pi, almost imperceptible latency and also Pi to PC (running VLC or similar). However, when using an Android phone over WIfi the latency was increased considerably. I think we fdid get it to go quicker, but not sure how - I wasn't doing the testing.

I think its one of those things you will need to try. I beleive it's the Android end that is the problem, not the Pi. SO probably will vary according to the handset.
I need to do exactly this; stream from rpi to rpi
Would you mind sharing how you solved this?

Return to “Camera board”