summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2016-09-08 22:34:39 +0200
committerRobin Gareus <robin@gareus.org>2016-09-12 12:03:16 +0200
commit9d927b54c178a90cc65eeffb01fe51ea6c3bba6a (patch)
treea5b5219a0a5df681cf729027fa41ef1c7ad8837b /scripts
parent5eaec8c82de1e9881d047b75f481b435a68200e3 (diff)
Lua script to export markers as mp4 chapters
Location markers, that are not xruns are exported as mp4 chapter marks. This requires `Location::name()` to be exposed to Lua.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/export_mp4chaps.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/export_mp4chaps.lua b/scripts/export_mp4chaps.lua
new file mode 100644
index 0000000000..b7ab23189c
--- /dev/null
+++ b/scripts/export_mp4chaps.lua
@@ -0,0 +1,55 @@
+ardour {
+ ["type"] = "EditorAction",
+ name = "Export markers as mp4chaps",
+ author = "Johannes Mueller",
+ description = [[
+Exports MP4chaps of all markers except xruns. The markers are stored in the
+export directory of the session in mp4 chapter marks format. The filename
+is mp4chaps.txt
+
+Note that there's always a chapter mark "Intro" at 00:00:00.000 as some
+players can't live without it. If there are no exportable markers, the file
+is not created.
+
+This is a bit more convenient than the export option, as one does not
+have to wait for the export.
+]],
+ license = "GPLv2"
+}
+
+function factory (unused_params) return function ()
+
+ fr = Session:frame_rate()
+ chaps = {}
+
+ for l in Session:locations():list():iter() do
+ name = l:name()
+ if not l:is_mark() or string.find(name, "^xrun%d*$") then
+ goto next end
+
+ t = l:start()
+ h = math.floor(t / (3600*fr))
+ r = t - (h*3600*fr)
+ m = math.floor(r / (60*fr))
+ r = r - m*60*fr
+ s = math.floor(r / fr)
+ r = r - s*fr
+ ms = math.floor(r*1000/fr)
+ table.insert(chaps, string.format("%02d:%02d:%02d.%03d %s\n", h, m, s, ms, name))
+ ::next::
+ end
+
+ if next(chaps) == nil then
+ goto out end
+
+ table.insert(chaps, "00:00:00.000 Intro\n")
+ table.sort(chaps)
+
+ file = io.open(string.format("%s/export/mp4chaps.txt", Session:path()), "w")
+ for i, line in ipairs(chaps) do
+ file:write(line)
+ end
+ file:close()
+
+ ::out::
+end end