RootEncoder icon indicating copy to clipboard operation
RootEncoder copied to clipboard

Crash java.lang.NullPointerException on Android 4.2

Open digitalStyx opened this issue 9 years ago • 7 comments

Hi i've got crash on Android 4.2.2 on HTC One X+. In fabric I also see many crash on this version. On version higher than 4.2 work correctly.

java.lang.NullPointerException at net.ossrs.rtmp.SrsFlvMuxer$SrsFlv.writeVideoSample(SrsFlvMuxer.java:769) at net.ossrs.rtmp.SrsFlvMuxer.sendVideo(SrsFlvMuxer.java:214) at com.pedro.rtplibrary.rtmp.RtmpCamera1.getH264DataRtp(RtmpCamera1.java:79) at com.pedro.rtplibrary.base.Camera1Base.getH264Data(Camera1Base.java:367) at com.pedro.encoder.video.VideoEncoder.getDataFromEncoder(VideoEncoder.java:447) at com.pedro.encoder.video.VideoEncoder.access$1100(VideoEncoder.java:30) at com.pedro.encoder.video.VideoEncoder$1.run(VideoEncoder.java:243) at java.lang.Thread.run(Thread.java:864)

I have code:

rtmpCamera1 = new RtmpCamera1(mSurfaceView, this); rtmpCamera1.prepareAudio(); rtmpCamera1.prepareVideo(lastResolution[0], lastResolution[1], FPS,chooseBitrate(lastResolution[1]), true, 0); rtmpCamera1.startStream(fabricateStreamName());

What can be?

digitalStyx avatar Nov 29 '17 11:11 digitalStyx

First of all check if your device has h264 and aac encoders.

if (rtmpCamera1.prepareAudio() && rtmpCamera1.prepareVideo(lastResolution[0], lastResolution[1], FPS,chooseBitrate(lastResolution[1]), true, 0) {
//you have a valid h264 and aac encoders you cna now stream
}

Show me too more logcat to know more info. What object give you null pointer and that line? 447 in VideoEncoder class is a else https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/blob/master/encoder/src/main/java/com/pedro/encoder/video/VideoEncoder.java#L447

pedroSG94 avatar Nov 29 '17 12:11 pedroSG94

Hi @pedroSG94 Functions prepareAudio and prepareVideo always return true;

I don't know which TAG of logs are interest for you. It's all: https://pastebin.com/yZ33Hagb

digitalStyx avatar Nov 29 '17 13:11 digitalStyx

I did a fix that could fix your problem. https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/723fb5ba09f462b2b38426889a3f872ed3ce28f5 Download the last commit of the project and try with my app.

pedroSG94 avatar Nov 29 '17 15:11 pedroSG94

Now it's work :) Could you put it on jitpack?

digitalStyx avatar Nov 30 '17 09:11 digitalStyx

done.

pedroSG94 avatar Nov 30 '17 12:11 pedroSG94

Thx @pedroSG94 .

I have one more question, and it's not important :) In https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/38ceae74e0c7e65ef22713c3477f7cbd8a092c95 You removed method getStreamWidth and getStreamHeight. Now, how I can get actual or default resolution from A/V stream if I start prepareVideo without any parameters. I see in code that it is 640x480, but I can get this values.

digitalStyx avatar Nov 30 '17 13:11 digitalStyx

You can't get resolution. I recomend use preparevideo with params allways because maybe some devices cant open to 640x480. prepare methods without params are only to do a fast demo or test. That method was removed because I used it to know texture resolution of the camera when I use openglview and then set correct resolution to the stream objects but I dont need now. If you want I can do it. This is simple you only need do a get to the VideoEncoder.

pedroSG94 avatar Nov 30 '17 16:11 pedroSG94