# Show ip camera in dashboard and store prefixed buffer video

**URL:** <https://discourse.nodered.org/t/show-ip-camera-in-dashboard-and-store-prefixed-buffer-video/39572>\
**Category:** General\
**Created:** [22 January 2021 17:15 UTC](https://discourse.nodered.org/t/show-ip-camera-in-dashboard-and-store-prefixed-buffer-video/39572 "2021-01-22T17:15:13Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [30 January 2021 21:05 UTC](https://discourse.nodered.org/t/show-ip-camera-in-dashboard-and-store-prefixed-buffer-video/39572/25 "2021-01-30T21:05:06Z")

</div>

@krambriw nice recordings! also, no key for your daughter? 😄

I just did a quick cmd line with ffmpeg to record an mp4 from my HLS stream. It worked like a charm. In the most basic form, all you would need is `ffmpeg -i https://123.45.67.89:1880/mp4frag/1/hls.m3u8 test.mp4` and ffmpeg will automatically figure out the input type and create the output. But of course, you can tweak the input and output to be whatever you like.

I was even able to pass a cookie(that i borrowed from my browser) to the headers of ffmpeg to get past my authentication middleware.  
`ffmpeg -headers "Cookie: nrca=s%3AeyJhbGciOiJIUzI1iIsInRcCI6IkpXVCJ9.eyJ1Ijoia2V2aW4iLCJyIjoiMTkyLjE2OCxLjcxIiwiaWF0IjoxNjEMDM4ODk0LCJleAiOjE2MTMyNDg0OTR9.GI2U2zhXOw530EyAgROAQH-afEZGXTOdzsb7zw.x1Z1bttYkQSjvMlXyT1bgDeLecWkhpz3ai7Gmx7fQ;" -i https://private.----------.com:1880/mp4frag/1/hls.m3u8 test.mp4`

`ffmpeg -h demuxer=hls`: `-live_start_index <int> .D....... segment index to start live streams at (negative values are from the end) (from INT_MIN to INT_MAX) (default -3)`

**live\_start\_index** is what you will tweak to determine how far back in the buffered video that ffmpeg will start recording from the hls.m3u8 playlist. In my non scientific test, it seems that setting that to `0` gave me the most "pre trigger" video and using a negative number such as `-5` gave me the least "pre trigger" video.

If you want ffmpeg to record a pre-determined length video after you trigger it, you can use `-t 30` to make ffmpeg stop after 30 seconds duration.

The following just worked for me to make a 30 second mp4 from my authenticated hls.m3u8:  
` ffmpeg -headers "Cookie: nrca=s%3AeyJhbGciOiJIUz6IkpXVCJ9.eyJ1IjoiCJyIjoiMTkyLjE2OC4xLjcxIiwiaWF0IjoxNjEyMDM4ODk0Dg0OTR9.GI2jU2zhXAgwROvAQH-afEZGXtTOdzsb7zw.x1Z1kbttYkQSjvMlXyTkhpz3ai7Gmx7fQ;" -f hls -live_start_index 0 -i https://private.-.com:1880/mp4frag/1/hls.m3u8 -c copy -t 30 -f mp4 test3.mp4 -y`

edit. It seems like using a big negative number -100 (or whatever number is greater than your total segments) for the live\_start\_index ensures that ffmpeg will use the oldest media segments in the hls.m3u8 playlist, which will give you the most "pre trigger" video.

I am able to get about 7 seconds of pre-trigger video from my example playlist that seems to contain 10 seconds( 20 pieces x 0.5 second duration) of video buffered:

```auto
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:377674
#EXT-X-MAP:URI="init-hls.mp4"
#EXTINF:0.520000,
hls377674.m4s
#EXTINF:0.538000,
hls377675.m4s
#EXTINF:0.541000,
hls377676.m4s
#EXTINF:0.522000,
hls377677.m4s
#EXTINF:0.547000,
hls377678.m4s
#EXTINF:0.530000,
hls377679.m4s
#EXTINF:0.536000,
hls377680.m4s
#EXTINF:0.549000,
hls377681.m4s
#EXTINF:0.516000,
hls377682.m4s
#EXTINF:0.522000,
hls377683.m4s
#EXTINF:0.549000,
hls377684.m4s
#EXTINF:0.539000,
hls377685.m4s
#EXTINF:0.502000,
hls377686.m4s
#EXTINF:0.548000,
hls377687.m4s
#EXTINF:0.543000,
hls377688.m4s
#EXTINF:0.518000,
hls377689.m4s
#EXTINF:0.549000,
hls377690.m4s
#EXTINF:0.510000,
hls377691.m4s
#EXTINF:0.532000,
hls377692.m4s
#EXTINF:0.558000,
hls377693.m4s

```

---

_[View the full topic](https://discourse.nodered.org/t/show-ip-camera-in-dashboard-and-store-prefixed-buffer-video/39572)._
