If you were to save the video and extract the length of video in onVideoFileReady callback, it would sometimes cause doubling the length error, as this callback would be called twice in some cases, it really depends on how fast or slow your phone is as there was two MediaEncoder implementation going on, one for video(MediaVideoEncoder), another for audio(MediaAudioEncoder), their encoding runnable are finishing at the different rate.
If you were to save the video and extract the length of video in onVideoFileReady callback, it would sometimes cause doubling the length error, as this callback would be called twice in some cases, it really depends on how fast or slow your phone is as there was two MediaEncoder implementation going on, one for video(MediaVideoEncoder), another for audio(MediaAudioEncoder), their encoding runnable are finishing at the different rate.