DEV Community

Super Funicular
Super Funicular

Posted on

Grading the Nokia 30-Minute Screen-Off Test From the Clip Files: 67 Lines of Python That Find Where Recording Stopped

Our guide to old Nokia Android phones as security cameras ends with a test: start recording, turn the screen off, wait 30 minutes, then check the recordings. Then repeat overnight.

A reader pointed out why 30 minutes matters. The old Evenwell Power saver cut background apps at about 20 minutes, so a 10-minute test gives a false pass.

But "check the recordings" hides real work. An overnight test is 8 hours of clips. You will not scrub through them. You need to know three things fast:

  1. Did recording cover the whole window?
  2. If not, when did it stop, measured from the moment the screen went off?
  3. Did it stop for good, or come back?

The answer to all three is already in the files. This post is a 67-line Python script that reads it, and the three test folders we ran it on.

What the files already tell you

Most phone camera apps split recording into segments and name each clip by its start time, like CAM_20261121_230000.mp4. Your app's naming may differ; adjust the pattern. Each clip also knows its own duration, which ffprobe (part of FFmpeg) prints.

Start + duration = end. Line the clips up, and every space between one clip's end and the next clip's start is a gap.

Two details matter:

  • Segment joins are not gaps. A new segment often starts a second after the last one ends. The script allows 5 seconds.
  • An unreadable clip is a gap. If a recorder is stopped hard, a normal MP4 can be left without its index (the moov atom), and no player can open it. ffprobe says so, and the script counts that time as missing instead of crashing.

The script

#!/usr/bin/env python3
"""Grade a screen-off recording test from the clip files alone.
Usage: python3 gaps.py FOLDER SCREEN_OFF_TIME END_TIME
Times are local, YYYY-mm-dd HH:MM. Clip names must start with the
recording start time: CAM_YYYYmmdd_HHMMSS.mp4"""
import re, sys, subprocess
from datetime import datetime, timedelta
from pathlib import Path

GAP_OK = timedelta(seconds=5)      # a clean segment join is allowed this much
NAME = re.compile(r"(\d{8}_\d{6})")

def duration(p):
    out = subprocess.run(
        ["ffprobe", "-v", "error", "-show_entries", "format=duration",
         "-of", "default=nw=1:nk=1", str(p)],
        capture_output=True, text=True)
    try:
        return float(out.stdout.strip())
    except ValueError:
        return None                  # unreadable clip: treat as missing

def main(folder, off, end):
    off = datetime.strptime(off, "%Y-%m-%d %H:%M")
    end = datetime.strptime(end, "%Y-%m-%d %H:%M")
    clips, bad = [], []
    for p in sorted(Path(folder).glob("*.mp4")):
        m = NAME.search(p.name)
        if not m:
            continue
        start = datetime.strptime(m.group(1), "%Y%m%d_%H%M%S")
        d = duration(p)
        if d is None:
            bad.append(p.name); continue
        clips.append((start, start + timedelta(seconds=d), p.name))
    clips.sort()
    gaps, cursor = [], off
    for s, e, name in clips:
        if e <= off or s >= end:
            continue
        if s - cursor > GAP_OK:
            gaps.append((cursor, s))
        cursor = max(cursor, e)
    if end - cursor > GAP_OK:
        gaps.append((cursor, end))
    total = (end - off).total_seconds()
    missing = sum((b - a).total_seconds() for a, b in gaps)
    print(f"clips: {len(clips)}  unreadable: {len(bad)}")
    print(f"window: {off:%H:%M} -> {end:%H:%M}  covered: {100*(total-missing)/total:.1f}%")
    for a, b in gaps:
        mins = (a - off).total_seconds() / 60
        print(f"  gap {a:%H:%M:%S} -> {b:%H:%M:%S}  ({(b-a).total_seconds()/60:.1f} min)"
              f"  starts {mins:.1f} min after screen off")
    if not gaps:
        print("verdict: full window recorded")
    else:
        first = (gaps[0][0] - off).total_seconds() / 60
        if 15 <= first <= 25 and gaps[0][1] >= end - GAP_OK:
            print("verdict: stopped near 20 min and never came back -> vendor killer (Step 2a/2b)")
        elif gaps[-1][1] >= end - GAP_OK:
            print(f"verdict: stopped at {gaps[-1][0]:%H:%M} and never came back -> check Battery Saver, Adaptive Battery, memory")
        else:
            print("verdict: recording has holes but resumed -> check the charger and storage first")
    return 1 if gaps else 0

