我一直在做一個視頻項目,最後遇到了一堵牆可見光通信. 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>