GithubHelp home page GithubHelp logo

pedrosg94 / rootencoder Goto Github PK

View Code? Open in Web Editor NEW
2.4K 73.0 739.0 21.1 MB

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin

License: Apache License 2.0

Java 42.07% GLSL 2.09% Kotlin 55.84%
rtmp android rtsp java encoder stream filters streaming amf kotlin

rootencoder's People

Contributors

b95505017 avatar cubitspeed avatar dependabot[bot] avatar dsteve595 avatar dunkpi avatar ekslv avatar exxkx avatar florianmlr avatar fruchtzwerg94 avatar gizm090 avatar gsw945 avatar hbergqvist avatar hirogakatageri avatar hritikutekar avatar mandanai avatar marcin-adamczewski avatar marinesco avatar mikemannox avatar miwaniec avatar mkrn avatar mustafaboleken avatar nodinosaur avatar obsidiansnoo avatar pascalbaljet avatar pedrosg94 avatar svprdga avatar tbeyou avatar troy-lamerton avatar westy92 avatar ykenji 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  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  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  avatar

rootencoder's Issues

App not streaming

The app i created without changing any code from this repo, is not uploading any data.

it simply establishes connection, and then does nothing.

com.pedro.rtmpstreamer.R

Error:(67, 30) error: package com.pedro.rtmpstreamer does not exist
I added the lib through GitHub and I can get a connection established but no video will show and no data will write to the server. On the server it make a 0 byte file showing that the phone connects but never any data. I'm using the rtmpBuilder example. I have a surfaceView just like the one in the layout file.

Documentation of project

Hello,
First of all, I would like to thank you guys for creating such an amazing project for RTMP streaming. Can you please provide a proper documentation of project structure?

Unable to stop stream

Hi,

Thanks for such a great library.

When I am trying to stop the stream its not able to stop the stream when I have integrated the project through gradle.
But when I have try with downloaded code it working great.

Thank you.

Camera should show preview image

The flow for RT*PCamera classes appears to be wrong. (I am looking at TextureModeRtmpActivity and RtmpCamera2 in particular as Camera1 is deprecated in most cases.

The expected flow would be to:

  • open the app
  • see a preview
    • (allow someone to adjust themselves)
  • start streaming

It does not seem possible to draw the camera preview image to the surface before pressing startStream(...)

Is there a workaround?

just a question?

I have built an rtmp stream by using default rtmp in your sample app. But when i open this stream in vlc player, it is very very slow.I have no network problem. When i build an rtmp stream by using manycam mobile app, there is no issue . It is pretty fluent. How can i overcome this issue? Any idea?

thanks for your useful library

Brutal crash on Nexus4 with Android 5.1.1

Thanks for this project.
I have tried it out with Wowza Streaming CLoud but I have a brutal crash where my device gets killed and restarts. Unfortunately LogCat does not show any logs.
I tested the CustomRTSP example and only changing the resolution to 640 x 480 otherwise everything left as default. Wowza sees the connection and streaming starts but after 30 seconds the device reboots..

Any idea?

server Call Back

Hi
How can we get the status, when the server disconnected the stream,
for example when we are in live broadcast due to some network error the stream to server is lost in that scenario how can we identify the status of the stream,
also we need to reconnect the stream in specific interval.
we check that on on the RtmpBuilder class always shows the streaming is true.

rtmp works fine with SRS but not Wowza

EDIT: RESOLVED - I was using a wrong connection-string. It connected anyway but would of course not stream
This is the correct format:
"rtmp://70XXdbb.entrypoint.cloud.wowza.com:1935/app-XXX/9d7c917f"

I cannot get rtmp (and rtsp) working with Wowza (although I am currently testing only rtmp) using the sample-app (custom and standard). It works nice with SRS in rtmp though...

With Wowza connection seems to be OK (I get authentication = OK and connection status is OK) but the Statistics-data of Wowza Streaming Cloud (test account) does not show any data. I cannot see any disconnections in the logs. I am trying this on Samsung S8 over 4G/LTE and over WIFI.
My connection endpoint is "rtmp://70XXdbb.entrypoint.cloud.wowza.com:1935/app-XXX/9d7c917f/testrtmp" but it should be OK. Authentication is set before StartStream.

Any idea what the problem can be?
Anything in particular I should watch out for in LogCat?

Not an issue but just some questions

This is not an issue but just some questions:

-The rotation is bugging me when VLC (desktop) shows the stream with the wrong rotation. This seems to be limited to Portrait mode. If I understand correctly, mediacodec rotation = hardware rotation and if hardware rotation is set to true, the (software) rotation values are ignored. Is this correct? What is the exact purpose of hardware rotation?

-Is there a way to avoid start streaming again when switching cameras. Using my Samsung s8 the rotation changes when I see it in VLC after switching cameras. Maybe this is not possible to do on the fly because the server needs to know it beforehand? But maybe it is possible since the bitrate can be changed on the fly?

-having the possibility to change the bitrate on the fly, how would it be possible to adapt the bitrate automatically? Can I somehow get the current speed of the upload connection? Or do I need to get it from the server and than set the new bitrate value?

Thanks for this superb library.

Streaming without preview ( running app in background?)

Hi,
Could you please implement streaming without preview ?
A radio button / check box can be added to toggle On/OFF preview.

A] Intent is to start streaming on boot, with locked screen (i.e. without preview).
B] Something like linux watchdog / crontab can be used to restart the app at regular interval if not running.
C] Idea is to make it remote streaming device, which can run without supervision.

