Tips for `ass’¶
- doc
https://ffmpeg.org/ffmpeg-filters.html#subtitles-1, https://ffmpeg.org/ffmpeg-filters.html#ass, https://en.wikipedia.org/wiki/SubStation_Alpha, http://moodub.free.fr/video/ass-specs.doc
General¶
Don’t expect too much to it.¶
Certainly it can do more than “SubRip”, but what can be done by explaining the specifications is quite limited, moreover, IMO, the implementation of the built-in ass engine in ffmpeg is incomplete.
For portability, give up.¶
Some media players such as “VLC media player” can read this and overlay it, but the ffmpeg’s ass engine and those players’ engines are different, and the compatibility seems to be quite incomplete.
For example, “Media Player Classic” rejects “ass” handled with ffmpeg without problems. For example, using “Drawing commands” described in the specification, results are quite different from those of ffmpeg and those of “Media Player Classic”. (It is probably ffmpeg that does not behave as described in the specification.)
Because using “ass” in ffmpeg is to embed as an image, if you do not intend to distribute the “ass file” alone, don’t think deeply about this fact, in other words, don’t think about distributing the “ass file” created for ffmpeg.
Features that don’t work I found¶
I think the followings don’t work.
I can not deny the possibility that I misunderstood because the explanation of the specification is unclear. However, for all listed here, it is a conclusion that has been drawn after at least one hour of trial and error.
`Synch Point’ in [Script Info] section¶
According to the explanation, I think it is the following usage:
[Script Info]
PlayResX: 1280
PlayResY: 720
Synch Point: 0:00:05.00
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, Alignment, Encoding
Style: Expl, Arial,60,&HFFB0B0,5,0
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,00:00:00.00,00:00:25.00,Expl,{\pos(640,640)}Start is 00:00:00, "Synch Point" is 00:00:05.
#! /bin/sh
pref="`basename $0 .sh`"
pygmentize -g -o ${pref}.png -O "hl_lines=4 12,line_numbers=False" ${pref}.ass
#
ffmpeg -y -i ${pref}.png -filter_complex "
color=black:s=1280x720:d=30[bg];
[0:v]scale=1024:-1,pad='1280:720:abs(iw-ow)/2:abs(ih-oh)/2',loop=-1:size=2[fg];
[bg][fg]overlay=shortest=1
,drawtext='fontsize=80:fontcolor=white:x=340:y=50:text=%{pts\:hms}'
,subtitles=${pref}.ass
" ${pref}.mp4
However, “Synch Point” seems to have no effect at all.
All events except but Dialogue seems not to be implemented¶
As far as I read an explanation that is extremely difficult to read, perhaps the usage of the “Picture” event looks like this:
[Script Info]
PlayResX: 1280
PlayResY: 720
WrapStyle: 1
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, OutlineColour, BackColour, BorderStyle, Outline, Shadow, Alignment, Encoding
Style: Expl, Arial,44,&H00FFB0B0,&H00CC7070,&H00333333,1,1,1,7,0
[Graphics]
filename: energymass.jpg
M_]C_X 02D9)1@ ! @ 0 ! #__@ 03&%V8S4W+C@Y+C$P, #_VP!# @&M!@<&!P@(" @(" D)"0
H*"@D)"0D*"@H*"@H,# P*"@H*"@H*# P,# T.#0T-M# T.#@\/#Q(2$1$5%149&1__Q &B !!0$!
0$! 0 0(#! 4&M!P@)"@L! ,! 0$! 0$! 0$ ! @,$!08'" D*"Q @$# P($
P4%M! 0 %] 0(# 01!1(A,4$&$U%A!R)Q%#*!D:$((T*QP152T? D,V)R@@D*M%A<8&1HE)B<H*2
HT-38W.#DZ0T1%1D=(24I35%565UA96F-D969G:&EJ<W1UM=G=X>7J#A(6&AXB)BI*3E)66EYB9FJ*CI
*6FIZBIJK*SM+6VM[BYNL+#Q,7&MQ\C)RM+3U-76U]C9VN'BX^3EYN?HZ>KQ\O/T]?;W^/GZ$0 " 0($
! ,$!P4$M! ! G< 0(#$00%(3$&$D%1!V%Q$R(R@0@40I&AL<$)(S-2\!5B<M$*%B0TMX27Q%Q@9&B
8G*"DJ-38W.#DZ0T1%1D=(24I35%565UA96F-D969G:&EJ<W1UM=G=X>7J"@X2%AH>(B8J2DY25EI>8F
9JBHZ2EIJ>HJ:JRL[2UMK>XN;K"P\3%MQL?(R<K2T]35UM?8V=KBX^3EYN?HZ>KR\_3U]O?X^?K_P 1
" + "D# 1( M A( Q( _]H # ,! (1 Q$ /P#V/2?%^AZ[<_9M/NI+ABES)'*+2]2UN([.M=+>XDM
+V2!+.Z2*:1$9K>60?,".*\?\ A#,UC\1?$VA6PC@TW3TUB."WBBC1MBL.LP)";F<*+B[>%&=(7NY)GB
1W5" QR 'L$_C/PM:S2P3^(=#AFA=HY8I=M3LDDCD1BKQR(TP975@0RL 01@T3^$].N9I9GN-<#2NTC
"+Q%X@AC#.Q8B.&'M44BC3)^5(U5%'"@"@ DO?%6A:?HSZ[+J%N^E1[<WML3=PG=.+<;#:"8O^^/MEG
8#M.<XP:S_ !;9Q:?X'\16T37#I'H>K8:YNKF[F.ZTG8[[B[EFN'Y/&]SMM&%& * M?B%X<O'@2*;
4#]H^Q&)WT76XH2NI3>392&>6P2%(KJ7Y(97=8WM(.&X->0?%NRM]'T_6;W3T^PW$?C'0[>*2U9X?)AT
_P )Q26B0+&52'[.\\ACM,2JPR.<*N [_QW?Z=XNTZ?2--TJXU[5K:>YFL8)H9;*SBO-.E:RFO3<:B
EMOIU]%8SS>7+;*URDSLJ/'L+,O)_"?5;Z'QYKOAB.XD71-%378]/L 1Y<"_VWL!@L^/-G=0S!'N'D=
S!2 QR 'FG_"DOB'_T O\ RHZ3_P#)M?7] !__]D
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,00:00:00.00,00:30:00.00,Expl,{\pos(10,10)}Is this correct?
Picture: 0,00:00:00.00,00:30:00.00,Expl,energymass.jpg
However, my trial and error have not been successful. It has not been implemented at this time (4.2dev), I think.
How-to¶
How can I use superscripts and subscripts?¶
See “Is there a way to render math only with ffmpeg?”. The story is probably the same for “ruby”, which expresses Kanji reading.
How to get a `blink’ effect?¶
There is no direct function for `blink’ in “Advanced SubStation Alpha (v4.00+)”. So, of course, a most straight-forward way is “repeating ‘Dialogue’ simply”:
[Script Info]
PlayResX: 1280
PlayResY: 720
WrapStyle: 1
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, BackColour, Alignment, Encoding
Style: Expl, Arial,44,&H00FFB0B0,&H00000000,7,0
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,00:00:00.00,00:00:00.50,Expl,{\pos(100,100)}BLINK
Dialogue: 0,00:00:01.00,00:00:01.50,Expl,{\pos(100,100)}BLINK
Dialogue: 0,00:00:02.00,00:00:02.50,Expl,{\pos(100,100)}BLINK
Dialogue: 0,00:00:03.00,00:00:03.50,Expl,{\pos(100,100)}BLINK
If you use the function \t
, you won’t have to repeat “Dialogue”, but that’s so ugly:
[Script Info]
PlayResX: 1280
PlayResY: 720
WrapStyle: 1
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, BackColour, Alignment, Encoding
Style: Expl, Arial,44,&H00FFB0B0,&H00000000,7,0
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,00:00:00.00,00:00:30.00,Expl,{\pos(100,100)}{\t(0,500,\c&H00000000&)}{\t(500,1000,\c&H00FFB0B0&)}{\t(1000,1500,\c&H00000000&)}{\t(1500,2000,\c&H00FFB0B0&)}{\t(2000,2500,\c&H00000000&)}{\t(2500,3000,\c&H00FFB0B0&)}{\t(3000,3500,\c&H00000000&)}{\t(3500,4000,\c&H00FFB0B0&)}{\t(4000,4500,\c&H00000000&)}{\t(4500,5000,\c&H00FFB0B0&)}{\t(5000,5500,\c&H00000000&)}{\t(5500,6000,\c&H00FFB0B0&)}{\t(6000,6500,\c&H00000000&)}{\t(6500,7000,\c&H00FFB0B0&)}{\t(7000,7500,\c&H00000000&)}{\t(7500,8000,\c&H00FFB0B0&)}{\t(8000,8500,\c&H00000000&)}{\t(8500,9000,\c&H00FFB0B0&)}{\t(9000,9500,\c&H00000000&)}{\t(9500,10000,\c&H00FFB0B0&)}{\t(10000,10500,\c&H00000000&)}{\t(10500,11000,\c&H00FFB0B0&)}{\t(11000,11500,\c&H00000000&)}{\t(11500,12000,\c&H00FFB0B0&)}{\t(12000,12500,\c&H00000000&)}{\t(12500,13000,\c&H00FFB0B0&)}{\t(13000,13500,\c&H00000000&)}{\t(13500,14000,\c&H00FFB0B0&)}{\t(14000,14500,\c&H00000000&)}{\t(14500,15000,\c&H00FFB0B0&)}{\t(15000,15500,\c&H00000000&)}{\t(15500,16000,\c&H00FFB0B0&)}{\t(16000,16500,\c&H00000000&)}{\t(16500,17000,\c&H00FFB0B0&)}{\t(17000,17500,\c&H00000000&)}{\t(17500,18000,\c&H00FFB0B0&)}{\t(18000,18500,\c&H00000000&)}{\t(18500,19000,\c&H00FFB0B0&)}{\t(19000,19500,\c&H00000000&)}{\t(19500,20000,\c&H00FFB0B0&)}{\t(20000,20500,\c&H00000000&)}{\t(20500,21000,\c&H00FFB0B0&)}{\t(21000,21500,\c&H00000000&)}{\t(21500,22000,\c&H00FFB0B0&)}{\t(22000,22500,\c&H00000000&)}{\t(22500,23000,\c&H00FFB0B0&)}{\t(23000,23500,\c&H00000000&)}{\t(23500,24000,\c&H00FFB0B0&)}{\t(24000,24500,\c&H00000000&)}{\t(24500,25000,\c&H00FFB0B0&)}{\t(25000,25500,\c&H00000000&)}{\t(25500,26000,\c&H00FFB0B0&)}{\t(26000,26500,\c&H00000000&)}{\t(26500,27000,\c&H00FFB0B0&)}{\t(27000,27500,\c&H00000000&)}{\t(27500,28000,\c&H00FFB0B0&)}{\t(28000,28500,\c&H00000000&)}{\t(28500,29000,\c&H00FFB0B0&)}{\t(29000,29500,\c&H00000000&)}{\t(29500,30000,\c&H00FFB0B0&)}BLINK
If you really want to do this, you should rely on other high-level languages such as Python:
#! /bin/bash
pref="`basename $0 .sh`"
#
function repeat_t_c() {
python -c '
print(
"".join([r"{\t(%d,%d,%s)}" % (
i * 500, (i + 1) * 500,
r"\c&H000000&" if i % 2 == 0 else r"\c&HFFB0B0&")
for i in range(0, '$1')]))'
}
#
cat <<__END__> ${pref}.ass
[Script Info]
PlayResX: 1280
PlayResY: 720
WrapStyle: 1
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, Alignment, Encoding
Style: Expl, Arial,44,&HFFB0B0,7,0
[Events]
Format: Layer, Start, End, Style, Text
Dialogue: 0,00:00:00.00,00:00:30.00,Expl,{\pos(100,100)}`repeat_t_c 60`BLINK
__END__
#
ffmpeg -y -filter_complex "
color=black:s=1280x720:d=30,ass=${pref}.ass
" ${pref}.mp4
There is also a way to achieve outside the scope of “ass”. I wrote `blink video’ example as “swapping two videos sequentially”. If it is applied, blink can be realized.
Citating programming code snippet¶
See Showing the source code of programming launguage as video.