Open source command line subtitle converter

20

10

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

Johnas

Posted 2010-03-09T15:12:21.813

Reputation: 347

Answers

26

You can try FFmpeg (great tool !) :

$ ffmpeg -i file.srt file.vtt

SebMa

Posted 2010-03-09T15:12:21.813

Reputation: 599

9

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.

RASG

Posted 2010-03-09T15:12:21.813

Reputation: 592

7

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.

Sunny

Posted 2010-03-09T15:12:21.813

Reputation: 921

Indeed this is handy, sadly though only three different formats are supported; .srt, .sub, .smi. – Johnas – 2010-03-09T15:31:07.640

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. – Johnas – 2010-03-09T16:27:08.277

Works nice, thanks! Here: http://pastebin.com/T6DM9xbq is my converter based on this with framerate detection using mplayer

– Lukasz Frankowski – 2012-09-04T15:29:24.953

3

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.

Johanz

Posted 2010-03-09T15:12:21.813

Reputation: 84

+1 as this is a really good converter and an open source application. And it has a cmd line interface. – user10607 – 2015-09-11T19:57:56.970

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 ... – Peter.O – 2012-01-06T23:12:01.297

This seems to be fixed in version 3.2.3 - at least on Ubuntu – Johanz – 2012-01-15T10:29:05.293

1@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. – Peter.O – 2012-01-27T17:09:36.683

1

What is it you want to convert exactly? If it is between subtitle formats then it depends on which formats you are talking about. Those which are bitmap based will require OCR to convert to text format and generally always require user input for confirming the accuracy of the OCR

If it is all text formats then Jubler or Aegisub may be of use

Shevek

Posted 2010-03-09T15:12:21.813

Reputation: 15 408

Simple text subtitles. SRT, STL, SUB, PAC. Back and forth. – Johnas – 2010-03-09T15:24:21.507

@johnas - my answer updated with a couple of possibilities – Shevek – 2010-03-09T16:06:25.847

Thanks Shevek, but none of the above was command line operational. Though they would've been perfect if I could use the GUI. – Johnas – 2010-03-09T16:20:45.687

1

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.

Jim Sung

Posted 2010-03-09T15:12:21.813

Reputation: 11

0

rename the file name using sed

for i in ./*.ass ; do ffmpeg -i "$i" "$( echo "$i"|sed 's/\.ass//g' ).srt" ; done

if you want to delete the .srt file after converting, just add a rm command afterwards.

for i in ./*.ass ; do ffmpeg -i "$i" "$( echo "$i"|sed 's/\.ass//g' ).srt"  &&  rm -f "$i"  ; done

mdaliyan

Posted 2010-03-09T15:12:21.813

Reputation: 1

1What 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". – Kamil Maciorowski – 2019-07-24T07:58:48.243

0

#!/bin/bash

file="*.srt"                     # Find file
ffmpeg -i "$file" "${file%.*}.vtt"   # Convert file  
rm "$file"                         # Remove file .srt from your dir

if you want to convert more file using this program in for loop.

Manoj kumar Linux

Posted 2010-03-09T15:12:21.813

Reputation: 1

What if Ffmpeg aborts? – 174140 – 2019-08-25T11:08:03.623

ffmpeg is open source multimedia library. – Manoj kumar Linux – 2019-08-25T11:13:30.013

0

With Windows batch file, you could use this to convert all text-subtitle files in folder to SRT

for %%i in (*.vtt .ass .ssa) do ffmpeg -i "%%i" "%%~ni.srt"

Na Nonthasen

Posted 2010-03-09T15:12:21.813

Reputation: 1