*Not sure how to handle android notifications. I would prefer running this app in background.

This feature will significantly boost the utility of this app.

rear and front camera rotation conflict

Hello,
i tried the library on 9 devices
by default the rear cam working great (portrait) but the front cam is flipped up side down
if i set the rotation degree to 270 , the front cam is ok but the rear is now flipped

also if possible to set which camera to start from the builder would be useful

thanks in advance

Connection Failure

Hi, first kudos on setting this up, I've been all over the place looking for an android rtmp client.

I pretty much copied your sample on the SurfaceView, and I'm trying to stream to azure media services. But I keep getting a connection failure, I don't have any more information on the reason why, the endpoint is open, I can test it using other tools, any hints on what could be the cause?

Here's the logcat of the starting of the streaming

08-23 09:46:40.920 16915-16915/org.springframework.cloud.stream.videostreaming I/MicrophoneManager: Microphone created, 44100hz, Stereo
08-23 09:46:40.921 16915-16915/org.springframework.cloud.stream.videostreaming I/MicrophoneManager: Microphone created, 44100hz, Stereo
08-23 09:46:40.923 16915-22285/org.springframework.cloud.stream.videostreaming I/OMXClient: MuxOMX ctor
08-23 09:46:40.930 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: videoEncoder OMX.qcom.video.encoder.avc type supported: video/avc
08-23 09:46:40.931 16915-16915/org.springframework.cloud.stream.videostreaming W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
08-23 09:46:40.931 16915-16915/org.springframework.cloud.stream.videostreaming W/VideoCapabilities: Unrecognized profile 2130706434 for video/avc
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2141391878
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2141391876
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2141391880
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2141391879
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2130708361
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 2135033992
08-23 09:46:40.932 16915-16915/org.springframework.cloud.stream.videostreaming I/VideoEncoder: Color supported: 21
08-23 09:46:40.937 16915-22289/org.springframework.cloud.stream.videostreaming I/OMXClient: MuxOMX ctor
08-23 09:46:40.956 16915-22289/org.springframework.cloud.stream.videostreaming E/ACodec: [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
08-23 09:46:40.957 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7fa30c06 = 2141391878
08-23 09:46:40.957 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7fa30c04 = 2141391876
08-23 09:46:40.957 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7fa30c08 = 2141391880
08-23 09:46:40.958 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7fa30c07 = 2141391879
08-23 09:46:40.958 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7f000789 = 2130708361
08-23 09:46:40.974 16915-22289/org.springframework.cloud.stream.videostreaming I/ACodec: setupAVCEncoderParameters with [profile: Baseline] [level: Level1]
08-23 09:46:40.977 16915-22289/org.springframework.cloud.stream.videostreaming I/ACodec: [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
08-23 09:46:40.977 16915-22289/org.springframework.cloud.stream.videostreaming I/ACodec: setupVideoEncoder succeeded
08-23 09:46:40.982 16915-22289/org.springframework.cloud.stream.videostreaming W/ACodec: do not know color format 0x7f000789 = 2130708361
08-23 09:46:41.026 16915-16915/org.springframework.cloud.stream.videostreaming I/AudioEncoder: AudioEncoder started
08-23 09:46:41.076 16915-22294/org.springframework.cloud.stream.videostreaming I/Camera2ApiManager: camera opened
08-23 09:46:41.078 16915-22294/org.springframework.cloud.stream.videostreaming I/Camera2ApiManager: camera configured
08-23 09:46:41.090 16915-16915/org.springframework.cloud.stream.videostreaming I/MicrophoneManager: Microphone started
08-23 09:46:41.092 16915-22330/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: worker: connecting to RTMP server by url=rtmp://xxx.channel.mediaservices.windows.net:1935/live/5dab22a72374418ba322c5e1f5437a33
08-23 09:46:41.092 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: connect() called. Host: xxx.channel.mediaservices.windows.net, port: 1935, appName: live, publishPath: 5dab22a72374418ba322c5e1f5437a33
08-23 09:46:41.250 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: connect(): socket connection established, doing handhake...
08-23 09:46:41.251 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC0
08-23 09:46:41.251 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1
08-23 09:46:41.252 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): Calculating digest offset
08-23 09:46:41.252 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): (real value of) digestOffset: 352
08-23 09:46:41.252 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): recalculated digestOffset: 1128
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): digestOffsetBytes: 000061FF
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: partBeforeDigest(): size: 1128
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): Writing timestamp and Flash Player version
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: partAfterDigest(): size: 376
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: copying digest offset bytes in partBeforeDigest
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): Calculating digest
08-23 09:46:41.253 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: writeC1(): writing C1 packet
08-23 09:46:41.254 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readS0
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readS1
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readS1(): S1 total bytes read OK
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readC2
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readS2
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/Handshake: readS2(): S2 total bytes read OK
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: connect(): handshake done
08-23 09:46:41.297 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: rtmpConnect(): Building 'connect' invoke packet
08-23 09:46:41.297 16915-22353/org.springframework.cloud.stream.videostreaming D/RtmpConnection: starting main rx handler loop
08-23 09:46:41.298 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: wrote packet: RTMP Command (command: connect, transaction ID: 1), size: 312
08-23 09:46:41.478 16915-22289/org.springframework.cloud.stream.videostreaming D/ACodec: dataspace changed to 0x10c40000 (R:2(Limited), P:4(BT601_6_525), M:3(BT601_6), T:3(SMPTE170M)) (R:2(Limited), S:4(BT601_525), T:3(SMPTE_170M))
08-23 09:46:41.488 16915-22293/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: annexb demux 29B, pts=487, frame=17B, nalu=7
08-23 09:46:41.488 16915-22293/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: annexb demux 29B, pts=487, frame=4B, nalu=8
08-23 09:46:41.488 16915-22293/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: flv: h264 sps/pps sent, sps=17B, pps=4B
08-23 09:46:41.511 16915-16924/org.springframework.cloud.stream.videostreaming W/MessageQueue: Handler (android.os.Handler) {f23a81d} sending message to a Handler on a dead thread
                                                                                               java.lang.IllegalStateException: Handler (android.os.Handler) {f23a81d} sending message to a Handler on a dead thread
                                                                                                   at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
                                                                                                   at android.os.Handler.enqueueMessage(Handler.java:643)
                                                                                                   at android.os.Handler.sendMessageAtTime(Handler.java:612)
                                                                                                   at android.os.Handler.sendMessageDelayed(Handler.java:582)
                                                                                                   at android.os.Handler.post(Handler.java:338)
                                                                                                   at android.hardware.camera2.dispatch.HandlerDispatcher.dispatch(HandlerDispatcher.java:61)
                                                                                                   at android.hardware.camera2.dispatch.MethodNameInvoker.invoke(MethodNameInvoker.java:88)
                                                                                                   at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.onClosed(CallbackProxies.java:177)
                                                                                                   at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:404)
                                                                                                   at android.hardware.camera2.impl.CameraCaptureSessionImpl.finalize(CameraCaptureSessionImpl.java:619)
                                                                                                   at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
                                                                                                   at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
                                                                                                   at java.lang.Thread.run(Thread.java:761)
