我一直在做一个视频项目,最后遇到了一堵墙可见光通信. VLC 是最好视频播放器。 它也可以用作视频生成工具,但有一些与输出文件的 FPS 相关的怪癖。 我决定重新调查FFmpeg作为替代品。 很久以前我就使用过 FFmpeg,但没有真正阅读所有文档并记得它很复杂。 好吧,是的。 我今天阅读了文档。 它是一个带有大量文档的命令行工具(参见链接) . 我把它放在一起作为概念验证。 它能做的还有很多。
下面的 JSL 包含一个为视频序列生成图像的用户定义函数和一个运行 FFmpeg 以制作视频的 RunProgram 调用。 FFmpeg 被告知通过标准输入获取图像,而 RunProgram 通过调用用户定义的函数来提供它们。 我只在 Windows 上运行过它,但我相信只需要做一些小的改动就可以让它在 Mac 上运行。
要运行它,您需要下载 FFmpeg。 他们的网站指向您可以从中获取的另一个网站。 我不确定为什么他们没有官方 Windows 版本。 安装后,此脚本将在大约 30 秒内运行以制作一个 8 秒的视频,然后在您的默认播放器中打开该视频。 它在 VLC 中看起来会更好,或者您可以将其上传到 youtube 并像这样查看:
阅读合法的东西如果你打算用它做商业工作,请小心。
// generate images for ffmpeg stdin on the fly to make a video
// using https://ffmpeg.org/download.html#build-windows
//
// You could make a somewhat simpler version, maybe, by writing
// the files to disk and telling ffmpeg to re-read them. I wanted
// to use the stdin pipe, and didn't try a file. I hope this pipe is
// at least as fast as writing and reading the files.
//
// you can't make a 2nd, parallel stream of audio data using RunProgram,
// so you'll need a disk file for audio. Or http as shown...
outputmp4 = ConvertFilePath("$desktop/VideoMadeByJMPandFFMPEG.mp4", "windows");
nrows = 1080 / 2;// keep the image buffer even in both dimensions
ncols = 1920 / 2;// and maybe a multiple of 16 as well
Open Log( 1 ); // where the action is (may need this window open for the text box to work)
imagex = J( nrows, ncols, RGB Color( 1, 1, 1 ) ); // buffer of JSL color values, updated by getNextImage...
// credit the CC music...write this once, into the buffer
musicCredit = Text Box(
"\!"Pump Sting\!" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/
"||char(asdate(today())),
<<SETWRAP></SETWRAP>