将实时视频流保存到视频文件中

huangapple go评论80阅读模式
英文:

Save live video stream to a video file

问题

I see you want to save live streaming video data into a playable video file. To do that, you'll need to capture and save the video frames from the stream. Then, you can use a library like FFmpeg to create a video file from those frames. Here's a high-level approach:

  1. Capture the video frames from the stream.
  2. Store the frames in memory or write them to a temporary file.
  3. After capturing the frames for the desired duration (e.g., 5 seconds), use FFmpeg to create a video file.

Please note that this is a simplified explanation, and you'll need to write code to achieve this. If you have any specific questions or need code samples for any part of this process, feel free to ask.

英文:

Trying to save live streaming video data into a (any) playable video file.
When I log the data I see the following (Put in comment in below code):-

axios.get(`http://192.168.1.33`, {
  responseType: 'stream',
}).then((response)=>{
  const stream = response.data
  stream.on('data', data => {
    console.log(data);  // <Buffer 4c 28 a1 0c 0d 14 0e e1 8e 28 eb 52 48 52 d0 c0 4a 4a 68 7b 0b c7 7c d2 55 21 0a 68 a9 63 12 96 9b 00 ed 49 42 1a 16 96 a4 42 1e 94 50 20 a3 d8 d5 14 ... 1386 more bytes>
                       // <Buffer 0d cb 4b f7 77 36 c8 42 9d bb b3 d6 a3 72 24 ff 00 9e 29 9e b8 35 a5 48 ad e2 11 a9 ad ec 38 1d e1 91 42 93 b8 73 bf a9 a6 96 62 a6 26 91 57 cb f4 a4 ... 4258 more bytes>
                      // ....

How can I save this data into a video file which can be played? I am starting to read from live stream at a certain point in time and reading it for few seconds - ex. 5 seconds. I need to have a video of that 5 seconds.

Note, when I use the url: http://192.168.1.33, I can see the video on the browser.

答案1

得分: 2

我不确定您所在的平台,但您可以使用 ffmpeg 在win/mac/linux上进行操作。

ffmpeg -i "http://192.168.1.33" -c copy "output.mkv"

就这么简单。

英文:

I'm not sure what platform you are on, but you can use ffmpeg to do it with win/mac/linux.

ffmpeg -i "http://192.168.1.33" -c copy "output.mkv"

Simple as that.

huangapple
  • 本文由 发表于 2023年6月26日 14:42:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554117.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定