08-23 09:46:41.600 16915-16915/org.springframework.cloud.stream.videostreaming I/MicrophoneManager: Microphone stopped
08-23 09:46:41.600 16915-22330/org.springframework.cloud.stream.videostreaming D/RtmpConnection: socket closed
08-23 09:46:41.601 16915-16915/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: SrsFlvMuxer closed
08-23 09:46:41.604 16915-22366/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: worker: disconnect ok.
08-23 09:46:41.624 16915-16915/org.springframework.cloud.stream.videostreaming I/AudioEncoder: AudioEncoder stopped
08-23 09:46:41.624 16915-16915/org.springframework.cloud.stream.videostreaming I/Choreographer: Skipped 31 frames!  The application may be doing too much work on its main thread.
08-23 09:46:41.633 16915-16915/org.springframework.cloud.stream.videostreaming I/MicrophoneManager: Microphone stopped
08-23 09:46:41.633 16915-16915/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: SrsFlvMuxer closed
08-23 09:46:41.634 16915-16915/org.springframework.cloud.stream.videostreaming I/AudioEncoder: AudioEncoder stopped
08-23 09:46:41.634 16915-22367/org.springframework.cloud.stream.videostreaming I/SrsFlvMuxer: worker: disconnect ok.

How Stream From SurfaceView Directly

