How to convert included subtitles in not UTF-8 encoding when their encoding is unknown

Viewed 2258

I'm trying to make automatic conversion of media files (video, audio, subtitles)

I use ffmpeg mainly.

I would subtitles convert to UTF-8 WebVTT files but I'm facing problem how to convert non UTF-8 encodings.

ffmpeg says:

[srt @ 0x559e9f111dc0] Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option
Error while decoding stream #0:8: Invalid data found when processing input

What to do when I don't know encoding at advance? (Should I use some other program? If so would you suggest some technique?)

Input is any media file - MKV, MP4, ... with bundled subtitle(s)

EDIT1:

full command with error:

ffmpeg -i input.mkv -c:s srt -map 0:s:3 3.srt

this pass OK:

ffmpeg -sub_charenc CP1250 -i input.mkv -c:s srt -map 0:s:3 3.srt
1 Answers

Normally, WebVTT must always be UTF-8 per the WebVTT specification. This is part of the reason FFmpeg does not attempt to detect and convert the encoding itself.

You can use one of the tools suggested in this Super User question for guessing the text file’s encoding and iconv to convert the file. (This can be scripted if you want it to happen automatically.) If you have additional questions about this, they are probably better suited for Super User.

Related