1

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.

VISHAL DAGA
  • 4,132
  • 10
  • 47
  • 53

1 Answers1

2

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.

J. Cravens
  • 131
  • 1
  • 7
  • I recommend doing `.mkv` instead... it supports more formats and can handle things like negative offsets without issue. – Brad Jun 29 '23 at 02:15
  • Good call. It does have a lot of advantages. I'm in the habit of using Twitter, currently, and they don't allow mkv uploads, which is annoying. They need to fix that. – J. Cravens Jun 29 '23 at 13:45