Hi
Thank you for create powerful library for streaming
how can streaming to wowza server directly from surfaceview
i created project : get video stream from hardware and show on surface view now need stream to server
your library very good but : supported camera - file - display

Adding new builder for wider lib integration

Dear Pedro
can you suggest how I could integrate your library in an App where data comes from MediaCodec output buffers? The general use case is using the lib where data is coming from external sources that are not covered by the available four builders.

Does Not Send Video. No Error In nginx-rtmp Log.

I tried both Custom and Default RTMP. Audio received but not video.
I am using Moto G5 (Lenovo) with Android 7.0.
No error observed in nginx-rtmp Log.

I tried all variants of "YUV420" video encoder formats, none of them worked.

Camera onConfigureFailed

Trying to stream RTSP To Rtsp server set at our office:

I am trying since 1 month, but i am facing the issue of cameraDevice.createCaptureSession is leading to onConfigureFailed.

Need your help to resolve the same

I am using the android build as below (android version in the device is 5.1.1)
{
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.pedro.rtmpstreamer"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile project(':rtplibrary')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}

Logcat print as below:

startPreview: called
09-12 08:47:22.852 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: addPreviewSurface: addPreviewSurface in surface view
09-12 08:47:22.852 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: addPreviewSurface: addPreviewSurface in sufaceview.width : 0 , sufaceview.height : 0
09-12 08:47:22.853 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: startPreview: addPreviewSurface
09-12 08:47:22.853 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: startPreview: before add surface
09-12 08:47:22.853 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: startPreview: after add surface
09-12 08:47:22.861 8557-8670/com.pedro.rtmpstreamer I/sixth.Camera2ApiManager: camera opened
09-12 08:47:22.862 8557-8670/com.pedro.rtmpstreamer E/sixth.Camera2ApiManager: configuration failed

Crashes on start

I'm passing in a valid rtmp url to the rtmpBuilder.startStream(rtmp_url); but the app is crashing on RtmpBuilder.class line 87 this.cameraManager.start();.

Error reading com.pedro.encoder.input.video.CameraOpenException: This camera resolution cant be opened

Any ideas on how to get around this?

Network limited

looks like your library cannot use the full speed of available network connection. I tried Wowza gocoder and it fills my connection to the top providing great quality. Your library cannot make upload faster than 80-100 kB/s.

SoftCoding supported

I want to integrate the soft coding H264 or H265, that would be the first step to start, please advise. Thanks

disabling audio

Hello,
i need to stream Video only
DisableAudio method is just mutes the microphone which makes the microphone always busy while streaming.

anyway to disable using the microphone at all ?

thanks

UnsupportedOperationException: eglCreateWindowSurface() Android 4.1.1 on swith camera or stop

Hi!
I tried to use your library in project and found few bugs.
One of them:

Problem device: ASUS Padfone 2 with Android 4.1.1 (API 16)

App crashes on camera switch or stop streaming.
Exception:
java.lang.UnsupportedOperationException: eglCreateWindowSurface() can only be called with an instance of SurfaceView, SurfaceHolder or SurfaceTexture at the moment, this will be fixed later.
In Camera1ApiManager.clearSurface() method

My solution change argument of this method from Surface to SurfaceHolder:

clearSurface(surfaceView.getHolder());

private void clearSurface(SurfaceHolder texture) {
...
}

I am not expert in video streaming, but I hope you wil use my solution to do your library better.

This fix works fine on all my devices:

ASUS Padfone 2 with Android 4.1.1 (API 16)
Samsung Galaxy Tab Pro with Android 4.4.2
Nexus 5 with Android 6.0.1

NetworkOnMainThreadException

Hello,
Android 4.1.1

android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getByName(InetAddress.java:289)
at com.pedro.rtsp.rtp.sockets.RtpSocketUdp.setDestination(RtpSocketUdp.java:67)
at com.pedro.rtsp.rtp.packets.AccPacket.updateDestinationAudio(AccPacket.java:28)
at com.pedro.rtmpstreamer.builders.RtspBuilder.updateDestination(RtspBuilder.java:209)
at com.pedro.rtmpstreamer.ui.customexample.RtspActivity$2.run(RtspActivity.java:274)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4812)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)

