unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: stardiviner <numbchild@gmail.com>
To: Emacs Help <help-gnu-emacs@gnu.org>
Subject: How to subtract timestamp in elisp?
Date: Sat, 04 Jul 2020 19:11:29 +0800	[thread overview]
Message-ID: <87zh8fwn4u.fsf@gmail.com> (raw)


I'm find an Elisp solution to subtract timestamps like "00:12:35".

I hope a function can subtract two timestamps:

    00:12:35 - 00:10:45 = 00:01:50

Is there some hints or suggestion like function name or Emacs library or package?
Or can convert timestamp into another format then convert back to timestamp.

I use those timestamps in "ffmpeg" command video cut clip command option "-ss" and "-t".

Or Linux command is acceptable. I can write a function to execute shell command then parse the result.

Here is my current code:

#+begin_src emacs-lisp
(defun ffmpeg-cut-clip (input-filename start-timestamp end-timestamp output-filename)
  (interactive (list
                (read-file-name "FFmpeg input filename: ")
                (read-string "FFmpeg start timestamp: ")
                (read-string "FFmpeg time timestamp: ")
                (read-file-name "FFmpeg output filename: ")))
  (let ((time-timestamp (FUNC start-timestamp end-timestamp)))
    (make-process
     :name "ffmpeg cut clip"
     ;; "ffmpeg -i input-filename -ss start-timestamp -t time-timestamp -codec copy output-filename"
     :command (list "ffmpeg"
                    "-i" input-filename
                    "-ss" start-timestamp
                    "-t" time-timestamp
                    "-codec copy"
                    output-filename)
     :buffer "*ffmpeg-cut-clip*"
     :sentinel (lambda (proc event)
                 (message "FFmpeg cut video clip finished.")))))
#+end_src

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3



             reply	other threads:[~2020-07-04 11:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 11:11 stardiviner [this message]
2020-07-04 11:39 ` How to subtract timestamp in elisp? Eli Zaretskii
2020-07-04 12:54 ` Michael Heerdegen
2020-07-04 21:17   ` Dmitry Alexandrov
2020-07-04 21:11 ` Dmitry Alexandrov
2020-07-05  3:04   ` [SOLVED] " stardiviner
2020-07-06  2:48     ` mu4e: configuring SMTP (was: [SOLVED] Re: How to subtract timestamp in elisp?) Dmitry Alexandrov
2020-07-05 13:30 ` How to subtract timestamp in elisp? Emanuel Berg via Users list for the GNU Emacs text editor
2020-07-06  1:43   ` stardiviner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zh8fwn4u.fsf@gmail.com \
    --to=numbchild@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).