Shell ffmpeg shuts down the computer

Greetings, gentlemen! A mystery to spice up your life? It certainly spiced up mine.

I am running FreeBSD 13.4 on a Dell Wyse 3040 thin client. It's used as a camera controller, and it runs this simple shell script:

Code:
touch "/tmp/ffmpeg_overlay.txt"

#   Front camera
echo Starting front camera...
nice -n 10 \
ffmpeg \
    -hide_banner \
    -loglevel error \
    -thread_queue_size 2048 \
    -fflags nobuffer \
    -avoid_negative_ts "make_zero" \
    -use_wallclock_as_timestamps 1 \
    -f "v4l2" \
    -input_format "h264" \
    -framerate 25 \
    -video_size "1280x720" \
    -i "/dev/camera-front" \
    -filter_complex "[0:v]drawtext=fontfile=/home/tomcatmwi/python_dashcam/overlay.ttf:textfile=/tmp/ffmpeg_overlay.txt:reload=1:x=10:y=10:fontsize=24:fontcolor=white:borderw=2:bordercolor=black[v0]" \
    -map "[v0]" \
    -f "segment" \
    -segment_time 180 \
    -strftime 1 \
    -c:v "libx264" \
    -preset "veryfast" \
    -crf 18 \
    "/tmp/camera-storage/front/%Y-%m-%d_%H:%M:%S_front.mp4"

The problem? It resets the computer. There is no shutdown warning, no error message, no kernel panic. Just BAM, it's down. I tried it several times, and it always happened. Sometimes immediately, sometimes after several minutes.

According to htop, CPU usage is around 30-35%. RAM usage is around 50%.
There is 1.5 GB free storage, so it's far from full. Even if it was full, it wouldn't just abruptly reset.
The CPU is not overheating at all. I can touch the CPU cooler, and it's barely as warm as my hand. (It has no active cooling.)
There is nothing in `/var/logs/messages`. Only this:

Code:
Nov 17 01:25:53 corolla-chan-cameras login[2359]: ROOT LOGIN (root) ON ttyv0
Nov 17 01:43:42 corolla-chan-cameras syslogd: kernel boot file is /boot/kernel/kernel
Nov 17 01:43:42 corolla-chan-cameras kernel: ---<<BOOT>>---
...etc

I tried to change the output directory, and also the location of the text file which contains a text overlay. It didn't help, this damn thing still resets.

I found some examples of the same thing happening on some Linux systems. There aren't any answers, just vague suggestions that the CPU might be overheating. I would bet these guys witnessed the same thing as I just did.


Anybody with a clue?
 
Most (many? some?) CPUs can measure the die temperature, and power supply voltage. Write a little script that collects these measurements, and displays them when the problem happens. If it happens too fast for you to see, have that script save the data in a "safe" place (could be disk, but remember to call fsync(), could be the network).
 
If it happens too fast for you to see,
I once got away with recording the console with a good camera and single-stepping trough the video (save uncompressed video).
It got the afterglow from the system console displaying the call stack and crash information, just enough to pinpoint the bug. Because if it happens really fast, you will not find anything in the log files.
 
If it isn't a thermal issue, replace the power supply. IIRC those tiny dells came with abysmally bad wall warts as power supply. Get one that matches the required voltage (IIRC 12V) and exceeds the maximum power draw of your specific variant. (there should be either an ampere value or wattage on the label on the bottom of the PC)
 
yeah...possible causes: thermal or runaway pointer in ffmpeg or in webcam driver.

You could also maybe run your command with strace and save log to persistent storage. you might get lucky and save enough data see where things go off the rails.
 
Back
Top