pedroSG94 / RootEncoder

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
Apache License 2.0
2.54k stars 772 forks source link

E/H264Packet: waiting for a valid sps and pps #1073

Closed j0hnw0rk3r closed 7 months ago

j0hnw0rk3r commented 2 years ago

Hi @pedroSG94, First I'm greatful of this library it helped me wind up my streaming problems.

I have an android app that integrates a USB camera (Otoscope) using a UVC usb library but without RTMP support. The usb camera library (written in java) supports video encoder and exports chunk of videos which is ByteArray, and with offset, length, timestamp.

I want to stream this chunk of video data into my RTMP server (nginx). Using the RTMPClient class, I called sendVideo I sent the video data as:

val info = MediaCodec.BufferInfo()
info.offset = offset
info.size = length
info.presentationTimeUs = timestamp
rtmpClient.sendVideo(ByteBuffer.wrap(data), info)

But I'm getting

I/RtmpSender: Skipping iteration, frame null
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
E/H264Packet: waiting for a valid sps and pps
pedroSG94 commented 2 years ago

Hello,

You missed flag value in MediaCodec.BufferInfo class. Also, you need set sps and pps to RtmpClient class to init stream. You have an issue here that is like your case: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/issues/1033 RtspClient and RtmpClient usage is the same so you can apply all for this case.

j0hnw0rk3r commented 2 years ago

Thank you! I will try this and get back to you with results