[Guide]Adding SSA/ASS Subtitles

Frequently asked questions. Tutorials, tips and tricks.

[Guide]Adding SSA/ASS Subtitles

Unread postby Ricky1252 » 19 May 2013, 03:10

Hello, I decided to make a guide for everyone on adding SSA/ASS subtitles to Subsonic/Madsonic. This works for windows, linux and prob mac as well with a few tweaks. I will write this gude for both windows and linux users.(I only know Debian, Im not familiar with Fedora so any linux ref will be for Debian)

Upgrading ffmpeg
For starters, I want to state ffmpeg may need to be upgraded... http://www.ffmpeg.org/download.html
download a static build with --enable libass of your windows/linux/mac build and replace it in subsonic/transcode.
Windows Users
I suggest Zeranoe's FFmpeg build (static)
C:\subsonic\transcode
Linux Users
I suggest Burek's FFmpeg build (static)
/var/subsonic/transcode/

Setting up fonts.conf File
Windows Users Only
ffmpeg needs a font config file... create a folder named fonts in transcode ie... C:\subsonic\transcode\fonts
next make a text file in the fonts folder and name it fonts.conf

open text editor and place this in the file...

fonts.conf
Code: Select all
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>

<!--
   DO NOT EDIT THIS FILE.
   IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
   LOCAL CHANGES BELONG IN 'local.conf'.

   The intent of this standard configuration file is to be adequate for
   most environments.  If you have a reasonably normal environment and
   have found problems with this configuration, they are probably
   things that others will also want fixed.  Please submit any
   problems to the fontconfig bugzilla system located at fontconfig.org

   Note that the normal 'make install' procedure for fontconfig is to
   replace any existing fonts.conf file with the new version.  Place
   any local customizations in local.conf which this file references.

   Keith Packard
-->

<!-- Font directory list -->

   <dir>./</dir>
   <dir>WINDOWSFONTDIR</dir>
   <dir>~/.fonts</dir>

<!--
  Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
   <match target="pattern">
      <test qual="any" name="family">
         <string>mono</string>
      </test>
      <edit name="family" mode="assign">
         <string>monospace</string>
      </edit>
   </match>

<!--
  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
   <match target="pattern">
      <test qual="any" name="family">
         <string>sans serif</string>
      </test>
      <edit name="family" mode="assign">
         <string>sans-serif</string>
      </edit>
   </match>

<!--
  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
   <match target="pattern">
      <test qual="any" name="family">
         <string>sans</string>
      </test>
      <edit name="family" mode="assign">
         <string>sans-serif</string>
      </edit>
   </match>

<!--
  Load local system customization file
-->
   <include ignore_missing="yes">conf.d</include>

<!-- Font cache directory list -->

   <cachedir>WINDOWSTEMPDIR_FONTCONFIG_CACHE</cachedir>
   <cachedir>~/.fontconfig</cachedir>

   <config>