Fix for Flashlight

In the enableLantern() method of the Camera1ApiManager.class, the following statement should be added:

lanternEnable = true;

otherwise lanternEnable will always be false.

Facebook RTMP handshake s0 no answer

Hi PedroSG94,

I'm trying to connect to facebook live RTMP via the "defaultexample". For some reason the readS0 property in the Handshake class doesn't read anything from the inputstream at the row 49 => "byte s0 = (byte) in.read();"
It stay stuck on that line, and according to the answer here, looks like I'm not getting any response from the socket : https://stackoverflow.com/questions/9129381/java-stuck-when-reading-from-inputstream
But from what I can see in debug, the "isConnected" socket attribute have the value "true".

Any idea how to solve this ?

Thanks

Can't play rtsp

hi could you tell me how to stream from rtsp link. i use with vlc it work ok

rtsp://mpv.cdn3.bigCDN.com:554/bigCDN/definst/mp4:bigbuckbunnyiphone_400.mp4

MediaMuxer

Hi,
With rtmp, you have MediaMuxer to mux the audio and video frames. What's about rtsp, which tool plays muxing role?
Thanks,

java.lang.IllegalStateException: Queue full

frame discarded, cant add more frames: 
                                                                      java.lang.IllegalStateException: Queue full
                                                                          at java.util.AbstractQueue.add(AbstractQueue.java:69)
                                                                          at com.pedro.encoder.video.VideoEncoder.inputNv21Data(VideoEncoder.java:286)
                                                                          at com.pedro.builder.base.BuilderBase.inputNv21Data(BuilderBase.java:185)
                                                                          at com.pedro.encoder.input.video.Camera1ApiManager.onPreviewFrame(Camera1ApiManager.java:192)
                                                                          at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1563)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:168)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5845)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)

happened immediately when I tried to stream with RTMP (both default and custom)

Red5 connection

@pedroSG94

I tested Red5 again today (my Wowza trial ran out 🔫)
I ran Red5-server on a Mac, downloaded, amended the server urls and ran:

Success!

SWF #1
SimpleSubscriber.fla

  • The code for this swf can be found in the first frame.
  • The swf connects to rtmp://<insert IP>/oflaDemo/red5BroadcastDemo
  • note: red5BroadcastDemo

and have managed to successfully stream from the Android App to the Server!

FFMPEG streaming also worked!
./ffmpeg -i guardians2.mp4 -f flv rtmp://192.168.1.4/oflaDemo/red5BroadcastDemo

SWF #2
simpleSubscriber.fla

