From ad3deb3226106f38689593c25d3a50efda6bcaae Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Sep 2026 18:40:02 -0400 Subject: [PATCH] Remote network usage --- aiworker/.env | 5 +++++ aiworker/docker-compose.yml | 7 +------ aiworker/run.pl | 11 +++++++++-- scanner/.env | 14 ++++++++++++++ scanner/docker-compose.yml | 8 +------- scanner/scanner.pl | 10 ++++++---- 6 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 aiworker/.env create mode 100644 scanner/.env diff --git a/aiworker/.env b/aiworker/.env new file mode 100644 index 0000000..4c9ab7d --- /dev/null +++ b/aiworker/.env @@ -0,0 +1,5 @@ +# VideoDetect — Docker Compose environment variables +# Copy this file to .env and fill in real values before running docker-compose up. + +API_HOST=https://10.0.1.7:3000 + diff --git a/aiworker/docker-compose.yml b/aiworker/docker-compose.yml index 5857837..5e93470 100644 --- a/aiworker/docker-compose.yml +++ b/aiworker/docker-compose.yml @@ -9,15 +9,13 @@ services: container_name: videodetect-aiworker restart: "no" environment: - - API_BASE_URL=${API_BASE_URL:-http://videodetect-api:3000} + - API_BASE_URL=${API_BASE_URL:-http://10.0.1.7:3000} - OLLAMA_URL=${OLLAMA_URL:-http://10.0.1.7:11434} - SECONDS_PER_FRAME=${SECONDS_PER_FRAME:-30} - TASK_COUNT=${TASK_COUNT:-50} volumes: - nas_input:/data:ro - ./run.pl:/app/run.pl:ro - networks: - - videodetect_videodetect-network volumes: nas_input: @@ -27,6 +25,3 @@ volumes: o: addr=10.0.0.2,ro,nfsvers=4,hard,intr device: ":/mnt/Bulk/Homes/ryan/Prawns" -networks: - videodetect_videodetect-network: - external: true diff --git a/aiworker/run.pl b/aiworker/run.pl index 6c20ace..e66ffd1 100755 --- a/aiworker/run.pl +++ b/aiworker/run.pl @@ -25,6 +25,8 @@ for(my $i=0; $i<$task_count; $i++) { my $video_id = $video->{'id'}; my $path = $video->{'file_path'}; my $result = CheckPath($path); + + next unless $result; my $response = PostResponse($task_id, $ref->{'assign_key'}, $result); } @@ -69,14 +71,19 @@ sub CheckPath { unlink($file); } + if($total == 0) { + warn "No images were processed for $path\n"; + return undef; + } + my $percentage = ($yes*100)/$total; print "$yes of $total images gave yes - $percentage\n"; my $verdict = 0; if($percentage >= $sensitivity) { - print "Probably a black dude, $percentage\n"; + print "$path: Probably a black dude, $percentage\n"; $verdict = 1; } else { - print "Probably not, $percentage\n"; + print "$path: Probably not, $percentage\n"; $verdict = 0; } return { diff --git a/scanner/.env b/scanner/.env new file mode 100644 index 0000000..6a2e1c2 --- /dev/null +++ b/scanner/.env @@ -0,0 +1,14 @@ +# VideoDetect — Docker Compose environment variables +# Copy this file to .env and fill in real values before running docker-compose up. + +# ----------------------------------------------------- +# Database +# ----------------------------------------------------- +DB_ROOT_PASSWORD=videodetect +DB_PASSWORD=videodetect +DB_USER=videodetect +DB_NAME=videodetect +DB_HOST=10.0.1.7 + +API_HOST=https://10.0.1.7:3000 + diff --git a/scanner/docker-compose.yml b/scanner/docker-compose.yml index 39ecb8e..d0a1483 100644 --- a/scanner/docker-compose.yml +++ b/scanner/docker-compose.yml @@ -18,8 +18,6 @@ services: volumes: - nas_input:/data:ro - $PWD/scanner.pl:/app/scanner.pl:ro - networks: - - videodetect_videodetect-network volumes: nas_input: @@ -27,8 +25,4 @@ volumes: driver_opts: type: nfs o: addr=10.0.0.2,ro,nfsvers=4,hard,intr - device: ":/mnt/Bulk/Homes/ryan/Prawns" - -networks: - videodetect_videodetect-network: - external: true \ No newline at end of file + device: ":/mnt/Bulk/Homes/ryan/Prawns" \ No newline at end of file diff --git a/scanner/scanner.pl b/scanner/scanner.pl index 65c9157..67d98b4 100755 --- a/scanner/scanner.pl +++ b/scanner/scanner.pl @@ -16,7 +16,7 @@ $SIG{INT} = sub { die "Interrupted\n"; }; my $dbh = DBI->connect("DBI:mysql:database=$db_name;host=$db_host", $db_user, $db_pass); -my @video_extensions = qw(mp4 mkv avi mov flv wmv mpg mpeg webm); +my @video_extensions = qw(mp4 mkv avi mov flv wmv mpg mpeg webm m4v); my %ignored_extensions; my @dir_queue = ('/data'); @@ -46,18 +46,19 @@ while(my $dir = shift @dir_queue) { # Any entry where last_scan_time < $now is considered deleted or moved, so we can mark them as such my $sth_delete = $dbh->prepare("DELETE FROM videos WHERE last_scan_time < ? OR last_scan_time IS NULL"); $sth_delete->execute($now); -print "Ignored extensions: " . join(", ", keys %ignored_extensions) . "\n"; +for my $ext (sort { $ignored_extensions{$b} <=> $ignored_extensions{$a} } keys %ignored_extensions) { + print "Ignored extension $ext: $ignored_extensions{$ext} times\n"; +} sub process_file { my ($file_path) = @_; if (my ($ext)=$file_path =~ /^.+\.(\S+?)$/) { unless (grep { lc($ext) eq $_ } @video_extensions) { - $ignored_extensions{lc($ext)} = 1; + $ignored_extensions{lc($ext)}++; return; # Not a video file } } - print "$file_path\n"; my $sth = $dbh->prepare("SELECT id,file_size FROM videos WHERE file_path=?"); $sth->execute($file_path); if(my $row = $sth->fetchrow_hashref()) { @@ -71,6 +72,7 @@ sub process_file { } return; # Already exists and size matches } + print "NEW:$file_path\n"; my $info = get_video_info($file_path); unless ($info) {