我正在尝试使用 nodeJS 和 ffmpeg 制作一个基本的在线视频编辑器。
为此,我需要执行 2 个步骤:
设置客户端视频的进出时间,要求客户端在特定的时间观看视频,并切换视频的位置。这意味着,如果使用单个视频作为输入,并将其分割成更小的部分,则需要从下一个编辑片段的开始时间重播(如果有意义的话)。
将输入输出数据发送到nodejs并使用ffmpeg将其导出为成品视频。
起初我想纯粹在客户端上做1.,然后将源视频上传到nodeJS,并使用ffmpeg生成相同的结果,然后将结果发送回。
但目前 HTML 客户端的视频处理可能存在问题,所以现在我改变计划:在 NodeJS 服务器上完成所有处理,包括视频播放。
这是我现在陷入困境的部分。我知道 ffmpeg 可以通过 NodeJS 以多种不同的方式使用,但是我还没有找到一种方法来使用 ffmpeg 在特定时间戳实时播放 .mp4 webm 视频,并将流视频(同样,在特定时间戳)发送到客户端。
我已经看到了 ffmpeg 中的 pipeline:1 属性,但我找不到任何教程来让它与 mp4 webm 视频一起工作,并使用 nodejs 以某种方式解析标准输出数据并将其发送到客户端。即使我能让这部分工作,我仍然不知道在某个时间戳实时播放视频。
我也见过 ffplay,但据我所知这仅用于测试;我还没有看到任何使用nodejs从中实时获取视频数据的方法。
So:
如何在nodeJS中在特定时间(最好使用ffmpeg)播放视频,并将其实时发送回客户端?
我已经看到的:
实时 http 流传输到 HTML5 视频客户端的最佳方法 https://stackoverflow.com/questions/21921790/best-approach-to-real-time-http-streaming-to-html5-video-client/30965967
使用 FFMPEG 进行网络音频 api 的直播 https://stackoverflow.com/questions/21204582/live-streaming-using-ffmpeg-to-web-audio-api
Ffmpeg - 如何强制整个帧的 MJPEG 输出? https://stackoverflow.com/questions/59468403/ffmpeg-how-to-force-mjpeg-output-of-whole-frames
ffmpeg:使用 NodeJS 从 stdin 渲染 webm https://stackoverflow.com/questions/28994271/ffmpeg-render-webm-from-stdin-using-nodejs
没有数据从 ffmpeg 写入 stdin 或 stderr https://stackoverflow.com/questions/47790255/no-data-written-to-stdin-or-stderr-from-ffmpeg
Node.js 将 ffmpeg 标准输出实时流式传输到 res https://stackoverflow.com/questions/23839741/node-js-live-streaming-ffmpeg-stdout-to-res/23845262
使用nodejs和ffmpeg进行实时视频转换 https://stackoverflow.com/questions/19519128/realtime-video-conversion-using-nodejs-and-ffmpeg
使用nodejs stdout 管道输出 ffmpeg https://stackoverflow.com/questions/22167893/pipe-output-of-ffmpeg-using-nodejs-stdout
无法使用 FFMPEG 重新流式传输 MP4 HTML5 视频 https://stackoverflow.com/questions/21804298/cant-re-stream-using-ffmpeg-to-mp4-html5-video/35955575#35955575
FFmpeg 通过 Nodejs 将 webm 视频直播到多个 http 客户端 https://stackoverflow.com/questions/46683482/ffmpeg-live-streaming-webm-video-to-multiple-http-clients-over-nodejs?rq=1
http://www.mobiuso.com/blog/2018/04/18/video-processing-with-node-ffmpeg-and-gearman/ http://www.mobiuso.com/blog/2018/04/18/video-processing-with-node-ffmpeg-and-gearman/
使用节点 Fluent-ffmpeg 流式传输 mp4 视频 https://stackoverflow.com/questions/29948551/stream-mp4-video-with-node-fluent-ffmpeg
如何通过Node JS获取ffmpeg的具体开始和结束时间? https://stackoverflow.com/questions/47090699/how-to-get-specific-start-end-time-in-ffmpeg-by-node-js
直播:节点媒体服务器 + Dash.js 配置为实时低延迟 https://stackoverflow.com/questions/60152228/live-streaming-node-media-server-dash-js-configured-for-real-time-low-latency
使用 NODE.JS 和 html5 实现低延迟 (50ms) 视频流 https://stackoverflow.com/questions/56504378/low-latency-50ms-video-streaming-with-node-js-and-html5
用于直播的服务器node.js https://stackoverflow.com/questions/48401234/server-node-js-for-livestreaming
使用 Node JS 进行 HLS 流式传输 https://stackoverflow.com/questions/21878178/hls-streaming-using-node-js
将部分视频流传输至客户端 https://stackoverflow.com/questions/25117464/stream-part-of-the-video-to-the-client
通过 Node.js 使用 HTML 5 进行视频流传输 https://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
使用 Node.js 将视频文件流式传输到 html5 视频播放器以便视频控件继续工作? https://stackoverflow.com/questions/24976123/streaming-a-video-file-to-an-html5-video-player-with-node-js-so-that-the-video-c
如何(伪)流式传输 H.264 视频 - 以跨浏览器和 html5 的方式? https://stackoverflow.com/questions/6677682/how-to-pseudo-stream-h-264-video-in-a-cross-browser-and-html5-way
伪流式传输 MP4 文件 https://stackoverflow.com/questions/25669948/pseudo-streaming-an-mp4-file
如何将视频数据流式传输到视频元素? https://stackoverflow.com/questions/36274810/how-to-stream-video-data-to-a-video-element
如何使用 ffmpeg 将 h.264 流转换为 MP4 并将结果通过管道传输到客户端? https://stackoverflow.com/questions/56407245/how-do-i-convert-an-h-264-stream-to-mp4-using-ffmpeg-and-pipe-the-result-to-the
https://medium.com/@brianshaler/on-the-fly-video-rendering-with-node-js-and-ffmpeg-165590314f2 https://medium.com/@brianshaler/on-the-fly-video-rendering-with-node-js-and-ffmpeg-165590314f2
Node.js 将 ffmpeg 标准输出实时流式传输到 res https://stackoverflow.com/questions/23839741/node-js-live-streaming-ffmpeg-stdout-to-res
Node.js 可以编辑视频文件吗? https://stackoverflow.com/questions/12032120/can-node-js-edit-video-files