Global

Methods

(async) WFfmpeg(args, optopt) → {Promise}

Description:
  • 調用ffmpeg,傳入參數交由套件自帶的ffmpeg.exe執行,只能用於Windows作業系統

    ffmpeg.exe由安裝時(postinstall)自GitHub下載切割zip分片合併解壓而來,位於套件src/目錄

    ffmpeg: https://ffmpeg.org/

Source:
Example
import WFfmpeg from './src/WFfmpeg.mjs'

async function test() {

    //args, 轉檔範例: 將input.mp4轉為output.avi
    let args = ['-i', './input.mp4', './output.avi']

    //cbStderr, ffmpeg的進度與資訊預設輸出至stderr
    let cbStderr = (msg) => {
        console.log(msg)
    }

    //WFfmpeg
    await WFfmpeg(args, { cbStderr })

    console.log('done')
}
test()
    .catch((err) => {
        console.log('catch', err)
    })
Parameters:
Name Type Attributes Default Description
args Array | String

輸入ffmpeg參數,可為陣列(例如['-i','./input.mp4','./output.avi'])或字串

opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
cbStdout function <optional>
null

輸入回調stdout函數,預設null

cbStderr function <optional>
null

輸入回調stderr函數,預設null

timeout Number <optional>
null

輸入逾時毫秒數,預設null表示不限制

codeCmd String <optional>

輸入讀回程序stdout與stderr回應的解碼字串,預設由execProcess決定

mode String <optional>

輸入子程序執行模式(spawn/exec/execFile),預設由execProcess決定為spawn

Returns:

回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息

Type
Promise