fyhertz / libstreaming

A solution for streaming H.264, H.263, AMR, AAC using RTP on Android
Apache License 2.0
3.49k stars 1.08k forks source link

Peer to Peer Streaming in Android Device Delay in stream video #163

Open testsoft49 opened 8 years ago

testsoft49 commented 8 years ago

Hello All,

I have integrate lib streaming library in server android app and start RTSP server in that Android app. Now in second application i have used video view for playing RTSP link. I have used same wi-fi network for communication. So one android device active as RTSP server and second Android device as client. I have set custom video quality and used MediaCodec API the surface-to-buffer method.

My Video Quality set as : setVideoQuality(new VideoQuality(800, 600, 20, 500000))

My Test Scenario: 1) When i play rtsp link client app in my samsung tab 10.1 then its takes 1 minute and then after display video and start after remove first 30 seconds video. 2) same problem like samsung tab in lenova device. 3) Also checked another android device Mi Redmi and display video after 5 seconds its good.

I have modified my code for delay frame after reading some comments but not success. In RtpSocket comment out all calls to Thread.sleep Thread.sleep(mCacheSize); if (mCacheSize>0) Thread.sleep(d);

Can some one please suggest me what changes require in library so video display in client side within 5 seconds ?

Waiting for good suggestion and thanks for help.

Locnath commented 8 years ago

Sorry wasn't clear with couple of statements below. Do you mean there is a 5s lag from server to client? (some action done on server side camera is displayed on client side display after 5s?)

On 24-Dec-2015 6:15 pm, testsoft49 notifications@github.com wrote:Hello All,

I have integrate lib streaming library in server android app and start RTSP server in that Android app Now in second application i have used video view for playing RTSP link I have used same wi-fi network for communication So one android device active as RTSP server and second Android device as client I have set custom video quality and used MediaCodec API the surface-to-buffer method

My Video Quality set as : setVideoQuality(new VideoQuality(800, 600, 20, 500000))

My Test Scenario: 1) When i play rtsp link client app in my samsung tab 101 then its takes 1 minute and then after display video and start after remove first 30 seconds video 2) same problem like samsung tab in lenova device 3) Also checked another android device Mi Redmi and display video after 5 seconds its good

I have modified my code for delay frame after reading some comments but not success In RtpSocket comment out all calls to Threadsleep Threadsleep(mCacheSize); if (mCacheSize>0) Threadsleep(d);

Can some one please suggest me what changes require in library so video display in client side within 5 seconds ?

Waiting for good response

—Reply to this email directly or view it on GitHub.

testsoft49 commented 8 years ago

Hello Locnath,

Thanks for your quickly response. currently in some devices samsung tablet 10.1 inch and lenova device 30s lag from server to client. (Means after 60 second client display video and first 30 sec video can't display in client and start video with after 31 second). Let me know still you have not clear for my above query.

Locnath commented 8 years ago

I have faced this same problem. I think the videoview widget in Android is not meant for real time streaming use cases like peer to peer streaming. This is because there is some minimum initial buffering done by android stagefright to ensure smooth playback in internet streaming  use cases. This initial buffering results in the lag seen in peer to peer streaming use cases. You would have to implement a custom RTP player on the client side to playback the incoming encoded H264 packets from the server. This would have to depacketize the NAL packets and extract the encoded packets and then feed it to the decoder. I had implemented a prototype RTP client through which I was able to bring down the latency down to less than a second for 640*480 resolution. (using videoview based player, the latency was around 4 seconds) On 25-Dec-2015 2:03 pm, testsoft49 notifications@github.com wrote:Hello Locnath,

Thanks for your quickly response. No currently in some devices samsung tablet 10.1 inch and lenova device 30s lag from server to client. (Means after 60 second client display video and first 30 sec video can't display start video with 31 second). Let me know still you have not clear for my above query.

—Reply to this email directly or view it on GitHub.