0

I'm running this command in a systemd service:

ffmpeg -re -i http://192.168.1.100:8080/stream -an -nostdin -q:v 6 -f segment -strftime 1 -segment_time 600 -segment_format mjpeg '/mnt/hdd/%%Y-%%m-%%d_%%H-%%M-%%S.mpg'

This records an mjpeg stream from 192.168.1.100:8080/stream and saves the recordings in 10-minute segments to files in /mnt/hdd. Note the doubled percent signs: this is to escape them in the ExecStart of the systemd service file; when running on the command line, single percent signs must be used.

The problem I'm having is that the service creates 10-minute-long video files, but pauses for about five minutes between them. So when I check /mnt/hdd, I see this:

ls -lh /mnt/hdd/2024-12-06_00-*
-rw-r--r-- 1 ki9 video 719M Dec  6 00:26 /mnt/hdd/2024-12-06_00-11-57.mpg
-rw-r--r-- 1 ki9 video 718M Dec  6 00:41 /mnt/hdd/2024-12-06_00-26-57.mpg
-rw-r--r-- 1 ki9 video 718M Dec  6 00:56 /mnt/hdd/2024-12-06_00-41-57.mpg
-rw-r--r-- 1 ki9 video 717M Dec  6 01:11 /mnt/hdd/2024-12-06_00-56-57.mpg

Files are 15 minutes apart, but only contain 10 minutes of video. So there's always 5 minutes of nothing recorded. It's always exactly five minutes too...

The logs are not very helpful. They show ffmpeg writing to files that don't exist at all.

journalctl -u webcam-record -ocat | grep 2024-12-06_00-
[segment @ 0x5572a54f0580] Opening '/mnt/hdd/2024-12-06_00-01-06.mpg' for writing
[segment @ 0x5572a54f0580] Opening '/mnt/hdd/2024-12-06_00-16-00.mpg' for writing
[segment @ 0x5572a54f0580] Opening '/mnt/hdd/2024-12-06_00-30-55.mpg' for writing
[segment @ 0x5572a54f0580] Opening '/mnt/hdd/2024-12-06_00-45-49.mpg' for writing

To complicate things further, it only seems to happen some of the time.

ls -lh /mnt/hdd/2024-12-06_06-*
-rw-r--r-- 1 ki9 video 197M Dec  6 06:28 /mnt/hdd/2024-12-06_06-13-51.mpg
-rw-r--r-- 1 ki9 video 458M Dec  6 06:43 /mnt/hdd/2024-12-06_06-28-46.mpg
-rw-r--r-- 1 ki9 video 600M Dec  6 06:56 /mnt/hdd/2024-12-06_06-43-41.mpg
-rw-r--r-- 1 ki9 video 524M Dec  6 07:04 /mnt/hdd/2024-12-06_06-56-11.mpg

Other times, it records every five minutes:

ls -lh /mnt/hdd/2024-12-06_07-*
-rw-r--r-- 1 ki9 video 477M Dec  6 07:11 /mnt/hdd/2024-12-06_07-04-42.mpg
-rw-r--r-- 1 ki9 video 517M Dec  6 07:17 /mnt/hdd/2024-12-06_07-11-57.mpg
-rw-r--r-- 1 ki9 video 600M Dec  6 07:22 /mnt/hdd/2024-12-06_07-17-36.mpg
-rw-r--r-- 1 ki9 video 626M Dec  6 07:26 /mnt/hdd/2024-12-06_07-22-01.mpg
-rw-r--r-- 1 ki9 video 646M Dec  6 07:30 /mnt/hdd/2024-12-06_07-26-27.mpg
-rw-r--r-- 1 ki9 video 660M Dec  6 07:35 /mnt/hdd/2024-12-06_07-30-52.mpg
-rw-r--r-- 1 ki9 video 683M Dec  6 07:39 /mnt/hdd/2024-12-06_07-35-18.mpg
-rw-r--r-- 1 ki9 video 676M Dec  6 07:44 /mnt/hdd/2024-12-06_07-39-44.mpg
-rw-r--r-- 1 ki9 video 677M Dec  6 07:48 /mnt/hdd/2024-12-06_07-44-12.mpg
-rw-r--r-- 1 ki9 video 696M Dec  6 07:53 /mnt/hdd/2024-12-06_07-48-37.mpg
-rw-r--r-- 1 ki9 video 717M Dec  6 07:57 /mnt/hdd/2024-12-06_07-53-03.mpg
-rw-r--r-- 1 ki9 video 754M Dec  6 08:01 /mnt/hdd/2024-12-06_07-57-29.mpg

I have two services recording two streams to different hard drives and they both seem to switch to five-minute gaps at exactly 7am.

1 Answer 1

0

Not sure the theory behind it, but adding -reset_timestamps 1 seems to have fixed this.

ffmpeg -re -i http://192.168.1.100:8080/stream -an -nostdin -q:v 6 -f segment -strftime 1 -segment_time 600 -segment_format mjpeg '/mnt/hdd/%Y-%m-%d_%H-%M-%S.mpg'

(That's the "command-line version" with single percent signs.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .