Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow globs as input to enable full-folder scanning #5

Closed
sveken opened this issue Dec 17, 2018 · 17 comments
Closed

Allow globs as input to enable full-folder scanning #5

sveken opened this issue Dec 17, 2018 · 17 comments
Labels
Milestone

Comments

@sveken
Copy link

sveken commented Dec 17, 2018

Hello,

Wanting to use this for my dashcam when it is in parking mode, only problem is even in parking mode it only does 3 minute clips over the 8 hours,

Is there a way to scan a whole folder?

@Breakthrough
Copy link
Owner

Breakthrough commented Dec 18, 2018

EDIT: This feature is now available in the latest release of DVR-Scan.


Hi @sveken;

Currently there is no way to accomplish this purely via DVR-Scan. However, you could write a Python or Bash script to accomplish this by running the dvr-scan command on all files in a given directory.

I'll look into adding this as a possible enhancement for a future release, thanks for your submission.

@Breakthrough
Copy link
Owner

As a possible way of implementation, perhaps allowing globs for the input file would be helpful.

@Breakthrough
Copy link
Owner

From #10, it would also be useful for this to output a list of motion events in a CSV file for each video scanned, to allow automated removal of videos without any motion events.

@matosconsulting
Copy link

matosconsulting commented Mar 14, 2020

Just wanted to share - for any Windows users who want to scan a folder or subset of folders, here's a quick and dirty command you can use:

for /F %i in ('dir *.mp4 /b') do dvr-scan -i %i

This runs a directory listing for all .mp4 files, and spits out a list of filenames. For each filename, the command "dvr-scan -i [filename]" is run. Amend the command above as necessary to get the results you need (e.g. pass in additional options to dvr-scan, sort the directory listing by date descending, etc...)

@SKempin
Copy link
Contributor

SKempin commented May 24, 2020

Similarly for anyone on MacOS:

target="/Users/name/Desktop/"
for f in "$target"*
do
    dvr-scan -i $f -t 0.3 -tb 00:00:05.2000 -tp 00:00:10.2000 -l 20
done

@Breakthrough
Copy link
Owner

Breakthrough commented Aug 30, 2020

