electron播放器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// ffmpeg
const { exec } = require('node:child_process');
const ls = exec("ffmpeg -f lavfi -i mandelbrot -f mp4 \
-movflags frag_keyframe -preset ultrafast -pix_fmt yuv420p -listen 1 http://localhost:8000");

console.log(ls.spawnargs)

// html
const http = require('http')
const html = `
<video controls autoplay src=http://localhost:8000 />
`
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' })
res.end(html)
}).listen(8080)

// window
const { app, BrowserWindow } = require("electron")
app.whenReady().then(() => {
const window = new BrowserWindow()
window.loadURL("http://localhost:8080/")
})

参考
node-fluent-ffmpeg
EvPlayer
rockplayer
electron-better-ipc
electron-builder
mpv.js

其他

1
2
3
4
pnpm config set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
pnpm config set ELECTRON_SKIP_BINARY_DOWNLOAD=1

choco install visualstudio2022buildtools --package-parameters "--passive --add "

修复video标签在safari中无法播放mp4视频的问题
https://www.jianshu.com/p/fecdec504ab0
safari下video标签无法播放视频的问题
https://juejin.cn/post/6844903640419794958

看样子要支持safari 需要修改ffmpeg的http支持