Giter Club home page Giter Club logo

consti10 / livevideo10ms Goto Github PK

View Code? Open in Web Editor NEW
65.0 8.0 21.0 922.75 MB

Real time video decoding on android

License: GNU Lesser General Public License v3.0

CMake 0.62% C++ 3.77% Java 1.71% C 80.69% Kotlin 0.09% Makefile 0.20% M4 0.15% Perl 0.02% Assembly 8.34% Roff 0.18% HTML 3.55% CSS 0.18% JavaScript 0.17% Rich Text Format 0.01% Shell 0.28% Python 0.05%
latency decoding mediacodec cpp rtp-streaming udp wifibroadcast live-streaming android

livevideo10ms's Introduction

Live Video 10ms Android

Release android_build_windows_workflow Consti10

Description
Library for live video playback with ultra low latency (below 10ms) on android devices. Supports playback of .h264 encoded live video data transmitted via UDP encapsulated in RAW or RTP and simple file playback.
Latency data (see example for more information)

Device Encoder avgTotalDecodingTime
Galaxy s9+ rpi cam 8.0ms
Galaxy s9+ x264 11.5ms
Pixel 3 rpi cam 11.2ms
Pixel 3 x264 10.5ms
HTC U11 rpi cam 8.6ms
HTC U11 x264 10.1ms

Example App
ExampleMain

This library has been optimized for low latency and tested on a wide variety of devices, including those running FPV-VR for wifibroadcast. The example library also contains test cases that can be executed on the 'gooogle firebase test lab'. These tests include feeding the decoder with faulty NALUs, created by a lossy connection. (e.g. wifibroadcast).

The 2 most important factors for low latency are

  1. HW-accelerated decoding via the MediaCodec api
  2. Receiving,Parsing and decoding is done in cpp code (multi-threaded). This decouples it from the java runtime, which increases performance and makes latency more consistent ( garbage collection halts all java threads, for example).

However, all native code needed for creating, starting and stopping the decoding process are exposed via the JNI, so you can use the lib without writing c/c++ code. The VideoPlayer class purposely has no pause/resume functions,since this library is for live video playback. Playback works on a 'best effort' principle, e.g. as soon as a receiver is created nalus are forwarded to the LowLagDecoder, but no frames can be decoded until enough I-frame data was received. Make sure to use a low enough I-frame interval with your h264 encoder. When receiving corrupted data (e.g from a lossy connection) the decoder will still generate frames if possible.

Structure:

  • VideoCore: contains the native code and java bindings
  • Example: simple example app. Playback of different .h264 files stored in the 'assets folder' of the app. Includes test case(s) \

Setup Dependencies
There are 2 ways to use VideoCore in your Project
1 Declaring Dependency via Jitpack: jitpack.io
➕ Easy
➖ cannot browse native libraries
Gradle example:

    allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io" }
        }
   }
   dependencies {
        implementation 'com.github.Consti10:LiveVideo10ms:v1.1'
   }

2 Forking the repo and including sources manually:
➕ browse native libraries
➕ modify code

  • To your top level settings.gradle file, add
include ':VideoCore'
project(':VideoCore').projectDir=new File('..\\LiveVideo10ms\\VideoCore')

and modify the path according to your download file

  • To your app level gradle file add
implementation project(':VideoCore')

See FPV-VR as an example how to add dependencies.

livevideo10ms's People

Contributors

consti10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

livevideo10ms's Issues

MPEG-TS support

Hi!

I am trying to display a stream from FFMPEG using your library with the lowest latency possible. FFMPEG's stream of raw h264 has higher latency than if transfering it via mpeg-ts. MPEG-TS has latency of 0.2-0.4 if streamed and displayed by ffmpeg, however mpeg-ts is not supported by the app.

Stream via UDP/RTP using FFMPEG for some reason does not seem to work with the app - also mentioned in this issue. I have also tried to stream with gstreamer command you have provided in that same issue - but the latency is about 1.5 seconds.

So I am wondering whether there any plans to support mpeg-ts? Otherwise maybe you could advice any other ways to overcome my problem? Thank you

@Consti10

streaming examples

How to stream a test video to the app? For example with FFmpeg? Here's what I tried (without success):
ffmpeg -re -i 1_reallyShort.mp4 -an -f rtp rtp://192.168.1.22:5600

feed decoder with End-of-Stream frame flag reduce latency

Hello. When I send IDR or P frame with frame flag End-of-Stream to the haerdware decoder and add vui information as your code, the MediaCodec decode H264 will not buffer frame, it will output frame immediately. Then after releaseOutputBuffer, flush the decoder, and queueInputBuffer make decoder Running again. I tested 720P@30fps h264 video on XiaoMi Mi8 device, the average decode time is about 7ms while without End-of-Stream flag is about 30ms. 
Howerver, when I render frame to surface and then flush decoder, it display little normal frame and lots of black frame.
Here is a test log. pts_times is  queueInputBuffer, pts_time_sb is dequeueOutputBuffer time, pts_time_sf is releaseOutputBuffer time.
Hope it helps you.

latency

playing rtsp URI

Hi, I came along to your library from a colleague.
How can I play the remote URI: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4
I have modified array.xml such that the first item has:
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4

Thanks for your feedback!

Question about decoding time 10ms

Hi,
I use this library to play rtp live video stream. It works much better than Gstreamer, and have less latency.

My question is about the decoding latency. I don't understand why the decode need 10ms or more to decode one video frame. My rtp source video is 720p 120 fps only I frame. in my opinion, the hardware decoder can decode the video in less than 1ms.
So I think the decoder may cache the video frame and cause the 10ms latency. I have try to enable the low latency mode, seems no effect.

difference from gstreamer

Hi,

this is just a question, today im using gstreamer in android to decode the RTP streaming. is there any value i will get using this library from using the standard gstreamer library. what would be the difference here.

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.