This is definitely on my radar (see #10), but I won't be able too address some of these improvements as the project requires a major refactor before looking into adding new features (it grew rather rapidly from a prototype script into a feature rich application, and to be honest, I still have a lot to learn about high level software design and scalability). Will get back to this as soon as that's done.

Thank you all for the above batch scripts, they'll likely be very useful for users in the meantime. Will pin this issue for more visibility.

@aardvark82
Copy link

aardvark82 commented Mar 5, 2021

Also - on Mac os X - if you have multiple subfolders (the example above only handles video files at 1 level) you can use

  • install bash 5 with glob support (Mac OS X standard bash doesn't support globs) - > brew install bash
  • enable glob
  • for f in "$target"/**/*

@Breakthrough
Copy link
Owner

I like your suggestion in #48 to also process files in parallel, @aardvark82 - that should definitely be possible. I'm working on refactoring the codebase to be more modular/reusable, which definitely supports this goal (and should be a lot cleaner to implement once I'm finished reworking the internal API).

@jaybeegee66
Copy link

jaybeegee66 commented Nov 11, 2021

One work around for windows users is to do the following

  • open a cmd/dos prompt
  • change directory to the one with the files
  • output the directory listing to a text file by doing "dir >files.txt"
  • using excel parse the file keeping just the filename in column A as an example
  • for the first row in column B add a formula with the parameters you need eg. ="dvr-scan -i " & A29 & " -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60"
  • for subsequent rows use " =" -i " & A30& " -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60"
  • finally merge all the cells into one field and you will end up with something like this:

dvr-scan -i 2012-05-24_12-29-38.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60 -i 2012-05-24_12-48-17.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60 -i 2012-05-24_13-18-48.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60 -i 2012-05-24_13-49-15.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60 -i 2012-05-24_14-19-41.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60 -i 2012-05-24_14-50-26.AVI -t 0.3 -tb 00:00:05.0000 -tp 00:00:5.0000 -l 60

@Breakthrough Breakthrough modified the milestones: v1.5, v2.0 Feb 11, 2022
@TeSoad90
Copy link

TeSoad90 commented Apr 4, 2022

Just wanted to share - for any Windows users who want to scan a folder or subset of folders, here's a quick and dirty command you can use:

for /F %i in ('dir *.mp4 /b') do dvr-scan -i %i

This runs a directory listing for all .mp4 files, and spits out a list of filenames. For each filename, the command "dvr-scan -i [filename]" is run. Amend the command above as necessary to get the results you need (e.g. pass in additional options to dvr-scan, sort the directory listing by date descending, etc...)

THANK YOU!

Breakthrough added a commit that referenced this issue Apr 5, 2022
Link to workaround for scanning all files in a folder to the FAQ.
@Breakthrough Breakthrough changed the title Way to scan whole folder? Allow globs as input to enable full-folder scanning Jun 5, 2022
@Breakthrough
Copy link
Owner

Breakthrough commented Jul 1, 2022

Finally managed to get around to fixing this, and will be included in the next release (v1.5). Summary of upcoming changes:

  • -i/--input will also now accept multiple paths, allowing for shell wildcard expansion (you can still specify -i multiple times)
  • Each path passed to -i/--input will also have wildcard/glob expansion performed on it directly

This means all of the following forms will work in DVR-Scan v1.5:

dvr-scan -i folder*.mp4
dvr-scan -i "folder/*.mp4"
dvr-scan -i folder_a/* -i "folder_b/*"
dvr-scan -i video1.mp4 video2.mp4
dvr-scan -i video1.mp4 -i video2.mp4

I've also added a -d/--output-dir flag to allow you to specify an explicit output folder, rather than only outputting files into the current working directory. Hopefully this should alleviate a lot of pain points people are facing when processing multiple files or folders.

Sorry for the delay in getting to this, hoping to release v1.5 sometime within the next month or so (lots of cool new features are being worked on 😄). Also planning on getting an early beta/release candidate before the final version is out, so stay tuned!

For anyone eager to provide feedback, you can grab .whl's from the AppVeyor builds:
https://ci.appveyor.com/project/Breakthrough/dvr-scan/history

@Breakthrough
Copy link
Owner

Breakthrough commented Jul 5, 2022

The latest release of DVR-Scan (v1.5.1 at time of writing) now includes correct support for this.

Beta release including this feature is now out:
https://github.com/Breakthrough/DVR-Scan/releases/tag/v1.5-beta

Feedback is most welcome. :)

@jaybeegee66
Copy link

Beta release including this feature is now out: https://github.com/Breakthrough/DVR-Scan/releases/tag/v1.5-beta

Feedback is most welcome. :)

I am trying the multiple file option using this command but getting an error!

dvr-scan -i e:\video\2013-10-27*.avi -d d:\temp -l 60

First file works fine but does not seem to transition to the next.

[DVR-Scan] Scanning 45 input videos for motion events...
[DVR-Scan] Fatal error: Exception raised in decode thread.
Detected: 2 | Progress: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 21601/21601 [01:34<00:00, 228.95 frames/s]
Traceback (most recent call last):
File "dvr_scan_main_.py", line 28, in
File "dvr_scan_main_.py", line 24, in main
File "dvr_scan\cli\controller.py", line 282, in run_dvr_scan
File "dvr_scan\scanner.py", line 733, in scan_motion
File "dvr_scan\scanner.py", line 817, in _decode_thread
File "dvr_scan\video_joiner.py", line 107, in read
AttributeError: 'VideoJoiner' object has no attribute '_get_next_frame'
[3784] Failed to execute script 'main' due to unhandled exception!

@Breakthrough
Copy link
Owner

@jaybeegee66 sorry there was a bug with that beta, this should work correctly in the latest official release (v1.5.1). Let me know if the latest version works out for you, thanks!

@jaybeegee66
Copy link

jaybeegee66 commented Apr 16, 2023

@jaybeegee66 sorry there was a bug with that beta, this should work correctly in the latest official release (v1.5.1). Let me know if the latest version works out for you, thanks!

Sounds good thank you!

Edit - my bad picked up an old build!

@Arielblues
Copy link

Hi, am using this command dvr-scan -i "folder/*.mp4" for folder scanning. But I noticed the filenames of the motion videos use only the first video name as initial naming. Is it possible that the motion video's use the name of their original video?

@Breakthrough
Copy link
Owner

Breakthrough commented Jun 13, 2023

@Arielblues there's no option for this, but it's certainly possible. Feel free to file a new feature request for it.

The reason things are the way they are is DVR-Scan treats all inputs as a sequence (e.g. motion events can span multiple videos). Could you describe a bit more about your use case?

In the meantime, you may want to consider calling DVR-Scan on each file individually using a for loop in your shell, rather than using wildcards. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants