fyhertz / libstreaming

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

Use OuputFormat =8 (TS) in MediaRecorder #194

Open yeahman45 opened 8 years ago

yeahman45 commented 8 years ago

Hi, I have an android box which has a capture card in it.. the capture card is accessed by using camera ID = 5.. so far I have modified the libstreaming to open camera ID = 5 with no problem.. I am stuck with one issue... the capture card does not support MP4 recording.. it supports only TS recording via mediarecorder.. so I have set output of mediarecorder to 8 mMediaRecorder.setOutputFormat(8);

There is a block of code in VideoStream.java --> encodeWithMediaRecorder() that skip the MPEG4 Header... so I commented it as I think it is not necessary as I have set mediarecorder to record in TS format...

Streaming seems to work except that I have a grey streamed video (the video is all grey) and in logcat I have the following errors:

03-23 23:48:09.217: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: 1195376657) 03-23 23:48:09.217: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:09.217: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: 3012178) 03-23 23:48:09.225: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:09.229: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: -1997678917) 03-23 23:48:09.501: D/dalvikvm(21480): GC_FOR_ALLOC freed 405K, 27% free 4677K/6356K, paused 19ms, total 19ms 03-23 23:48:09.933: D/dalvikvm(21480): GC_FOR_ALLOC freed 641K, 30% free 4673K/6588K, paused 28ms, total 28ms 03-23 23:48:10.069: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:10.161: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: -1) 03-23 23:48:10.161: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:10.161: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: -200081479) 03-23 23:48:10.245: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:10.245: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: 3012178) 03-23 23:48:10.249: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:10.249: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: -183441643) 03-23 23:48:10.285: E/H264Packetizer(21480): A NAL unit may have been found in the bit stream ! 03-23 23:48:10.289: E/H264Packetizer(21480): Packetizer out of sync ! Let's try to fix that...(NAL length: -166666360)

I keeps displaying that error.. any idea plz?

yeahman45 commented 8 years ago

Digging deeper in the codes.. I found that there is a test done prior to streaming .. that test tries an mp4 recording with mediarecorder and use the MP4Parser top return the MP4Config ... which is used by the H264Packetizer (the pps and sps)

But my capture card cannot record in mp4 format, only in TS.. is there a way to get the pps and sps of a TS file instead?

yeahman45 commented 8 years ago

aynone?