You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repo has been quite dead for a while now, but I hope there are still some people hanging around here that can maybe help me or point me in the right direction.
TL;DR
I have securitycameras that I stream 24/7 live, but with a 30m delay because of reasons. Somehow though, this sometimes increases up to a 60m delay, although I can not find the raw footage on the server. How is this even possible?
Config
I created a workflow where, when nginx starts, it starts recording the camera and saves a .flv every 30m. I then rename that to just 'stream.flv' to create a source for continious streaming. If the buffer file does not exist at first, it will show a waiting screen.
This works fine, apart from the fact the stream ends up anywhere between 30 up to 60 minutes behind. When I manually download the .flv file and play it, it's just the past 30 minutes. The footage that is shown through HLS at that moment, for example from 56 minutes ago, is not in there.
How is that even possible? Is there some kind of hidden tmp used by nginx/nginx-rtmp?
It's not because of unexpected restarts of nginx, because it also happens when it will be up and running for days.
Hope there's someone who knows where this strange behaviour comes from, or maybe knows a better way to do this.
#!/bin/bash
# Test if buffer is there
if test -f "/recordings/$1.flv"; then
# If yes, start stream like normal
/usr/bin/ffmpeg -i rtmp://localhost:1935/vod/$1.flv -vcodec copy -f flv rtmp://localhost:1935/live/$1;
else
# Start waiting screen
/usr/bin/ffmpeg -loop 1 -i buffer.jpg -vcodec libx264 -pix_fmt yuv420p -an -f flv rtmp://localhost:1935/live/$1 &
# Save wainting screen PID
BUFFER_PID=$!
# Wait for buffer to build
sleep 30m
# Kill waiting screen
kill $BUFFER_PID
# Start actual stream, delayed
/usr/bin/ffmpeg -i rtmp://localhost:1935/vod/$1.flv -vcodec copy -f flv rtmp://localhost:1935/live/$1;
fi
rename.sh
#!/bin/bash
# Catch stream name, delete -HHMM part from filename
CAM=$1
CAM_STRIPPED=${CAM::-5}
# Delete old .flv file just to be sure old footage does not stick around
rm /recordings/$CAM_STRIPPED.flv
# Rename new footage
mv /recordings/$CAM.flv /recordings/$CAM_STRIPPED.flv
# Delete footage older than 60 minutes, just to keep everything clean in case of previous errors
/usr/bin/find /recordings/*.flv -type f -mmin +60 -delete
The text was updated successfully, but these errors were encountered:
This repo has been quite dead for a while now, but I hope there are still some people hanging around here that can maybe help me or point me in the right direction.
TL;DR
I have securitycameras that I stream 24/7 live, but with a 30m delay because of reasons. Somehow though, this sometimes increases up to a 60m delay, although I can not find the raw footage on the server. How is this even possible?
Config
I created a workflow where, when nginx starts, it starts recording the camera and saves a .flv every 30m. I then rename that to just 'stream.flv' to create a source for continious streaming. If the buffer file does not exist at first, it will show a waiting screen.
This works fine, apart from the fact the stream ends up anywhere between 30 up to 60 minutes behind. When I manually download the .flv file and play it, it's just the past 30 minutes. The footage that is shown through HLS at that moment, for example from 56 minutes ago, is not in there.
How is that even possible? Is there some kind of hidden tmp used by nginx/nginx-rtmp?
It's not because of unexpected restarts of nginx, because it also happens when it will be up and running for days.
Hope there's someone who knows where this strange behaviour comes from, or maybe knows a better way to do this.
nginx.conf
stream-30m.sh
rename.sh
The text was updated successfully, but these errors were encountered: