1

My problem is similar to this one, but there was no correct answer, so I thought I give it a go.

In my application I've got two video players (TextureView + MediaPlayer- based on VideoView) playing from URL side by side on one screen. I got it working quite right. As I need then them to play simultaneously I synced their controllers, to when I start one of them the second starts too (the same with pausing, seeking, buffering, etc).

videoView1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) {
            mp.setVolume(0.0f, 0.0f);
            firstVideoPrepared = true;
            tryStart();
        }
    });

videoView2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) {
            secondVideoPrepared = true;
            tryStart();
        }
    });

private void tryStart() {
    // here is also buffered data level check
    if (firstVideoPrepared && secondVideoPrepared) {
        videoView1.start();
        videoView2.start();
    }
}

The problem is that despite pausing both videos for buffering, when I start() them they sometimes get out of sync. Let's say that there is the same video in both players- I need them to be sync almost ideally as I can see any difference. Is there any way to keep them synced so precisely?

I've read about libraries like ExoPlayer, FFMPEGMediaPlayer or MediaPalyer-Extended but none of them seems to have what I need.

Is it even possible to keep that accuracy of videos sync?

Community
  • 1
  • 1
Mohru
  • 725
  • 1
  • 7
  • 17
  • Have you considered something like http://stackoverflow.com/questions/9293265/ffmpeg-2-videos-transcoded-and-side-by-side-in-1-frame ? – kpsharp Oct 24 '16 at 21:38
  • The problem is that I have to keep videos in separate containers as one of the functionalities is hiding/showing one of the videos. But this link addresses my question to some point. Unfortunately I'm not familiar with ffmpeg nor android ndk. Do you know of any wrappers I could use in Java code? – Mohru Oct 24 '16 at 22:50
  • What's more, I've found some android-ffmpeg libraries but all of them are under GPL/LGPL licences and my project is commercial, so I can't really use it. – Mohru Oct 25 '16 at 06:51

0 Answers0