2 ["type"] = "EditorAction",
3 name = "Export markers as mp4chaps",
4 author = "Johannes Mueller",
6 Exports MP4chaps of all markers except xruns. The markers are stored in the
7 export directory of the session in mp4 chapter marks format. The filename
10 Note that there's always a chapter mark "Intro" at 00:00:00.000 as some
11 players can't live without it. If there are no exportable markers, the file
14 This is a bit more convenient than the export option, as one does not
15 have to wait for the export.
20 function factory (unused_params) return function ()
22 fr = Session:frame_rate()
25 for l in Session:locations():list():iter() do
27 if not l:is_mark() or string.find(name, "^xrun%d*$") then
31 h = math.floor(t / (3600*fr))
33 m = math.floor(r / (60*fr))
35 s = math.floor(r / fr)
37 ms = math.floor(r*1000/fr)
38 table.insert(chaps, string.format("%02d:%02d:%02d.%03d %s\n", h, m, s, ms, name))
42 if next(chaps) == nil then
45 table.insert(chaps, "00:00:00.000 Intro\n")
48 file = io.open(ARDOUR.LuaAPI.build_filename (Session:path(), "export", "mp4chaps.txt"), "w")
49 for i, line in ipairs(chaps) do
57 function icon (params) return function (ctx, width, height, fg)
58 local mh = height - 3.5;
62 ctx:set_line_width (.5)
63 ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
65 ctx:move_to (width / 2 - m6, 2)
66 ctx:rel_line_to (m3, 0)
67 ctx:rel_line_to (0, mh * 0.4)
68 ctx:rel_line_to (-m6, mh * 0.6)
69 ctx:rel_line_to (-m6, -mh * 0.6)
73 local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .5) .. "px")
75 local tw, th = txt:get_pixel_size ()
76 ctx:move_to (.5 * (width - tw), .5 * (height - th))
77 txt:show_in_cairo_context (ctx)