You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ExoPlayer升级后字幕停留在最后一句对话的问题求助

ExoPlayer 2.11.1内嵌字幕持续显示问题的解决方案
  • 检查字幕轨道时间戳
    内嵌字幕最后一条的结束时间戳异常(如未设置、设为极大值)会导致ExoPlayer 2.10+版本持续显示字幕。用FFmpeg解析字幕流验证:
    ffmpeg -i your_video.mp4 -map 0:s:0 -c copy -f webvtt -
    若发现结束时间不合理,重新生成字幕轨道,确保每条字幕都有明确的起止时间。

  • 自定义字幕可见性控制
    通过监听字幕更新和播放进度,强制在字幕过期后隐藏。示例代码:

    // 监听字幕变化
    subtitleView.addOnSubtitleChangedListener((view, subtitle) -> {
        view.setVisibility(subtitle != null && !subtitle.getCues().isEmpty() ? View.VISIBLE : View.GONE);
    });
    
    // 监听播放进度,兜底检查
    player.addListener(new Player.Listener() {
        @Override
        public void onPositionDiscontinuity(@DiscontinuityReason int reason) {
            checkSubtitleVisibility();
        }
    
        @Override
        public void onPlaybackStateChanged(int state) {
            if (state == Player.STATE_ENDED) {
                subtitleView.setVisibility(View.GONE);
            }
        }
    
        private void checkSubtitleVisibility() {
            long currentPos = player.getCurrentPosition();
            Subtitle currentSub = player.getCurrentSubtitle();
            if (currentSub != null) {
                subtitleView.setVisibility(currentSub.getCues(currentPos).isEmpty() ? View.GONE : View.VISIBLE);
            }
        }
    });
    
  • 单独降级字幕模块
    若不想整体升级,可单独替换字幕处理模块为旧版本(注意依赖冲突):

    implementation 'com.google.android.exoplayer:exoplayer-core:2.11.1'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.1'
    // 用2.8.4版本的字幕模块兼容
    implementation 'com.google.android.exoplayer:exoplayer-text:2.8.4'
    
  • 验证媒体封装格式
    部分内嵌字幕(如ASS)在MP4封装下,ExoPlayer 2.11.x的解析逻辑有变化。尝试转封装为MKV,或重新打包字幕轨道,确保元数据完整。

内容的提问来源于stack exchange,提问作者neojav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 17:19:58