The sample that is on the demos page (http://<insert IP>:5080/demos) is not the same as SWF #1

  • The code for this swf can be found here Main.as
  • http://<insert IP>:5080/demos/simpleSubscriber.html connects to rtmp://<insert IP>/oflaDemo/red5StreamDemo
  • note: red5StreamDemo

Another thing, you will need to allow Flash Player to access the correct urls (I did this in Advanced -> Developer Tools -> Trusted Location Settings and Peer-assisted Network Settings by Site)

Does not send video. Exception thrown

I tried the sample application. It only sends the audio. The video is not sent.
I used Samsung galaxy S6 running android 6.0.1
Same issue on Google Nexus 5 running 5.1.1

Here is the exception
com.pedro.rtmpstreamer E/SrsFlvMuxer: frame discarded, cant add more frame:
java.lang.IllegalStateException: Queue full
at java.util.AbstractQueue.add(AbstractQueue.java:69)
at net.ossrs.rtmp.SrsFlvMuxer$SrsFlv.flvFrameCacheAdd(SrsFlvMuxer.java:845)
at net.ossrs.rtmp.SrsFlvMuxer$SrsFlv.writeRtmpPacket(SrsFlvMuxer.java:839)
at net.ossrs.rtmp.SrsFlvMuxer$SrsFlv.writeAudioSample(SrsFlvMuxer.java:687)
at net.ossrs.rtmp.SrsFlvMuxer.sendAudio(SrsFlvMuxer.java:220)
at com.pedro.builder.RtmpBuilder.getAccData(RtmpBuilder.java:163)
at com.pedro.encoder.audio.AudioEncoder.getDataFromEncoderAPI21(AudioEncoder.java:119)
at com.pedro.encoder.audio.AudioEncoder.inputPcmData(AudioEncoder.java:98)
at com.pedro.builder.RtmpBuilder.inputPcmData(RtmpBuilder.java:178)
at com.pedro.encoder.input.audio.MicrophoneManager$1.run(MicrophoneManager.java:71)
at java.lang.Thread.run(Thread.java:818)

Here, I've attached the full log.
https://gist.github.com/mohsalsaleem/b176857179a4321fc981c60d44ed38fa

hi i find a error

08-25 15:13:21.220 30796-30796/com.pedro.rtmpstreamer I/android.media.AudioRecord: startRecording
08-25 15:13:21.230 30796-30796/com.pedro.rtmpstreamer I/AudioRecordPermission: remindWithResult:false
08-25 15:13:21.240 30796-30796/com.pedro.rtmpstreamer I/AudioRecord: sendStateChangedIntent, state=3
08-25 15:13:21.240 30796-30796/com.pedro.rtmpstreamer I/MicrophoneManager: Microphone started
08-25 15:13:21.240 30796-30796/com.pedro.rtmpstreamer I/Choreographer: Skipped 34 frames! The application may be doing too much work on its main thread.
08-25 15:13:22.050 30796-31612/com.pedro.rtmpstreamer I/System: core_booster, getBoosterConfig = false
08-25 15:13:22.050 30796-31612/com.pedro.rtmpstreamer I/System.out: [socket][3] connection /192.168.253.1:554;LocalPort=53544(3000)
08-25 15:13:22.050 30796-31612/com.pedro.rtmpstreamer I/System.out: [CDS]connect[/192.168.253.1:554] tm:3
08-25 15:13:22.060 30796-31612/com.pedro.rtmpstreamer I/System.out: [socket][/192.168.253.3:53544] connected

                                                                [ 08-25 15:13:22.070  2643:31588 I/         ]
                                                                [Grace_0.0.5.0][smartAf]af_doAF: flow: 0, giNumFlagDoAF: 1, afType: 1

08-25 15:13:22.100 30796-31612/com.pedro.rtmpstreamer I/RtspClient: RTSP/1.0 415 Unsupported Media Type
Server: EasyDarwin/7.0.5 (Build/16.0518; Platform/Win32; Release/EasyDarwin; State/Development; )
Cseq: 1
Connection: Close
08-25 15:13:22.100 30796-31612/com.pedro.rtmpstreamer I/System.out: [CDS]shutdownInput in read
08-25 15:13:22.100 30796-31612/com.pedro.rtmpstreamer I/System.out: [CDS]shutdownInput in read
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: java.net.SocketException: sendto failed: EPIPE (Broken pipe)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:572)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.IoBridge.sendto(IoBridge.java:541)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.net.PlainSocketImpl.write(PlainSocketImpl.java:506)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:37)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:266)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.io.BufferedWriter.flush(BufferedWriter.java:124)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at com.pedro.rtsp.rtsp.RtspClient$2.run(RtspClient.java:217)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at java.lang.Thread.run(Thread.java:831)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: Caused by: android.system.ErrnoException: sendto failed: EPIPE (Broken pipe)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.Posix.sendtoBytes(Native Method)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.Posix.sendto(Posix.java:206)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:278)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: at libcore.io.IoBridge.sendto(IoBridge.java:539)
08-25 15:13:22.110 30796-31613/com.pedro.rtmpstreamer W/System.err: ... 8 more
08-25 15:13:22.260 30796-30796/com.pedro.rtmpstreamer I/android.media.AudioRecord: stopRecording
08-25 15:13:22.340 30796-30796/com.pedro.rtmpstreamer I/AudioRecord: sendStateChangedIntent, state=1
08-25 15:13:22.340 30796-30796/com.pedro.rtmpstreamer I/android.media.AudioRecord: stopRecording
08-25 15:13:22.340 30796-30796/com.pedro.rtmpstreamer I/AudioRecord: sendStateChangedIntent, state=1
08-25 15:13:22.340 30796-30796/com.pedro.rtmpstreamer I/MicrophoneManager: Microphone stopped
08-25 15:13:22.400 30796-30796/com.pedro.rtmpstreamer I/AudioEncoder: AudioEncoder stopped

