1

after posting an answer to this question Buffering Surface input to MediaCodec it was suggested I ask a new question even though I was answering the last question...

i have stuttering video on both a galaxy note 10.1 tablet and a lenovo yoga hd tablet...the former is on 4.1.2 so it's pre-cts and possibly wont get fixed...dequeueoutputbuffer always returns bufferinfo.size of 0 so cts test will never display the surface if display is based on size. The lenovo is 4.3 and has > 0 size but the video stutters and appears to be due to the fact the input buffers are rarely available. The same code works fine on GalaxyS3 and Nvidia Shield.

Is there an issue with calling dequeueInputBuffer too often? Is there a problem with the driver on the Lenovo?

Community
  • 1
  • 1
PapaWhiskey
  • 117
  • 1
  • 13
  • Pre-4.3 you get what you get. 4.3+ should work. Input buffers should be available whenever the codec needs more data, so the absence of input buffers suggests that the codec isn't able to keep up (is it a software implementation?). Does video playback from Grafika look okay? (Try playing one of the generated movies in a loop at 60fps; if that works, try capturing some video and see how that goes.) – fadden Jun 17 '14 at 17:28
  • The generated movies look a little "hiccupy" (i used sliders), but hard to really tell...captured video from camera looks fine. My implementation is reading TS data from file or from stream (udp currently), passing to a demuxer written in native, which returns the H264 data and feeds that to the decoder when we have full AUs. I only call dequeueInputBuffer when I have data to give to decoder. Reading from file was getting ahead of the decoder, so i did have to add a "throttle" if the input is way ahead. – PapaWhiskey Jun 17 '14 at 20:44
  • Your best bet is to get systrace instrumentation working (http://developer.android.com/tools/debugging/systrace.html). With API 18+ you can use https://developer.android.com/reference/android/os/Trace.html to add app events. Most devices support systrace, though I think GS3 might not, and you want a rooted device to get at some of the more useful things ("sched" tag). It's *very* useful for tracking down stutters. – fadden Jun 17 '14 at 22:49
  • I've done some instrumentation and not seen anything out of sorts...I based my current implementation on the Grafika movie player and as it's not stuttering, i'll have to take a second look to see what I did different (along with systrace). The Grafika player doesnt do any throttling that I can see, other than using the PTS on output, which would throttle the input as the whole thread is sleeping, so maybe thats the difference because i separated processInput and processOutput into two different functions – PapaWhiskey Jun 18 '14 at 15:17

1 Answers1

1

The stuttering was due to two things...on tablets for some reason the garbage collection is happening more often and the delay was longer than on other devices. Due to the delay from the GC, the "preRender" function I swiped from the Grafika sample would get out of sorts once it fell "behind"...fixing the GC issues and adding a "reset" to the preRender if it fell behind removed stuttering

PapaWhiskey
  • 117
  • 1
  • 13
  • Can you explain how you fixed the GC issues? – Wajih Mar 04 '15 at 06:21
  • for my particular app, in regards to the video "chunks" that come from my c/c++ code, i'm able to wait on a free buffer from the codec versus having to keep a linked list of buffers and send them in as the codec gives me an input buffer...that helped immensely mDecoder.dequeueInputBuffer(-1); – PapaWhiskey Mar 04 '15 at 19:17
  • Thanks for the reply - well i read somewhere that we need to push in a single NAL unit in order to get it correctly working, I have been doing that but i am still getting stutter, even the video freezes for a moment before It runs again. I was using a concurrent queue to buffer the incoming packets and then send them one by one to the decoder, despite all my efforts I am unable to remove stutter. – Wajih Mar 05 '15 at 05:26
  • I have posted a detailed question, may be you can have a look at it http://stackoverflow.com/questions/28870905/h264-streamed-video-stutter-and-freeze-with-mediacodec-android-4-1-2 – Wajih Mar 05 '15 at 07:12
  • my reputation is still too low to comment on your post, but I do have comments...you can contact me directly...my contact info is in profile – PapaWhiskey Mar 05 '15 at 17:29