Issue is that when amc was producing a codec-data buffer, a GstVideoCodecFrame was being popped off the internal queue. This meant that the codec-data was being associated with the first input frame and the second (first encoded buffer) output buffer with the second input frame. At the end (assuming one input produces one output which seems to hold in my testing and how the encoder is currently implemented) there would be an input frame missing and would be pushed without any timing information. This would lead to e.g. muxers rejecting the buffer without PTS and failing to mux.
requested to merge ystreet/gstreamer:androidmedia-handle-codec-data-before-frame into main