Skip to content

Commit

Permalink
ffmpeginterface: Fix subtitles under windows
Browse files Browse the repository at this point in the history
There is a problem related to relative and global paths with
subtitles in ffmpeg.
For more information, check: https://trac.ffmpeg.org/ticket/3334

Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Jun 24, 2020
1 parent d82f900 commit 8edb3f2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions converter/ffmpeginterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ffmpeginterface.h"
#include "mediaprobe.h"
#include "exepath.h"
#include <QDir>
#include <QRegExp>
#include <QTextStream>
#include <QDebug>
Expand Down Expand Up @@ -384,6 +385,19 @@ QStringList FFmpegInterface::Private::getOptionList(const ConversionParameters &

QString command;

#ifdef Q_OS_WIN32
// Fix any problems related to native separators under Windows
// For more information about this: https://trac.ffmpeg.org/ticket/3334
auto TransformToFFMPEGSubtitleBackslash = [](QString& path) {
path = QDir::toNativeSeparators(path);
path = path.replace(R"(\)", R"(\\)");
path = path.replace(R"(:)", R"(\:)");
};

for(QString* subtitle : {&subtitlesrt, &subtitlessa, &subtitlesub, &subtitleass}) {
TransformToFFMPEGSubtitleBackslash(*subtitle);
}
#endif
if (subtitle_srt.exists())
{
command = QString("subtitles='%1':force_style='FontName=Sans Serif,OutlineColour=&H00000000,WrapStyle=2,Borderstyle=1,Outline=1,Shadow=1,Fontsize=28':charenc=ISO-8859-1").arg(subtitlesrt);
Expand Down

0 comments on commit 8edb3f2

Please sign in to comment.