stop stream

when i stop the streaming (i use nginx to stream)
i get this error
E/AndroidRuntime: FATAL EXCEPTION: Thread-1518
java.lang.NullPointerException
at com.pedro.encoder.video.VideoEncoder$1.run(VideoEncoder.java:244)
at java.lang.Thread.run(Thread.java:841)

Android 4.1.1 (API 16)RTSP not working (fix attached)

Hi!
I tried to use your library in project and found few bugs.
One of them:

Problem device: ASUS Padfone 2 with Android 4.1.1 (API 16)
RTSP example did not work on it and crashes after ~20-30 seconds.
I investigated the problem and found the cause - there are no call of rtspClient.connect(); - because no call of RTSPBuilder.onSPSandPPS() - because no MediaCodec.INFO_OUTPUT_FORMAT_CHANGED in getDataFromEncoder() method.

I implement folowing solution and propogate it to you:
To get SPS and PPS params we can use flag MediaCodec.BUFFER_FLAG_CODEC_CONFIG in MediaCodec.BufferInfo.flags and parse SPS and PPS from buffer.
This is my modified VideoEncoder.getDataFromEncoder() method and decodeSpsPpsFromBuffer() method:

  private void getDataFromEncoder(byte[] buffer) {
    ByteBuffer[] inputBuffers = videoEncoder.getInputBuffers();
    ByteBuffer[] outputBuffers = videoEncoder.getOutputBuffers();

    int inBufferIndex = videoEncoder.dequeueInputBuffer(-1);
    if (inBufferIndex >= 0) {
      ByteBuffer bb = inputBuffers[inBufferIndex];
      bb.clear();
      bb.put(buffer, 0, buffer.length);
      long pts = System.nanoTime() / 1000 - mPresentTimeUs;
      videoEncoder.queueInputBuffer(inBufferIndex, 0, buffer.length, pts, 0);
    }

    for (; ; ) {
      int outBufferIndex = videoEncoder.dequeueOutputBuffer(videoInfo, 0);
      if (outBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
        MediaFormat mediaFormat = videoEncoder.getOutputFormat();
        getH264Data.onSPSandPPS(mediaFormat.getByteBuffer("csd-0"),
            mediaFormat.getByteBuffer("csd-1"));
        spsPpsWasSet = true;
      } else if (outBufferIndex >= 0) {
        //!!!!!!!!!!!!!!!!!!!
        if((videoInfo.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG)!=0) {
          if (!spsPpsWasSet) {
            Pair<ByteBuffer, ByteBuffer> buffers = decodeSpsPpsFromBuffer(outputBuffers[outBufferIndex], videoInfo.size);
            if(buffers!=null) {
              getH264Data.onSPSandPPS(buffers.first, buffers.second);
              spsPpsWasSet = true;
            }
          }
        } else {
          //This ByteBuffer is H264
          ByteBuffer bb = outputBuffers[outBufferIndex];
          getH264Data.getH264Data(bb, videoInfo);
        }
        videoEncoder.releaseOutputBuffer(outBufferIndex, false);
      } else {
        break;
      }
    }
  }

  private Pair<ByteBuffer, ByteBuffer> decodeSpsPpsFromBuffer(ByteBuffer outputBuffer, int length) {
    byte[] mSPS = null, mPPS = null;
    byte[] csd = new byte[length];
    outputBuffer.get(csd, 0, length);
    int i = 0;
    int spsIndex = -1;
    int ppsIndex = -1;
    while(i < length-4) {
      if(csd[i] == 0 && csd[i+1] == 0 && csd[i+2] == 0 && csd[i+3] == 1) {
        if(spsIndex==-1) {
          spsIndex = i;
        } else {
          ppsIndex = i;
          break;
        }
      }
      i++;
    }
    if(spsIndex!=-1 && ppsIndex!=-1) {
      mSPS = new byte[ppsIndex];
      System.arraycopy(csd, spsIndex, mSPS, 0, ppsIndex);
      mPPS = new byte[length-ppsIndex];
      System.arraycopy(csd, ppsIndex, mPPS, 0, length-ppsIndex);
    }
    if (mSPS != null && mPPS != null) {
      return new Pair<>(ByteBuffer.wrap(mSPS), ByteBuffer.wrap(mPPS));
    }
    return null;
  }

