Skip to content

Commit 801a84c

Browse files
committed
fix : 解决重新播放器时音频时间戳不对齐的问题
Signed-off-by: JeffMony <[email protected]> #branch=master
1 parent 1686b3c commit 801a84c

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

app/src/main/java/com/jeffmony/playerdemo/MainActivity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ private void initViews() {
6666
// http://sns-video-bd.xhscdn.com/stream/110/258/01e4326d8b792647010370038764ff7d3c_258.mp4
6767
// http://videoconverter.vivo.com.cn/201706/655_1498479540118.mp4.main.m3u8
6868
// http://sns-video-bd.xhscdn.com/stream/110/258/01e4326d8b792647010370038764ff7d3c_258.mp4
69-
mUrlText.setText("file:///storage/emulated/0/DCIM/Camera/long_gop.mp4");
69+
// mUrlText.setText("file:///storage/emulated/0/DCIM/Camera/long_gop.mp4");
7070

71+
mUrlText.setText("file:///storage/emulated/0/Pictures/VIDEO_20230713_231426.mp4");
7172
mExoBtn.setOnClickListener(this);
7273
mIjkBtn.setOnClickListener(this);
7374
mOrcodeBtn.setOnClickListener(this);

playersdk/src/main/java/com/jeffmony/playersdk/impl/IjkPlayerImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public IjkPlayerImpl(Context context, PlayerParams params) {
2727
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1);
2828

2929
//不用opensles编解码
30-
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "opensles", 0);
30+
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "opensles", 1);
3131
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "overlay-format", IjkMediaPlayer.SDL_FCC_RV32);
3232
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 1);
3333
mPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 0);

third_party/ijkmedia/ijkplayer/ff_ffplay.c

+7
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ static void video_image_display2(FFPlayer *ffp)
904904
if (!ffp->first_video_frame_rendered) {
905905
ffp->first_video_frame_rendered = 1;
906906
ffp_notify_msg1(ffp, FFP_MSG_VIDEO_RENDERING_START);
907+
is->audio_start_reset = 1;
907908
}
908909
while (is->pause_req && !is->abort_request) {
909910
SDL_Delay(20);
@@ -914,6 +915,7 @@ static void video_image_display2(FFPlayer *ffp)
914915
if (!ffp->first_video_frame_rendered) {
915916
ffp->first_video_frame_rendered = 1;
916917
ffp_notify_msg1(ffp, FFP_MSG_VIDEO_RENDERING_START);
918+
is->audio_start_reset = 1;
917919
}
918920

919921
if (is->latest_video_seek_load_serial == vp->serial) {
@@ -2720,6 +2722,11 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len, int32_t aud
27202722
/* Let's assume the audio driver that is used by SDL has two periods. */
27212723
if (!isnan(is->audio_clock)) {
27222724
double sync_audio_clock = is->audio_clock;
2725+
if (is->audio_start_reset) {
2726+
audio_render_time = 0;
2727+
*adjust_time = 0;
2728+
is->audio_start_reset = 0;
2729+
}
27232730
if (is->audio_seek_req && is->seek_completed) {
27242731
audio_render_time = is->seek_completed_pos;
27252732
*adjust_time = audio_render_time;

third_party/ijkmedia/ijkplayer/ff_ffplay_def.h

+1
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ typedef struct VideoState {
426426
int audio_seek_req;
427427
int seek_completed;
428428
int seek_completed_pos;
429+
int audio_start_reset;
429430
} VideoState;
430431

431432
/* options specified by the user */

0 commit comments

Comments
 (0)