主要是用 ffmpeg 命令,这个命令很强大,可以压缩视频,转换格式,也可以将视频转为gif。试了下,3M的视频可以压缩或转换成800K,很清晰。
(defun my/video-compress-and-convert (video new)
(interactive "fvideo path: \nfnew item name (eg. exam.mp4, exam.gif) : ")
(let ((extension (cadr (split-string (file-name-nondirectory new) "\\."))))
(if (string= extension "gif")
(progn
(shell-command
(concat "ffmpeg -i " video " -r 5 " new))
(message "%s convert to %s successfully!" video new))
(progn
(shell-command
(concat "ffmpeg -i " video " -vcodec libx264 -b:v 5000k -minrate 5000k -maxrate 5000k -bufsize 4200k -preset fast -crf 20 -y -acodec libmp3lame -ab 128k " new))
(message "%s compress and convert to %s successfully!" video new))
)
))
原文:https://blog.geekinney.com/post/elisp-hack-compress-and-convert-video.html