Similarly it needs in getDataFromEncoderAPI21() I think.

I am not expert in video streaming, but I hope you wil use my solution to do your library better.

With this fix RTSP works fine on all my devices:

  • ASUS Padfone 2 with Android 4.1.1 (API 16)
  • Samsung Galaxy Tab Pro with Android 4.4.2
  • Nexus 5 with Android 6.0.1

Auth error

I pasted a rstp stream url,and clicked the 'strart stream' button,
then I always saw toast showing that "Auth error".
I saw the log:

I/RtspClient: RTSP/1.0 401 Unauthorized
Server: DSS/5.5.5 (Build/489.16; Platform/Linux; Release/Darwin; state/beta; )
Cseq: 1
WWW-Authenticate: Digest realm="Streaming Server", nonce="cba1e24d77d2b0f00c91f0e2f3f06ade"

Could you please give me any idea how can I resolve this problem, thank you :)

Reverse camera video display

My phone is Nexus 5x Android Oreo. I use rear camera and the display video is reverse to 180 but front camera is fine. how I to fix it ?

Wrong detection of encoder resolutions.

On my Huawei 5A LYO-21 your app detect resolutions of encoder wrong. I do
List sizesRtmp = rtmpBuilder.getResolutions();
and get a lot of diffrent resolutions (some of them are strange like 1872x1120 or 1920x1088), but I'm confident that my phone can't record video more than 1280x720. So by default your app and my app on your library select resolution 1872x1120 and crashes. It can make stream only on resolutions 1280x720 and below. But on other device app detect resolutions right, without strange variants and top resolution is 1920x1080. So, can you fix it or i doing something wrong?

autoFocus failed

Hello,

on some cheap devices that not supporting autofocus on front cam i always gets this error
"autoFocus failed"

note : we changed the default starting camera to front cam instead of rear cam.

RTSP to machine/server ?

Hey,

Just wondering if you could help me out.
I am trying to find a free RTSP server (that handles UDP) or a FFMPEG command so I can watch the RTSP stream.

RtspBuilder rtspBuilder = new RtspBuilder(surfaceView, Protocol.UDP, this);
if (rtspBuilder.prepareAudio() && rtspBuilder.prepareVideo()) {
    rtspBuilder.startStream("rtsp://10.0.0.18:5000/Test");
} else {
    Log.d("error","encoding");
    /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}

ffplay -rtsp_flags listen -i rtsp://10.0.0.18:5000 -rtsp_transport udp

This ffplay command works and the logs say I am connected but I cannot see any video from it even though I can see the UDP packets coming (from TCPDUMP).

I cannot really find a working example in your application.
What do you recommend to use with your lib ?

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.