Open source command line subtitle converter

46,521

Solution 1

You can try FFmpeg (great tool !) :

$ ffmpeg -i file.srt file.vtt

Solution 2

very simple and effective oneliner i use to convert subtitles:

for i in *.ass ; do ffmpeg -i "$i" "$i.srt" ; done

just change ass and srt according to your needs.

Solution 3

Subtitles perl swiss army knife (scroll to the end of the page).

Here you can find more options.

Also, mplayer/mencoder has some dumpXXXsub options, which might work. I never tried this, but reading the man, it should work. Example:

-dumpmpsub (MPlayer only)
              Convert the given subtitle (specified with the -sub option) to MPlayer's subtitle format, MPsub.  Creates a dump.mpsub file in the current directory.

Solution 4

The open source program Subtitle Edit has a command line converter and is available for both Windows and Linux.

Syntax: SubtitleEdit /convert "pattern" "name-of-format-without-spaces"

Example 1: SubtitleEdit /convert sub1.srt sami
Result: Will convert sub1.srt to sub1.sub to SAMI format

Example 2: SubtitleEdit /convert *.srt adobeencore
Result: Will convert all .srt files to Adobe Encore format

For Linux the command line needs to be slightly longer…

Syntax: mono SubtitleEdit.exe /convert "pattern" "name-of-format-without-spaces"

…but could easily be wrapped in a script.

Solution 5

I found that some players (e.g., Google Drive video player) do not like the .srt generated from:

ffmpeg -i subtitles.ass <blah>.srt

or:

SubtitleEdit /convert subtitles.ass subrip

but:

ffmpeg -i subtitles.ass -codec:s text subtitles.srt

...did the trick for me.

Share:
46,521

Related videos on Youtube

Szakacs Botond
Author by

Szakacs Botond

Updated on September 17, 2022

Comments

  • Szakacs Botond
    Szakacs Botond almost 2 years

    Are there any open source, command line, subtitle converters - preferably for Linux?

  • Szakacs Botond
    Szakacs Botond over 14 years
    Simple text subtitles. SRT, STL, SUB, PAC. Back and forth.
  • Szakacs Botond
    Szakacs Botond over 14 years
    Indeed this is handy, sadly though only three different formats are supported; .srt, .sub, .smi.
  • Shevek
    Shevek over 14 years
    @johnas - my answer updated with a couple of possibilities
  • Szakacs Botond
    Szakacs Botond over 14 years
    Thanks Shevek, but none of the above was command line operational. Though they would've been perfect if I could use the GUI.
  • Szakacs Botond
    Szakacs Botond over 14 years
    I checked the Mplayer and Mencoder out. Didnt get it working though. And it supports only SRT, SMI, SUB and JACO. A good suggestion though, thanks.
  • Peter.O
    Peter.O over 12 years
    The GUI works, but I got an error when running from the command line.. .I needed to install libmono-winforms for the GUI to work (as stated in the README)... Maybe there is something extra which is needed for the CLI to work... I get an AttachConsole... error. using Ubuntu 10.04 ...
  • Johanz
    Johanz over 12 years
    This seems to be fixed in version 3.2.3 - at least on Ubuntu
  • Peter.O
    Peter.O over 12 years
    @Johanz: Thanks. Version 3.2.3 works. It converted a .ass to SubRip (.srt) ... Just one thing I notieced: it produces \r\n (CRLF) line endings, even when the source line-ending is \n ... but that would rarely be a problem and is easily fixed with sed if need be.
  • Lukasz Frankowski
    Lukasz Frankowski almost 12 years
    Works nice, thanks! Here: pastebin.com/T6DM9xbq is my converter based on this with framerate detection using mplayer
  • user10607
    user10607 almost 9 years
    +1 as this is a really good converter and an open source application. And it has a cmd line interface.
  • Kamil Maciorowski
    Kamil Maciorowski almost 5 years
    What if the file name is big.assassins.assured (plus the extension)? Your sed will name it bigassinsured. Without sed and without this flaw: "${i%.ass}.srt".
  • 174140
    174140 almost 5 years
    What if Ffmpeg aborts?
  • Learning
    Learning almost 5 years
    ffmpeg is open source multimedia library.
  • IvanP
    IvanP almost 4 years
    That tool can convert anything :)
  • Sxilderik
    Sxilderik over 3 years
    for i in *.ass ; do ffmpeg -i "$i" "${i%.*}.srt" ; done
  • DUO Labs
    DUO Labs over 3 years
    @IvanP Apparently not ttml to $x$, though :(
  • jewishmoses
    jewishmoses almost 3 years
    keeps surprising me every time!