<!--
  These are the default Unicode chars that are expected to be blank
  in fonts.  All other blank chars are assumed to be broken and
  won't appear in the resulting charsets
 -->
      <blank>
         <int>0x0020</int>   <!-- SPACE -->
         <int>0x00A0</int>   <!-- NO-BREAK SPACE -->
         <int>0x00AD</int>   <!-- SOFT HYPHEN -->
         <int>0x034F</int>   <!-- COMBINING GRAPHEME JOINER -->
         <int>0x0600</int>   <!-- ARABIC NUMBER SIGN -->
         <int>0x0601</int>   <!-- ARABIC SIGN SANAH -->
         <int>0x0602</int>   <!-- ARABIC FOOTNOTE MARKER -->
         <int>0x0603</int>   <!-- ARABIC SIGN SAFHA -->
         <int>0x06DD</int>   <!-- ARABIC END OF AYAH -->
         <int>0x070F</int>   <!-- SYRIAC ABBREVIATION MARK -->
         <int>0x115F</int>   <!-- HANGUL CHOSEONG FILLER -->
         <int>0x1160</int>   <!-- HANGUL JUNGSEONG FILLER -->
         <int>0x1680</int>   <!-- OGHAM SPACE MARK -->
         <int>0x17B4</int>   <!-- KHMER VOWEL INHERENT AQ -->
         <int>0x17B5</int>   <!-- KHMER VOWEL INHERENT AA -->
         <int>0x180E</int>   <!-- MONGOLIAN VOWEL SEPARATOR -->
         <int>0x2000</int>   <!-- EN QUAD -->
         <int>0x2001</int>   <!-- EM QUAD -->
         <int>0x2002</int>   <!-- EN SPACE -->
         <int>0x2003</int>   <!-- EM SPACE -->
         <int>0x2004</int>   <!-- THREE-PER-EM SPACE -->
         <int>0x2005</int>   <!-- FOUR-PER-EM SPACE -->
         <int>0x2006</int>   <!-- SIX-PER-EM SPACE -->
         <int>0x2007</int>   <!-- FIGURE SPACE -->
         <int>0x2008</int>   <!-- PUNCTUATION SPACE -->
         <int>0x2009</int>   <!-- THIN SPACE -->
         <int>0x200A</int>   <!-- HAIR SPACE -->
         <int>0x200B</int>   <!-- ZERO WIDTH SPACE -->
         <int>0x200C</int>   <!-- ZERO WIDTH NON-JOINER -->
         <int>0x200D</int>   <!-- ZERO WIDTH JOINER -->
         <int>0x200E</int>   <!-- LEFT-TO-RIGHT MARK -->
         <int>0x200F</int>   <!-- RIGHT-TO-LEFT MARK -->
         <int>0x2028</int>   <!-- LINE SEPARATOR -->
         <int>0x2029</int>   <!-- PARAGRAPH SEPARATOR -->
         <int>0x202A</int>   <!-- LEFT-TO-RIGHT EMBEDDING -->
         <int>0x202B</int>   <!-- RIGHT-TO-LEFT EMBEDDING -->
         <int>0x202C</int>   <!-- POP DIRECTIONAL FORMATTING -->
         <int>0x202D</int>   <!-- LEFT-TO-RIGHT OVERRIDE -->
         <int>0x202E</int>   <!-- RIGHT-TO-LEFT OVERRIDE -->
         <int>0x202F</int>   <!-- NARROW NO-BREAK SPACE -->
         <int>0x205F</int>   <!-- MEDIUM MATHEMATICAL SPACE -->
         <int>0x2060</int>   <!-- WORD JOINER -->
         <int>0x2061</int>   <!-- FUNCTION APPLICATION -->
         <int>0x2062</int>   <!-- INVISIBLE TIMES -->
         <int>0x2063</int>   <!-- INVISIBLE SEPARATOR -->
         <int>0x206A</int>   <!-- INHIBIT SYMMETRIC SWAPPING -->
         <int>0x206B</int>   <!-- ACTIVATE SYMMETRIC SWAPPING -->
         <int>0x206C</int>   <!-- INHIBIT ARABIC FORM SHAPING -->
         <int>0x206D</int>   <!-- ACTIVATE ARABIC FORM SHAPING -->
         <int>0x206E</int>   <!-- NATIONAL DIGIT SHAPES -->
         <int>0x206F</int>   <!-- NOMINAL DIGIT SHAPES -->
         <int>0x2800</int>   <!-- BRAILLE PATTERN BLANK -->
         <int>0x3000</int>   <!-- IDEOGRAPHIC SPACE -->
         <int>0x3164</int>   <!-- HANGUL FILLER -->
         <int>0xFEFF</int>   <!-- ZERO WIDTH NO-BREAK SPACE -->
         <int>0xFFA0</int>   <!-- HALFWIDTH HANGUL FILLER -->
         <int>0xFFF9</int>   <!-- INTERLINEAR ANNOTATION ANCHOR -->
         <int>0xFFFA</int>   <!-- INTERLINEAR ANNOTATION SEPARATOR -->
         <int>0xFFFB</int>   <!-- INTERLINEAR ANNOTATION TERMINATOR -->
      </blank>
<!--
  Rescan configuration every 30 seconds when FcFontSetList is called
 -->
      <rescan>
         <int>30</int>
      </rescan>
   </config>

</fontconfig>


Save it, and then you will need to add some environment variables.

Environment Variables
Windows Users Only
Hit the windows button and in the search type... env .... then hit enter and the env variables should pop up.
The Environment variables can also be accessed by right clicking computer or my computer properties, then hitting advanced system settings, go to advanced tab, and at the bottom will be environment variables.

in the env variables, two will need to be added...
User Variables For Admin

FC_CONFIG_DIR (this is the variable name)
C:\subsonic\transcode\fonts (this is the variable value)

and

FC_CONFIG_FILE
C:\subsonic\transcode\fonts\fonts.conf

Update Madsonic
This will work with Madsonic Version 5.0.3500+ If you haven't already, update! =]

Transcoding
Now then we can move onto transcoding... First off make a folder in your transcoding folder and name is sub...
Windows Users
C:\subsonic\transcode\sub
Linux Users
/var/subsonic/transcode/sub

This will be the directory for all your ssa/ass subtitle files.. also let me note that a ssa/ass file is required to transcode with ffmpeg. For a fail safe, for a case theres no subtitle file, make a file in the transcode folder named clean.ass with this contents

