Last active
December 12, 2017 14:49
-
-
Save avih/60ea4a20b98b9fb43eae018c1b34fab1 to your computer and use it in GitHub Desktop.
Revisions
-
avih revised this gist
Dec 12, 2017 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,12 @@ played normally. mpv should be invoked as: `mpv --script=path/to/autoloop.js --idle` The info file should consist of lines where each line is: <length> <clip-path> E.g. 0 path/to/clip.mp4 5 path/to/some/image.jpg 0 /another/clip.mkv Sets image-display-duration to length and plays the clip. Images would be affected by the length value while other clips will not. -
avih revised this gist
Dec 12, 2017 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ /*********************************************************************** autoloop.js - mpv script which reads and play a custom playlist file in a loop. Images are displayed for a specified duration and other clips are played normally. mpv should be invoked as: `mpv --script=path/to/autoloop.js --idle` The info file should consist of lines where each line is: [length] [clip-path] -
avih created this gist
Dec 12, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ /*********************************************************************** autoloop.js - read and play a custom playlist file format where images are displayed for a specified duration and other clips are played normally. The info file should consist of lines where each line is: [length] [clip-path] Sets image-display-duration to length and plays the clip. Images would be affected by the length value while other clips will not. After the last line was processed, start again with the first line. Note: For simplicity, there should be no empty lines, exactly one space between length and clip-path, and no extra spaces before or after (but spaces as part of clip-path are premitted). ***********************************************************************/ var data = mp.utils.read_file("~/autoloop.info"); data = data.split("\r\n").join("\n").split("\n"); var i = 0; function start_item(length, clip) { mp.set_property("image-display-duration", length); mp.commandv("loadfile", clip, "replace"); } function play_next_item() { var space = data[i].indexOf(" "), length = Number(data[i].substring(0, space)), clip = data[i].substring(space + 1); print("next_item: '" + length + "', '" + clip + "'"); start_item(length, clip); i = (i + 1) % data.length; } mp.register_event("end-file", play_next_item); play_next_item();