I had another try with a different video, I'm trying using ffmpeg to do the 1-bit video dither directly since this feels like a neater method. And I'm cropping to a more era-appropriate-feeling 4x3 aspect ratio. Also: there's optional subtitles now! https://zine.kawaiiuguu.moe/videotest2.html
That's really slick!
I have a few thoughts on handling subtitles. In your script, you use an if-elseif chain to assign the values to your subtitle field:
This totally works, and is perhaps the most straightforward approach possible! One alternative Lil offers is to take advantage of the fact that conditionals are expressions to cut down on repetition, like so:
If none of the elseif clauses match, the implicit "else" will evaluate to the number 0. The "unless" operator returns its left hand side "unless" its right hand side is not 0, which lets us keep the field value the same unless there's a new caption available.
Another alternative would be to build a dictionary of captions keyed by their trigger frame and index into it:
Of course, what might be even better than defining a dictionary in a bunch of code could be to store it in a grid! By converting the caption dictionary into a CSV representation (including a header row naming our columns "f" and "c" respectively):
f,c 0, 46,"Hi, trying another" 72,"Decker video experiment." 117,"So, if all goes well," 140,"this should be much better" 167,"video quality than the last time" 221,"and we should have subtitles!" 278,
We can make a grid widget called "subs" with column formats "is" to indicate we have an Integer column (i) followed by a String column (s):
And then build our dictionary by gluing together the "f" and "c" columns of that table using the "dict" operator:
Or, being slightly more verbose, we could even phrase that as a query if we wanted:
The grid widget storing this metadata can be made invisible or tucked away on a different card if desired.
All of these approaches have their merits, of course. The best script is the one that makes you happiest!