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>
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]
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
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 -
Step 1
Code: Select all
ffmpeg -i transcode\clean.ass -n transcode\sub\%f.ass
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 -
Step 1
Code: Select all
ffmpeg -i /var/subsonic/transcode/clean.ass -n /var/subsonic/transcode/sub/%f.ass
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 -
Step 1
Code: Select all
ffmpeg -i /var/subsonic/transcode/clean.ass -n /var/subsonic/transcode/sub/%f.ass
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 -
Extracting SSA/ASS files
from a container... example...
abc.mkv
Code: Select all
ffmpeg -i abc.mkv abc.ass
Code: Select all
ffmpeg -i abc.mkv
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
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
# 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
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
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