if __name__ == "__main__":
    sys.exit(main(*sys.argv[1:4]))
Enter fullscreen mode Exit fullscreen mode

It needs Python 3 and FFmpeg's ffprobe on a computer. Copy the clips off the phone first. It never changes the clips.

Three test folders

We built three folders with FFmpeg (tiny 16×16 grey clips at 1 frame per second, so the durations are exact) and ran the script on each with Python 3.10.12.

A: the pass

Screen off at 23:00. Six 5-minute segments, each starting 1 second after the last ended.

clips: 6  unreadable: 0
window: 23:00 -> 23:30  covered: 100.0%
verdict: full window recorded
Enter fullscreen mode Exit fullscreen mode

The 1-second joins did not count. Exit code 0.

B: the 20-minute killer

Same start, but the last segment is only 267 seconds long, so recording ends at 23:19:30.

clips: 4  unreadable: 0
window: 23:00 -> 23:30  covered: 65.0%
  gap 23:19:30 -> 23:30:00  (10.5 min)  starts 19.5 min after screen off
verdict: stopped near 20 min and never came back -> vendor killer (Step 2a/2b)
Enter fullscreen mode Exit fullscreen mode

19.5 minutes of 30 recorded = 65.0%. The gap starts 19.5 minutes after screen off and runs to the end of the window. That is the Evenwell pattern from the guide's table, and the verdict line points back to its Step 2a and 2b.

Note what a 10-minute test would have said about this phone: 100%, pass.

C: the night with holes

Overnight, 23:00 to 07:00, sixteen 30-minute slots (each clip 1,799 s). The 03:30 clip is missing, and the 05:00 clip is a broken file with no index.

clips: 14  unreadable: 1
window: 23:00 -> 07:00  covered: 87.5%
  gap 03:29:59 -> 04:00:00  (30.0 min)  starts 270.0 min after screen off
  gap 04:59:59 -> 05:30:00  (30.0 min)  starts 360.0 min after screen off
verdict: recording has holes but resumed -> check the charger and storage first
Enter fullscreen mode Exit fullscreen mode

14 of 16 slots = 87.5%. Both holes are found, including the one a file listing would hide: the broken 05:00 clip is there, it just holds nothing you can watch.

Reading the verdict

The three verdicts map to the guide's result table:

What the script finds Likely cause
Gap starts 15–25 min after screen off, never ends A vendor app killer is still active
Gap starts later, never ends Battery Saver, Adaptive Battery, or memory pressure
Holes, but recording came back Look at power and storage before battery settings
No gaps The phone is ready

The third row is a judgement, not a measurement. A hole that heals means something restarted the recording, so a permanent app kill is less likely. A loose cable or a full card is a cheaper first check than a settings hunt.

For the "same time every night" row in the guide, run the script once per night and compare the gap start times.

What this does not tell you

  • Why the recording stopped. The files show when, not who. On a Nokia, the guide's Step 1 (Android version) and Step 2 (Evenwell, DuraSpeed) are still how you find the cause.
  • Whether the picture is good. A covered window full of black frames still scores 100%.
  • Anything about clips named by end time, or apps that record one long file. Change the NAME pattern or the duration logic for those.

Same test, any phone

Nothing here is Nokia-specific. The 20-minute line is, but the method works for the Motorola, Redmi and OnePlus guides too. Change the 15–25 minute window to whatever cut-off your brand is known for.


Background Camera RemoteStream turns an Android phone into a screen-off camera: it records with the screen off and keeps recordings on the phone, with no cloud account needed. Its Pro tier adds a live browser view over your own Wi-Fi and YouTube Live streaming; check the Play listing for what is free and what is Pro.

Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

This is the kind of test that earns its keep. A 10-minute test giving a false pass on a phone Evenwell kills at around 20 minutes is exactly the trap that only shows up once you measure instead of eyeballing it. The detail I liked most is the unreadable clip counting as a gap: in folder C the broken file is right there in the listing, holding nothing watchable, and a naive check on file existence would have missed it entirely.

The verdict table is honest about its own limits too — the "holes, but recording came back" row being a judgement, not a measurement, is the right call. A gap that heals is a different animal from a gap that never ends.

One thing I'm curious about: for the Motorola, Redmi and OnePlus guides, do their vendor killers have a similarly sharp cut-off you can anchor the 15–25 minute window to, or is that window a Nokia number that needs re-measuring per brand?