clean.ass
Code: Select all
[Script Info]
ScriptType: v4.00+
[V4+ Styles]


Now, mainly I only use the subtitles for mkv files, because thats the only container I need it for, but you can do this for any file type as long as you provide a subtitle file.

In Madsonic... Settings...Transcode...add transcoding
name: ssa/ass
convert from: mkv (make sure any filetype added here is removed from other transcodes)
convert to: flv or webm (depending on if your using HTML5 or Flash)

Windows Users Flash
Step 1
Code: Select all
ffmpeg -i transcode\clean.ass -n transcode\sub\%f.ass

Step 2
Code: Select all
ffmpeg -ss %o -i %s -b %bk -s %wx%h -copyts -af asetpts=PTS-%o/TB -vf ass='transcode\\sub\\%f.ass',setpts=PTS-%o/TB -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast -threads 0 -


Windows Users HTML5
Step 1
Code: Select all
ffmpeg -i transcode\clean.ass -n transcode\sub\%f.ass

Step 2
Code: Select all
ffmpeg -ss %o -t %d -i %s -vf lutyuv=y=val*1.3,ass='transcode\\sub\\%f.ass',setpts=PTS-%o/TB -b %bk -s %wx%h -copyts -af asetpts=PTS-%o/TB -ar 44100 -ac 2 -v 0 -f webm -vcodec libvpx -preset superfast -acodec libvorbis -threads 0 -


Linux Users Flash
Step 1
Code: Select all
ffmpeg -i /var/subsonic/transcode/clean.ass -n /var/subsonic/transcode/sub/%f.ass

Step 2
Code: Select all
ffmpeg -ss %o -i %s -b %bk -s %wx%h -copyts -af asetpts=PTS-%o/TB -vf ass='/var/subsonic/transcode/sub/%f.ass',setpts=PTS-%o/TB -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast -threads 0 -


Linux Users HTML5
Step 1
Code: Select all
ffmpeg -i /var/subsonic/transcode/clean.ass -n /var/subsonic/transcode/sub/%f.ass

Step 2
Code: Select all
ffmpeg -ss %o -t %d -i %s -vf lutyuv=y=val*1.3,ass='/var/subsonic/transcode/sub/%f.ass',setpts=PTS-%o/TB -b %bk -s %wx%h -copyts -af asetpts=PTS-%o/TB -ar 44100 -ac 2 -v 0 -f webm -vcodec libvpx -preset superfast -acodec libvorbis -threads 0 -


And done! now to test to make sure everything was done correctly / working properly! play a mkv, or whatever filetype you added and if it plays then bam! you are ready to start adding SSA/ASS files. As a note, because this is a burn in transcode, these subtitles will work on all devices, like android. cheers =]


Extracting SSA/ASS files
from a container... example...
abc.mkv
Code: Select all
ffmpeg -i abc.mkv abc.ass

if theres more then one subtitle in the container first do the input
Code: Select all
ffmpeg -i abc.mkv

look at the streams it will say 0:0 is video 0:1 is audio then it could have 0:2 with another audio or subtitle and so on, find the subtitle you want and do...
example of it having subtitle on stream 0:2 0:3 and 0:4 and you want 0:3... by default, it will extract the default subtitle or lowest numbered on the stream.
Code: Select all
ffmpeg -i abc.mkv -map 0:3 abc.ass

Linux Users
To do a simple batch file...name it something like assconvert with this contents...
assconvert
Code: Select all
for m in *.mkv
   do
   ffmpeg -i "$m" -y "/var/subsonic/transcode/sub/${m%mkv}ass"
done

may need to grant execution so..
# chmod 755 assconvert
then place it in the folder and do..
# ./assconvert

Windows Users
Alternatively you can also download mkvtoolnix with mkvextractgui (place the gui in mkvtoolnix)
version 2.2.2.5 can extract fonts and all other versions should be able to extract anything else.



Adding Fonts (optional)
Windows Users
Easy! All you do is get a font like [fontname].ttf and right click and install it! simple =]

Linux Users
At least for debian, fonts folder should be /usr/share/fonts
Mainly I only needed ttf, but added a folder in truetype called myfonts... ie /usr/share/fonts/truetype/myfonts
Add your ttf's or otf's or any desired font you want then in the terminal...
Code: Select all
# cd /usr/share/fonts/truetype/myfonts
# mkfontscale && mkfontdir
# fc-cache


Trouble shooting
If you get a access denied error, first hit the play. If it still shows access denied, check the log.

