libvlc_video_set_subtitle_file not working

libvlc_video_set_subtitle_file not working

本文关键字:not working file set video libvlc subtitle      更新时间:2023-10-16

我使用以下代码来设置字幕文件,但由于某些原因,它不起作用。

QString selectedFile = QFileDialog::getOpenFileName(this, "Open");
if(selectedFile == NULL) {
    return;
}
qDebug("Before %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player));
//int a = libvlc_video_set_subtitle_file(player, selectedFile.toStdString().c_str());
int a = libvlc_video_set_subtitle_file(player, selectedFile.toLatin1().data());
qDebug("A = %d",a);
qDebug("After %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player));

设置特定文件前后的字幕索引和计数相同,函数返回1(int a)。

但是,使用libvlc_video_set_spu设置字幕是有效的。

我使用的是VLC 2.2.1

如果您在Windows上,QDir::toNativeSeparators将有所帮助:

const QString selectedFile = QFileDialog::getOpenFileName(this, "Open");
const QString nativePath = QDir::toNativeSeparators(selectedFile);
libvlc_video_set_subtitle_file(player, nativePath.toUtf8().constData());