ExoPlayer-奇怪的阿拉伯语/波斯语字幕格式 [英] ExoPlayer - Weird Arabic/Persian Subtitles Format

查看:128
本文介绍了ExoPlayer-奇怪的阿拉伯语/波斯语字幕格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建带有字幕的视频播放器.一切都已设置并正常工作,只有一件事.我的阿拉伯语字幕没有按原样显示纠正.他们看起来像是带有符号和东西的怪异..像这样的东西:

I'm trying to create a video player with subtitles. everything is set up and working correctly , except one thing. my Arabic subtitles are not showing correcting as they should be. they look so weird with symbols and stuff.. something like this :

这是我的带有字幕的ExoPlayer设置:

Uri srt = Uri.parse("http://download1651.mediafire.com/titdvyxje25g/j5wpodffdhn005r/Thor+3+.WEB+%28NoColored%29.srt");

    Handler mainHandler = new Handler();
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);
    player =
            ExoPlayerFactory.newSimpleInstance(this, trackSelector);
    DefaultBandwidthMeter bandwidthMeter2 = new DefaultBandwidthMeter();
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "yourApplicationName"), bandwidthMeter2);
    Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
            null, Format.NO_VALUE, Format.NO_VALUE, "ar", null, Format.OFFSET_SAMPLE_RELATIVE);
    MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
            .createMediaSource(Uri.parse(getVideoUri()));
    MediaSource textMediaSource = new SingleSampleMediaSource.Factory(dataSourceFactory)
            .createMediaSource(srt, textFormat, C.TIME_UNSET);
    MediaSource mediaSource = new MergingMediaSource(videoSource, textMediaSource);


    player.prepare(mediaSource);

我该如何解决这个问题?

is there any solution on how can i fix that ?

推荐答案

该文件的编码为 windows-1256 .您应该先将其更改为Unicode,然后才能正确看到它.

The encoding of that file is windows-1256. you should change it to Unicode first and then you can see it correctly.

BufferedReader reader = new BufferedReader(
        new InputStreamReader(new FileInputStream("arabic sub.srt"), "windows-1256")
    );
String line = null;
BufferedWriter writer = new BufferedWriter(
    new OutputStreamWriter(new FileOutputStream("new.srt"), "UTF-8")
);
while((line = reader.readLine())!= null){        
    writer.write(line);
    writer.write("\r\n");
}
writer.close();

这篇关于ExoPlayer-奇怪的阿拉伯语/波斯语字幕格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