vhs icon indicating copy to clipboard operation
vhs copied to clipboard

feat:get timestamp for each command with flag --with-timestamp or -t

Open Exar04 opened this issue 10 months ago • 14 comments

Adds feature #584

Screenshot 2025-04-20 at 12 46 53 PM

Exar04 avatar Apr 20 '25 07:04 Exar04

Hey @Exar04 thank you for the PR, it's indeed a nice feature to add. Two things though, could you add tests about this functionality? and second would be nice --timestamp if it actually receive an unix POSIX for retrieve timestamp like '%d/%m/%Y_%H:%M:%S:%N' would return 20/04/2025_11:47:43:32. It would allow people configure their timestamp in the way they would want to.

raphamorim avatar Apr 20 '25 09:04 raphamorim

One issue with this is that there isn't a separate timecode for each typed letter. One use case for the timecode is being able to add audio and this wouldn't be enough to add audio to each keystroke.

Soviut avatar Apr 21 '25 05:04 Soviut

I see @Soviut seems hard to implement but I will give it a try.

@raphamorim yeah I will add tests at the end, after the complete feature is implemented.

Exar04 avatar Apr 21 '25 08:04 Exar04

Perfect, please lemme know if need help with anything. Feel free to ping on my discord

raphamorim avatar Apr 21 '25 09:04 raphamorim

I see @Soviut seems hard to implement but I will give it a try.

@raphamorim yeah I will add tests at the end, after the complete feature is implemented.

You could infer the current typing speed which is how frequently the Type command types a character. Then multiply that by the number of characters.

https://github.com/charmbracelet/vhs?tab=readme-ov-file#set-typing-speed

The TypingSpeed changes the speed globally. While, you can also change the speed of a single Type command.

To handle timecodes with milliseconds it's usually HH:MM:SS,mmm. There's also HH:MM:SS:FF that will capture the current frame, assuming we know the framerate.

image

Soviut avatar Apr 21 '25 17:04 Soviut

Screenshot 2025-04-22 at 1 04 03 PM Does something like this works for you @Soviut ?

Also what should be the names for the the tags @Soviut @raphamorim

Exar04 avatar Apr 22 '25 07:04 Exar04

20/04/2025_11:47:43:32

I mean its just a stopwatch. should it have dates and stuff?

Exar04 avatar Apr 22 '25 07:04 Exar04

Hey @Exar04 timestamp term isn't just about dates when comes to unix, but sure just allow formating time (hour, minute, second, millisecond) would be ok imho

raphamorim avatar Apr 22 '25 07:04 raphamorim

Does something like this works for you @Soviut ?

That's definitely more useful.

I think the : should be changed to something that does not appear in the timecode. Perhaps | or >

Also what should be the names for the the tags @Soviut @raphamorim

Do you mean the flags in the CLI? I would go with:

--timing=timecode
--timing=timestamp

Where timecode produces 00:00:00.000 and timestamp produces milliseconds since the epoch.

Soviut avatar Apr 22 '25 18:04 Soviut

@Exar04 Here's a really good resource about timecode.

https://editingtools.io/timecode/

Soviut avatar Apr 22 '25 18:04 Soviut

Screenshot 2025-04-23 at 9 05 28 PM Hey sorry, but I think I have not implemented the feature correctly. Theres a inconsistency in timecodes. I will have to take a deeper look into it later. Sry this might take longer for me to implement it

Exar04 avatar Apr 23 '25 15:04 Exar04

No stress/rush @Exar04 please take your time

raphamorim avatar Apr 23 '25 16:04 raphamorim

Just a thought here: making the timecodes compatible with the FFmpeg metadata format (https://ffmpeg.org/ffmpeg-formats.html#Metadata-2) would allow for relatively easy tagging of videos with chapter markers (http://ikyle.me/blog/2020/add-mp4-chapters-ffmpeg or https://medium.com/@dathanbennett/adding-chapters-to-an-mp4-file-using-ffmpeg-5e43df269687 for details).

In fact, imagine -t=chapters, and a new .tape command like Chapter, that accepts a chapter name as the argument - the entire FFmpeg file could be auto-generated, and then the resulting .mp4 has chapter markers!

dzuelke avatar Aug 19 '25 00:08 dzuelke

@Exar04 this "inconsistency" seems normal to me - computers don't always perfectly execute everything at the same speed. The sleep commands are pretty spot on (+/- 2 milliseconds), so I think it's fine?!

dzuelke avatar Aug 19 '25 18:08 dzuelke

I don’t think wall clock is sufficient as drift becomes large. Instead, I used the captured frame to derive the timestamp as I describe in discussion #702.

pkazmier avatar Feb 11 '26 02:02 pkazmier