If it say font config error or something stating the config file, that means of course something isnt working right with env variables (probably) Windows can be picky. Make sure the env variables and config file is exactly where I described.

If its showing something like missing .ass file or something mostlikely missing the clean.ass file, or it could be a problem with one of the characters used in the file name. I have not really looked into what characters these are and sometimes they work with some files and dont with others, it is odd but the first thing to check would be things like ! , ; ~ any of the special characters really.

If theres no sub folder in transcoding, you not be able to generate an .ass file which will generate the access denied error.

For windows, if Madsonic was not installed in the default folder, wherever it was installed,(where you to replaced the .war at) is also where you need to create the sub folder for your subtitles. By default, wherever it was installed is where the root directory is. Also take out the transcode folder in the transcode so that it says sub\ instead of transcode\sub the clean.ass will need to be moved to this directory as well.

Sometimes when converting container ssa/ass subs (older ones anyway) in ffmpeg, I noticed the .ass may have a small error... example...
random.ass
Code: Select all
[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, TextDialogue: 0,0:00:00.52,0:00:03.71,Ep Song,,0000,0000,0000,,{\a6\i1}I want to change the world
Dialogue: 0,0:00:03.75,0:00:07.24,Ep Song,,0000,0000,0000,,{\a6}jounetsu tayasazu ni

The above example will generate an access denied error. it needs to be like this...
Code: Select all
[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.52,0:00:03.71,Ep Song,,0000,0000,0000,,{\a6\i1}I want to change the world
Dialogue: 0,0:00:03.75,0:00:07.24,Ep Song,,0000,0000,0000,,{\a6}jounetsu tayasazu ni


Any questions or comments, or something I made a mistake on. Please let me know! Im not good at making things colorful and pretty so sorry this guide doesn't look amazing. XD
Last edited by Ricky1252 on 11 Jun 2013, 01:31, edited 3 times in total.
Ricky1252
Contributor
Contributor
 
Posts: 12
Joined: 18 Mar 2013, 01:13
Has thanked: 6 times
Been thanked: 8 times

Re: [Guide]Adding SSA/ASS Subtitles

Unread postby Ricky1252 » 22 May 2013, 15:35

Working on another project, I just noticed that %t should be equivalent to %f, however for some odd reason iv ran into errors occasionally when using %t months ago when I started using this. Never with the added %f have a ran into the same errors.. Perhaps Ill find the answer in the future.
Ricky1252
Contributor
Contributor
 
Posts: 12
Joined: 18 Mar 2013, 01:13
Has thanked: 6 times
Been thanked: 8 times

Re: [Guide]Adding SSA/ASS Subtitles

Unread postby nikku » 29 May 2013, 20:07

Thank you for posting this, been waiting forever to see this happen. Gonna try it out as soon as I get home.
Thanks again!
nikku
 
Posts: 2
Joined: 13 Mar 2013, 19:31
Has thanked: 1 time
Been thanked: 0 time

Re: [Guide]Adding SSA/ASS Subtitles

Unread postby nikku » 24 Jun 2013, 20:31

Hey There,
I'm trying to get this to work with iSub on an iPhone, any ideas on what the http live streaming command would be? tried playing around with strings supplied in the guide, but haven't been able to get any of them working. Using HTML5.
Thanks for any info you can provide, and for this guide!
nikku
 
Posts: 2
Joined: 13 Mar 2013, 19:31
Has thanked: 1 time
Been thanked: 0 time

Re: [Guide]Adding SSA/ASS Subtitles

Unread postby Ricky1252 » 03 Jul 2013, 01:05

I don't have an Iphone, and i'm not sure what Isub's is, googled it and it looks like its only for music streaming? This guide focused was for video media. I tested the HTML5 transcode provided and they worked for me. Can you tell me a little bit more about the issue or what fixes you tried so I know what i'm looking at. I'v been vary busy with work and such and haven't had the time to check the forums much so ill try and keep an eye out. =]

also, make sure you are providing the subtitle file, without the subtitle file you wont generate the subtitles.
Ricky1252
Contributor
Contributor
 
Posts: 12
Joined: 18 Mar 2013, 01:13
Has thanked: 6 times
Been thanked: 8 times

Re: [Guide]Adding SSA/ASS Subtitles

Unread postby newyear2016happy » 02 Mar 2016, 10:16

To hardcode .ass, .srt, .sub to video, you may try iDealshar VideoGo to add any subtitles to AVI, MKV, MP4, MOV, WMV, etc
newyear2016happy
 
Posts: 1
Joined: 02 Mar 2016, 10:13
Has thanked: 0 time
Been thanked: 0 time


Return to Info

Who is online

Users browsing this forum: No registered users and 1 guest

cron