Skip to content

Instantly share code, notes, and snippets.

@klaxa
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaxa/197efb68e549d01193b8 to your computer and use it in GitHub Desktop.
Save klaxa/197efb68e549d01193b8 to your computer and use it in GitHub Desktop.
Nov 10 00:06:48 <CalimeroTeknik> hello! can I tell ffmpeg to keep the attachments (mkv fonts) while encoding?
Nov 10 00:07:20 <CalimeroTeknik> no magic -keep-attachments or alike option
Nov 10 00:07:28 <CalimeroTeknik> well, afaik
Nov 10 00:11:26 * glebihan_ (~glebihan@unaffiliated/glebihan) has joined #ffmpeg
Nov 10 00:14:17 * glebihan has quit (Ping timeout: 245 seconds)
Nov 10 00:14:48 * Inkane has quit (Remote host closed the connection)
Nov 10 00:16:33 <klaxa> CalimeroTeknik: -map 0
Nov 10 00:19:28 <CalimeroTeknik> ah, thanks but it doesn't seem to work
Nov 10 00:20:06 <CalimeroTeknik> oh! it's maybe two subtitle tracks. sorry.
Nov 10 00:20:54 <klaxa> it worked for me the last time i checked
Nov 10 00:23:06 * glebihan__ (~glebihan@unaffiliated/glebihan) has joined #ffmpeg
Nov 10 00:25:01 <CalimeroTeknik> that's strange, it indeed includes the fonts but one of the two subtitles is missing
Nov 10 00:25:12 <CalimeroTeknik> (so thanks, -map 0 works)
Nov 10 00:25:39 * glebihan_ has quit (Ping timeout: 248 seconds)
Nov 10 00:28:11 <CalimeroTeknik> here's ffmpeg output: http://sprunge.us/PhBh
Nov 10 00:28:53 <klaxa> there is only one subtitle stream as far as i can see
Nov 10 00:29:34 <CalimeroTeknik> yes, indeed
Nov 10 00:30:00 <klaxa> so what exactly is missing?
Nov 10 00:30:06 <CalimeroTeknik> it contains an ass subtitle for the up of the screen (Japanese) and the bottom (English)
Nov 10 00:30:12 <CalimeroTeknik> the English is missing
Nov 10 00:30:39 <sacarasc> Which can be done in 1 subtitle file.
Nov 10 00:31:10 <klaxa> which most of the time IS done in one subtitle file... lemme see if i can reproduce
Nov 10 00:31:10 <CalimeroTeknik> absolutely
Nov 10 00:32:06 <CalimeroTeknik> do you want a ssh to test?
Nov 10 00:32:46 <klaxa> i'll download the file and see if it works on my system
Nov 10 00:33:35 <CalimeroTeknik> well, mkvmerge does a better job here
Nov 10 00:34:52 <CalimeroTeknik> however if reencoding is needed (in order to cut the video precisely, not ±5 seconds on keyframes) I need to get ffmpeg to properly dump subtitles from input to output
Nov 10 00:35:42 <CalimeroTeknik> for the moment, I wrote this script, it solves the problem : http://sprunge.us/RhGE
Nov 10 00:36:17 <klaxa> well it should start with an i-frame and whatever comes afterwards doesn't matter... so you should be able to extract the opening...
Nov 10 00:36:37 <CalimeroTeknik> with mkvmerge, yes, it worked perfectly
Nov 10 00:36:53 <CalimeroTeknik> with ffmpeg as my paste describes, the second subtitle disappears
Nov 10 00:37:04 <CalimeroTeknik> well... the bottom subtitle line I mean
Nov 10 00:37:22 <klaxa> maybe they are defined later in the script and ffmpeg thinks it got all the subs?
Nov 10 00:37:28 <klaxa> which would be rather weird
Nov 10 00:38:51 <CalimeroTeknik> well, yes
Nov 10 00:42:10 * teamcolt_ (~teamcoltr@cpe-74-77-33-38.buffalo.res.rr.com) has joined #ffmpeg
Nov 10 00:42:24 * teamcoltra|mba has quit (Read error: Connection reset by peer)
Nov 10 00:42:47 * teamcolt_ has quit (Read error: Connection reset by peer)
Nov 10 00:43:17 * teamcoltra|mba (~teamcoltr@cpe-74-77-33-38.buffalo.res.rr.com) has joined #ffmpeg
Nov 10 00:44:23 * drftklm (~Multbrelc@16.197.88.79.rev.sfr.net) has joined #ffmpeg
Nov 10 00:47:37 * Multbrelch has quit (Ping timeout: 260 seconds)
Nov 10 00:48:33 * kriegerod (~krieger@37.203.2.152) has joined #ffmpeg
Nov 10 00:48:41 * drftklm has quit (Client Quit)
Nov 10 00:48:54 <klaxa> (btw CalimeroTeknik: sora no woto any good? would you recommend it?)
Nov 10 00:50:42 * Multbrelch (~Multbrelc@16.197.88.79.rev.sfr.net) has joined #ffmpeg
Nov 10 00:52:55 * Trax- has quit (Read error: Connection reset by peer)
Nov 10 00:53:40 <klaxa> CalimeroTeknik: i can reproduce that behavior
Nov 10 00:54:28 <CalimeroTeknik> it's soft, but entertaining
Nov 10 00:57:58 <CalimeroTeknik> dumping the subtitles doesn't produce the same result as from the file produced by mkvmerge!
Nov 10 00:58:25 <CalimeroTeknik> the order is slightly modified
Nov 10 00:58:32 <CalimeroTeknik> that's all, apparently.
Nov 10 00:58:41 <klaxa> hmm... i blame the demuxer of libav?
Nov 10 00:59:03 <klaxa> if you extract the subs from the encoded file and use the .ass file directly it gets rendered properly
Nov 10 00:59:25 <klaxa> if you use the embedded subtitles it doesn't work
Nov 10 00:59:32 <CalimeroTeknik> http://sprunge.us/BVhM
Nov 10 00:59:33 <klaxa> how did you extract it with mkvmerge?
Nov 10 01:00:08 <klaxa> timecodes are the same, it shouldn't make any difference :|{[
Nov 10 01:00:10 <CalimeroTeknik> mkvmerge \[Chihiro\]_Sora_no_Woto_-_07.5_\[1280x720_Blu-Ray_FLAC\]\[0F27FE1F\].mkv --split parts:00:00:00.000-00:01:30.000 -o op.mkv
Nov 10 01:01:21 <CalimeroTeknik> this one produces visible subtitles
Nov 10 01:02:14 * zimbatm has quit (Remote host closed the connection)
Nov 10 01:04:01 * jdjrjc (~dkaivcd@pool-71-185-46-229.phlapa.fios.verizon.net) has joined #ffmpeg
Nov 10 01:04:07 <klaxa> there must be something else...
Nov 10 01:04:22 <CalimeroTeknik> yes, but I won't diff the mkv files.
Nov 10 01:04:22 <klaxa> i guess a bugreport isn't too bad of an idea anyways
Nov 10 01:04:37 <CalimeroTeknik> is the matter investigated enough?
Nov 10 01:04:47 <CalimeroTeknik> we still don't know what's going wrong
Nov 10 01:04:48 <klaxa> i tried, forget it, the matroska tools and ffmpeg write pretty different headers and metadata
Nov 10 01:06:35 <klaxa> mkvextract also writes 3 frames less
[...]
Nov 10 01:10:43 <klaxa> currently dumping the interleaved subtitles as hex
Nov 10 01:11:15 <klaxa> those should be more or less identical apart from the switch of one line
Nov 10 01:11:45 * glebihan_ (~glebihan@unaffiliated/glebihan) has joined #ffmpeg
Nov 10 01:12:25 <klaxa> oh... they differ by a byte every here and there
Nov 10 01:12:46 * juanmabc (~juanmabc@79.109.192.240.dyn.user.ono.com) has joined #ffmpeg
Nov 10 01:14:20 <CalimeroTeknik> is that LF/CRLF line jumps that were converted to LF when extracting with mkvextract tracks file.mkv 2:blah.ass ?
Nov 10 01:15:00 * glebihan__ has quit (Ping timeout: 265 seconds)
Nov 10 01:17:07 <klaxa> i don't even know... but it seems like ffmpeg doesn't mux the .ass correctly for some reason
Nov 10 01:17:29 <klaxa> if i use the .ass i get with mkvmerge and mux it with ffmpeg it doesn't work
Nov 10 01:17:34 <klaxa> neither does simply remuxing help
Nov 10 01:18:22 * Multbrelch has quit (Quit: Leaving)
Nov 10 01:19:50 <klaxa> the event gets called
Nov 10 01:19:51 <klaxa> [ass] Text = {\fad(300,300)}kono sora no kagayaki kimi no mune ni todoiteru
Nov 10 01:19:51 <klaxa> [ass] Event at 3550, +9780: 0,0,OPE,,0000,0000,0000,,{\fad(300,300)}The luminance of the sky has reached your heart.
Nov 10 01:19:53 <klaxa> but not rendered
Nov 10 01:20:18 * glebihan__ (~glebihan@unaffiliated/glebihan) has joined #ffmpeg
Nov 10 01:21:41 <CalimeroTeknik> in the player?
Nov 10 01:23:10 <klaxa> yeah with mplayer
Nov 10 01:23:28 <klaxa> the event gets triggered... producing mplayer2 debug messages for .ass right now for both files
Nov 10 01:23:33 * glebihan_ has quit (Ping timeout: 260 seconds)
Nov 10 01:23:45 * kent1 has quit (Quit: Leaving.)
Nov 10 01:24:49 <CalimeroTeknik> oh I didn't test vlc
Nov 10 01:25:20 <CalimeroTeknik> same result.
Nov 10 01:25:29 <klaxa> yeah but... >vlc
Nov 10 01:25:36 <klaxa> you know how it goes
Nov 10 01:26:22 <CalimeroTeknik> anyway it calls libass just as mplayer I guess
Nov 10 01:26:49 <wm4> yes VLC uses libass now
Nov 10 01:30:00 <klaxa> CalimeroTeknik: http://diffchecker.com/lTd7wIjl
Nov 10 01:30:21 <klaxa> that's the debug output of mplayer2 grep'd for ass
Nov 10 01:31:14 <klaxa> so apart from the swapped lines it's identical
Nov 10 01:31:20 * glebihan__ has quit (Ping timeout: 268 seconds)
Nov 10 01:31:39 <CalimeroTeknik> okashii ne~
Nov 10 01:33:18 <CalimeroTeknik> "[0x1827cb0]" changes, is that an address in the file?
Nov 10 01:33:25 <klaxa> i guess so
Nov 10 01:33:43 * FunnyLookinHat has quit (Quit: Leaving)
Nov 10 01:33:50 <@ubitux> it's a pointer
Nov 10 01:33:55 <@ubitux> of the context printer
Nov 10 01:34:11 <@ubitux> i guess.
Nov 10 01:34:23 <klaxa> the funny thing is, if you use the .ass you get when you extract it with ffmpeg it works, if you use the .ass you get from mkvmerge it works
Nov 10 01:34:35 <klaxa> the only thing that doesn't work is the embedded file
Nov 10 01:34:44 * glebihan__ (~glebihan@unaffiliated/glebihan) has joined #ffmpeg
Nov 10 01:35:04 <CalimeroTeknik> right, the data doesn't get destroyed
Nov 10 01:35:12 <@ubitux> i'm too lazy to backlog, is there a bug with ffmpeg?
Nov 10 01:35:23 <klaxa> probably
Nov 10 01:35:41 <klaxa> well it's kinda bound to ffmpeg... the situation is as follows:
Nov 10 01:36:02 <CalimeroTeknik> it's muxing subtitles in a way that if two of them appear at the same time, only one is displayed
Nov 10 01:36:12 <CalimeroTeknik> something like that is what I saw
Nov 10 01:36:21 <klaxa> matroska file with ass subtitles, multiple lines at a time, with the -t option of ffmpeg only one line appears if you use the embeeded subtitles, if you extract them it works
Nov 10 01:36:48 <CalimeroTeknik> oh, without -t it doesn't break anything?
Nov 10 01:37:02 <klaxa> i'm not sure lemme test
Nov 10 01:37:29 <@ubitux> i guess i'll have to backlog, but it's late, too bad
Nov 10 01:37:51 * thaman has quit (Remote host closed the connection)
Nov 10 01:37:52 <klaxa> nah doesn't work without -t either
Nov 10 01:37:53 <@ubitux> please open an issue on the trac if you think there is a problem with ffmpeg
Nov 10 01:38:01 <@ubitux> and feel free to hilight me with the bug id
Nov 10 01:38:29 <@ubitux> don't forget to describe a simple way of reproducing the issue
Nov 10 01:38:32 <CalimeroTeknik> basically using ffmpeg as cp doesn't work :p
Nov 10 01:39:15 <CalimeroTeknik> ubitux, try to use ffmpeg as if it were cp, on the file [Chihiro]_Sora_no_Woto_-_07.5_[1280x720_Blu-Ray_FLAC][0F27FE1F].mkv
Nov 10 01:39:18 <CalimeroTeknik> that's enough.
Nov 10 01:39:39 <klaxa> well you describe the problem and file a bugreport with the description :P
Nov 10 01:40:31 <@ubitux> i don't have 07.5
Nov 10 01:40:38 <@ubitux> only 01-12 without half subs
Nov 10 01:40:38 <@ubitux> :p
Nov 10 01:40:40 <klaxa> stay in this channel, if you don't think you can write it up i can assist you tomorrow... because i'm tired...
Nov 10 01:40:42 <@ubitux> s/subs/eps/
Nov 10 01:40:55 <klaxa> ubitux: it's well seeded at bakabt :P
Nov 10 01:41:03 <@ubitux> i don't want to watch this
Nov 10 01:41:10 <@ubitux> :)
Nov 10 01:41:17 <@ubitux> the anime was so-so
Nov 10 01:41:29 <@ubitux> just provide a simple .ass and a way to reproduce
Nov 10 01:41:29 <klaxa> yeah we'll see if we can reproduce it with some generated files
Nov 10 01:41:32 <@ubitux> and i'll have a look
Nov 10 01:43:34 <klaxa> maybe the subgroup did some stuff which differs from the specs for ass and ffmpeg tries to correct that
Nov 10 01:43:56 <klaxa> and thus everything fails... well i'll try to reproduce it tomorrow
Nov 10 01:45:19 <CalimeroTeknik> ah, for the bug report… yes, we need a small download to reproduce the problem
Nov 10 01:45:31 <CalimeroTeknik> which the file I'm using isn't exactly :p
Nov 10 01:45:42 <@ubitux> what do you need to do?
Nov 10 01:46:02 <@ubitux> you need to provide a video or a .ass to reproduce?
Nov 10 01:46:18 <klaxa> well... get a dummy video file, which contains an .ass that doesn't work propery
Nov 10 01:46:25 * Haikarainen has quit (Ping timeout: 265 seconds)
Nov 10 01:46:42 <@ubitux> hint: ffmpeg -f lavfi -i testsrc -t 5 out.mkv generates a 5 seconds mkv
Nov 10 01:47:02 <CalimeroTeknik> okay
Nov 10 01:47:08 <klaxa> if you extract the ass from the mkv it works
Nov 10 01:47:14 <klaxa> but not from within the container
Nov 10 01:47:18 <klaxa> that's the weirdest thing
Nov 10 01:47:25 <@ubitux> ?/
Nov 10 01:47:36 <@ubitux> from the mkv but not from within the container?
Nov 10 01:47:40 <@ubitux> what does that mean?
Nov 10 01:48:00 <klaxa> i mean that if the ass is embedded in the mkv and you try to play it, it fails to render the second line of subtitles
Nov 10 01:48:00 <CalimeroTeknik> that means, after extracting the ass file from the mkv it can be used separately
Nov 10 01:48:20 <CalimeroTeknik> but muxed *by ffmpeg* into an mkv, it's not rendered properly
Nov 10 01:48:46 <@ubitux> ah, ok, so you just need to provide a .ass with duplicated events at the same time
Nov 10 01:48:54 <CalimeroTeknik> I think
Nov 10 01:48:56 <@ubitux> if the .ass is muxed with mkvmerge both subs shows
Nov 10 01:49:05 <@ubitux> and if muxed with ffmpeg, none?
Nov 10 01:49:09 <CalimeroTeknik> only one.
Nov 10 01:49:14 <CalimeroTeknik> and always the same one
Nov 10 01:49:24 <CalimeroTeknik> well, relative to its position on screen
Nov 10 01:49:26 <@ubitux> can you provide a .ass?
Nov 10 01:49:59 <CalimeroTeknik> http://sprunge.us/LgJI I think
Nov 10 01:50:39 <@ubitux> thx
Nov 10 01:53:35 * stephanedev has quit (Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/)
Nov 10 01:53:38 <@ubitux> works for me
Nov 10 01:55:35 <klaxa> hmm... maybe... ugh i kinda already thought it will be hard to reproduce with a different file
Nov 10 01:55:49 * TheSandmann has quit (Quit: Verlassend)
Nov 10 01:55:51 <@ubitux> ./ffmpeg -f lavfi -i testsrc=s=1280x720 -i in.ass -preset:v ultrafast -map 0 -map 1 -c:s copy -t 90 -y test.mkv
Nov 10 01:56:00 <@ubitux> without -c:s copy as well
Nov 10 01:56:03 <klaxa> maybe it's even dependent on the attachments...
Nov 10 01:56:13 <@ubitux> test.mkv displays 2 subtitles at the same time
Nov 10 01:56:24 <klaxa> yeah just tried myself too, same result here
Nov 10 01:57:46 <CalimeroTeknik> well, x264 fails to reencode this video!
Nov 10 01:58:16 <CalimeroTeknik> there must be something broken about it
Nov 10 01:58:32 <@ubitux> ok then i'm going to bed
Nov 10 01:58:36 <klaxa> i'll head to bed as well
Nov 10 01:58:42 <@ubitux> i'll wait for you to be able to describe the bug :p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment