What causes orphan recording files?

"Orphan" meaning existing recording files on disk that do not appear in Channels app 'Recordings' listing.

I have found numerous such files - some created well over a year ago. (!)

Also, can anything be done by either a user or developers to prevent this from happening? And, no, I haven't migrated to a new disk or performed any other "maintenance" action on the disk since the original install of Channels.

It's a very tedious and time-consuming process to identify such files and delete them manually via file system (NTFS) to free-up space.

When you delete recordings in Channels DVR, this is what happens:

  1. Recordings become unlisted from the library and end up in the Trash. The files themselves are still present on the disk.

  2. After either 1, 3, or 10 days (as defined in the settings) the Trash is cleared. At that moment, the files get deleted from the disk.

So you seem to be in situation #1 but you said some files are from one year ago. So it's as if the files couldn't be deleted from the disk when the trash got cleared.

Could it be that those files were being used by another program and Windows was unable to delete them?

Were the files moved or renamed?

There is a feature in Channels DVR to get a list of recordings still present in the DVR database but not physically present on the disk. Your situation is reversed.

It should be possible to write a script to generate a list of recordings present on the disk but not in the DVR database.

1 Like

Thanks much for the reply.

I suppose it's possible files were being used by another program and Windows was unable to delete them - but I'd guess highly unlikely. To my knowledge, those files are never moved or renamed and no reason to do so. (?) That disk drive is dedicated solely to Channels - no other program creates or manipulates files on that drive.

Re writing a script to identify "orphaned" recordings files, I have no idea how to do that. But yes, that would be very useful.

1 Like

I will see if I have enough spare time during the week to write a script that gives a list of extra recordings that are left on the disk and unknown to the DVR.

I might be surprised to see that I also have some.

My server also runs on Windows so that will be interesting if that reveals a possible bug.

This is definitely an issue on Windows, I've seen it too.

1 Like

Excellent! Looking forward to using it. Thanks much.

Well, to my surprise, I have orphaned recordings too and way more than I imagined!

I'm working on a script now and it surprised me with this output:

Found 103 orphaned recordings:
 → I:\DVR\Movies\Ace Ventura When Nature Calls (1995) 2021-06-26-1457.mpg
 → I:\DVR\Movies\Alien (1979) 2021-07-02-1927.mpg
 → I:\DVR\Movies\Along Came Polly (2004) 2021-07-10-1627.mpg
 → I:\DVR\Movies\American Made (2017) 2021-06-08-1720.mpg
 → I:\DVR\Movies\American Pie Presents The Book of Love (2009) 2021-06-27-0257.mpg
 → I:\DVR\Movies\Born on the Fourth of July (1989) 2021-07-03-0800.mpg

and more.

I will clean up the code and publish the script shortly.

Thanks! When you publish script, please provide instructions for running on Windows. PowerShell script would be perfect!

Sorry, this is a Python script. :frowning:

I'm not familiar with PowerShell but I can see if with help from AI I can convert it.

Do you have any that are recent? If you search your logs do you see anything about them?

In my case, they are old files. The most recent ones are from November 2023 (2 of them) and all others are from 2021 (101 of them).

1 Like

You may now download a PowerShell script:
mjitkop/cdvr-find-orphaned-recordings: Get a list of recordings present on disk(s) but unknown to a Channels DVR server.

You will want to download the file cdvr_find_orphaned_recordings.ps1.
The instructions to run it are explained there.

For other people who would prefer a Python script, there is one available there too.

Excellent! Much appreciate.

However, there may be a bug in the PowerShell script.

See below the last 5 lines of output. The numbers don't add up.

Checking storage paths for files...
-> Found 3 files in U:\Channels DVR\Movies
-> Found 27 files in U:\Channels DVR\TV
-> Found a total of 3 files on disks.
No orphaned recordings found.

Thank you for the feedback! I will take a look at this bug.

1 Like

Any progress on fixing the bug? Otherwise, the script works great.

Please check your DMs. I sent you a request to run a modified version of my script to produce more printouts on the screen. I just need more information because I was not able to see the bug in the code.

Error
$ python3 cdvr_find_orphaned_recordings.py
Using Channels DVR at: http://127.0.0.1:8089

Fetching recording paths from the server...
 -> Retrieved 319 recording paths from the server.

Fetching storage paths from the server...
Traceback (most recent call last):
  File "/home/channels/src/cdvr-find-orphaned-recordings/cdvr_find_orphaned_recordings.py", line 119, in <module>
    main()
  File "/home/channels/src/cdvr-find-orphaned-recordings/cdvr_find_orphaned_recordings.py", line 103, in main
    storage_paths = get_storage_paths(dvr_url)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/channels/src/cdvr-find-orphaned-recordings/cdvr_find_orphaned_recordings.py", line 37, in get_storage_paths
    paths.extend(json_data.get("extra_paths"))
TypeError: 'NoneType' object is not iterable
$ git diff
diff --git a/cdvr_find_orphaned_recordings.py b/cdvr_find_orphaned_recordings.py
index c2bc4c1..f89ab41 100644
--- a/cdvr_find_orphaned_recordings.py
+++ b/cdvr_find_orphaned_recordings.py
@@ -34,7 +34,7 @@ def get_storage_paths(dvr_url):
         json_data = response.json()

         paths.append(json_data.get("path"))
-        paths.extend(json_data.get("extra_paths"))
+        paths.extend(json_data.get("extra_paths") or [])

     except requests.RequestException as e:
         print(f"Error fetching recording paths: {e}")

Found 1 orphaned recordings:
-> /mnt/sda1/Channels/recordings/Movies/Takers (2010) 2026-01-28-2000.mpg

My iSCSI drive needed to be remounted but CDVR, after an unsuccessful deletion, forgot about the file.

channels-dvr-2026-02-06.log:2026/02/07 19:40:31.100332 [ERR] Missing file to delete #44863 /mnt/sda1/Channels/recordings/Movies/Takers (2010) 2026-01-28-2000.mpg: stat /mnt/sda1/Channels/recordings/Movies/Takers (2010) 2026-01-28-2000.mpg: input/output error

1 Like

Thanks for this fix, @hal9000 ! :smiley:

I'm glad the script (after you fixed it) was able to find one orphaned file for you. :slightly_smiling_face:

I will add your suggested fix in the next version.

1 Like