Consti10 / LiveVideo10ms

Real time video decoding on android
GNU Lesser General Public License v3.0
75 stars 22 forks source link

feed decoder with End-of-Stream frame flag reduce latency #5

Open qiximenghu opened 3 years ago

qiximenghu commented 3 years ago
Hello. When I send IDR or P frame with frame flag End-of-Stream to the haerdware decoder and add vui information as your code, the MediaCodec decode H264 will not buffer frame, it will output frame immediately. Then after releaseOutputBuffer, flush the decoder, and queueInputBuffer make decoder Running again. I tested 720P@30fps h264 video on XiaoMi Mi8 device, the average decode time is about 7ms while without End-of-Stream flag is about 30ms. 
Howerver, when I render frame to surface and then flush decoder, it display little normal frame and lots of black frame.
Here is a test log. pts_times is  queueInputBuffer, pts_time_sb is dequeueOutputBuffer time, pts_time_sf is releaseOutputBuffer time.
Hope it helps you.

latency

Consti10 commented 3 years ago

Hello, Interesting. So you are basically doing the following: 1) feed frame (IDR or P) with EOS flag 2) "get" the decoded frame with low latency, but due to EOS one has to restart the decoder 3) repeat step 1 ?

Do you have a link to your code ?