-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronize video and audio positions when seekTo #8644
Comments
ExoPlayer does not out of the box (see next comment) support synchronisation between two ExoPlayer Instances. You will then be able to switch from video1 to video2 by defining a custom @tonihei what would you recommend to switch video for this use-case? |
If I understand the requirements correctly the transition doesn't even need to be seamless. So if you know all sources in advance, @krocard's suggestion is probably the best way:
If you want to swap tracks at playback position 1000, I'd also recommend to use Having only one player ensures you automatically get A/V sync because there is only one media clock. If you really need multiple players, then synchronizing them is considerably more complicated, but not impossible:
See also #4549 for a similar question. But note that some information in this issue is out of date because we now have options in |
@krocard I haven't tried a custom TrackSelection, so I will check it out. |
@tonihei I actually tried using multiple players, I thought that this method is not correct, so first I will try again to see if seamless switching can be achieved by using MergingMediaSource. If it is still difficult to achieve, I would like to try the following.
|
I forgot to say that if you know in advance how long video1 should play before switching to video2, things are much simpler. You could use 2 Cliping MediaSource to clip the end of video1 after Xms and clip the beginning of video2 of the same Xms. The switch should be seamless and no class need to be implemented. The drawback is that only 1 video switch can occur and it's timestamp must be known before the video start playing. |
Regarding MediaSource, video deals with videos from different viewpoint. Is Clipping MediaSource effective even in such a case? |
If you know the switch point in advance, then If your goal is to instantaneously switch in the moment the user presses a button and still get perfectly seamless transitions, then I'm afraid it's more complicated. In order for a seamless switch to work, the player needs to start decoding samples before they are displayed. That means if you want the switch to happen immediately, the player already needs to have the decoded samples available. This in turn means both videos need to be decoded in parallel all the time.
|
My goal is perfect seamless switching.
Is it possible to implement the contents explained above in the case of textureView? |
The things discussed above independent of the view/surface you use. |
@tonihei
I don't understand this. Also, I would like to confirm the above methods. |
Seeking can never be completely seamless because the player always needs to decode the new samples first. This happens in the renderers on a much lower level than
Sounds right. Note we are happy to give hints on how to approach complex implementations, but we can't really provide detailed app support especially when it goes beyond our usually supported features. So it would be great if you can try to work with what we provided so far. |
Thanks for reply. |
I created the AudioRendererWithoutClock, MultiTrackRenderersFactory, and MultiTrackSelector described in #6589.
exception
I'm investigating what's wrong. |
It was played if I specified multiple audio files. |
@tonihei
Currently, it seems that video1 and video2 are playing, but only video1 is visible. |
I understand that it may be possible to achieve it by using setSelectionOverride. |
@tonihei mediaSource
player setup
I specified videoRenderer from renderers and called createMessage.
In this case, video1 will be displayed.
From the above behavior, I thought that it would be possible to switch videos by changing the renderer specification, but in this case nothing is displayed.
output log
I thought it was necessary to clear the surface, so I called |
You probably need to set the actual surface with ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java Line 1863 in 4364b91
Also note that if you swap surfaces, the remove call (with |
Thank you for advice. |
Closing for now as issue has been discussed and no further questions came up. |
I use two video players and one audio player to play HlsMediaSource.
I'm trying to switch to video player2 while playing video player1, and synchronize the video and audio positions.
AudioPlayer is always playing.
In the above state, if calling videoPlayer2.seekTo(videoPlayer1.currentPosition), the playbackState of videoPlayer2 will be STATE_BUFFERING -> STATE_READY.
In this case, it takes time for videoPlayer2 to become STATE_READY, so the currentPositions of videoPlayer2 and audioPlayer are different, so there will be a gap between the video and audio.
for example
I want to eliminate this gap and synchronize the video and audio positions.
If buffering occurs when seekingTo, I think position synchronization is difficult.
Is there any good way?
Also, is it possible to eliminate buffering when seekingTo?
The text was updated successfully, but these errors were encountered: