DVR-Scan icon indicating copy to clipboard operation
DVR-Scan copied to clipboard

ffmpeg copy doesnt work

Open washinoboku opened this issue 10 months ago • 1 comments

Only output mode opencv works, other options do not

2025-05-28 20:54:32,964 INFO: dvr_scan main.main(): DVR-Scan Application 1.7.0.1 2025-05-28 20:54:32,964 INFO: dvr_scan main.main(): Loading user config file: C:\Users\washi\AppData\Local\DVR-Scan\dvr-scan.cfg 2025-05-28 20:54:33,181 DEBUG: dvr_scan application._initialize(): initializing UI state from settings 2025-05-28 20:54:33,181 DEBUG: dvr_scan application.run(): starting main loop 2025-05-28 20:54:42,656 DEBUG: pyscenedetect init.open_video(): Opening video with opencv... 2025-05-28 20:54:52,472 DEBUG: dvr_scan application._start_scan(): ui settings: {'input': ['E:\CAJA\A06_20250503123256.mp4'], 'use-pts': True, 'downscale-factor': 0, 'frame-skip': 0, 'input-mode': 'opencv', 'kernel-size': -1, 'bg-subtractor': 'CNT', 'threshold': 0.15, 'min-event-length': '0.1s', 'time-before-event': '2s', 'time-post-event': '2s', 'learning-rate': -1.0, 'max-threshold': 255.0, 'variance-threshold': 16.0, 'mask-output': False, 'output-mode': <OutputMode.COPY: 3>, 'output-dir': 'C:/Users/washi/Desktop/Nueva carpeta (2)', 'scan-only': False} 2025-05-28 20:54:52,472 DEBUG: dvr_scan init.init_scanner(): initializing motion scan 2025-05-28 20:54:52,481 INFO: dvr_scan video_joiner._load_input_videos(): Opened video A06_20250503123256.mp4 (960 x 1080 at 30.000 FPS). 2025-05-28 20:54:52,521 DEBUG: dvr_scan scan_window.show(): starting scan thread showing scan window. 2025-05-28 20:54:52,521 DEBUG: dvr_scan scanner._handle_regions(): no regions selected 2025-05-28 20:54:52,521 INFO: dvr_scan scanner.scan(): Using subtractor CNT with kernel_size = 3 (auto), variance_threshold = auto and learning_rate = auto 2025-05-28 20:54:52,521 INFO: dvr_scan scanner.scan(): Scanning input video for motion events... 2025-05-28 20:54:52,521 DEBUG: dvr_scan scanner.scan(): input mode = opencv, output mode = SCAN_ONLY 2025-05-28 20:56:19,101 DEBUG: dvr_scan scanner.scan(): event 1 high score 42.765133 2025-05-28 20:56:19,101 INFO: dvr_scan scanner._on_motion_event(): Splitting events using ffmpeg, first event: 2025-05-28 20:56:19,101 DEBUG: dvr_scan scanner._extract_event_ffmpeg(): Running ffmpeg, args: ffmpeg -y -nostdin -v error -ss 00:00:00.033 -i E:\CAJA\A06_20250503123256.mp4 -t 00:17:00.933 -map 0 -c:v copy -c:a copy -sn C:/Users/washi/Desktop/Nueva carpeta (2)\A06_20250503123256.DSME_0001.mp4 2025-05-28 20:56:19,191 CRITICAL: dvr_scan scanner._encode_thread(): Fatal error: Exception raised in encode thread. 2025-05-28 20:56:19,191 DEBUG: dvr_scan scanner._encode_thread(): (<class 'subprocess.CalledProcessError'>, CalledProcessError(4294967274, ['ffmpeg', '-y', '-nostdin', '-v', 'error', '-ss', '00:00:00.033', '-i', 'E:\CAJA\A06_20250503123256.mp4', '-t', '00:17:00.933', '-map', '0', '-c:v', 'copy', '-c:a', 'copy', '-sn', 'C:/Users/washi/Desktop/Nueva carpeta (2)\A06_20250503123256.DSME_0001.mp4']), <traceback object at 0x00000263F50BB240>) 2025-05-28 20:56:19,251 CRITICAL: dvr_scan scan_window._update(): error during scan: Traceback (most recent call last):

File "dvr_scan\app\scan_window.py", line 238, in _do_scan

File "dvr_scan\scanner.py", line 1008, in scan

File "dvr_scan\scanner.py", line 1199, in _encode_thread

File "dvr_scan\scanner.py", line 1176, in _on_motion_event

File "dvr_scan\scanner.py", line 198, in _extract_event_ffmpeg

File "subprocess.py", line 466, in check_output

File "subprocess.py", line 571, in run

subprocess.CalledProcessError: Command '['ffmpeg', '-y', '-nostdin', '-v', 'error', '-ss', '00:00:00.033', '-i', 'E:\CAJA\A06_20250503123256.mp4', '-t', '00:17:00.933', '-map', '0', '-c:v', 'copy', '-c:a', 'copy', '-sn', 'C:/Users/washi/Desktop/Nueva carpeta (2)\A06_20250503123256.DSME_0001.mp4']' returned non-zero exit status 4294967274.

2025-05-28 20:57:05,161 INFO: dvr_scan scan_window._destroy(): Stopping current scan. 2025-05-28 20:57:05,201 DEBUG: dvr_scan application.on_closed(): scan window closed, restoring focus 2025-05-28 20:57:05,201 DEBUG: dvr_scan scan_window._destroy(): root destroyed

washinoboku avatar May 29 '25 00:05 washinoboku

Same issue here. It seems like the code is messing with slashes (directory structure).

[DVR-Scan] Stopping current scan.
[DVR-Scan] Opened video C0017.MP4 (3840 x 2160 at 29.970 FPS).
[DVR-Scan] Limiting detection to 1 region.
[DVR-Scan] Using subtractor MOG2 with kernel_size = 7 (auto), variance_threshold = auto and learning_rate = 0.5
[DVR-Scan] Scanning input video for motion events...
[DVR-Scan] [Issue 198] Incorrect meter format: ['00:00', '7:30:21', '', '5.34', 'frames/s']
[DVR-Scan] Splitting events using ffmpeg, first event:
[DVR-Scan] Fatal error: Exception raised in encode thread.
Detected: 1 | Progress:   1%|▍                                              | 1475/144210 [00:29<47:47, 49.78 frames/s]
[DVR-Scan] error during scan:
Traceback (most recent call last):

  File "dvr_scan\app\scan_window.py", line 238, in _do_scan

  File "dvr_scan\scanner.py", line 1008, in scan

  File "dvr_scan\scanner.py", line 1199, in _encode_thread

  File "dvr_scan\scanner.py", line 1176, in _on_motion_event

  File "dvr_scan\scanner.py", line 198, in _extract_event_ffmpeg

  File "subprocess.py", line 466, in check_output

  File "subprocess.py", line 571, in run

subprocess.CalledProcessError: Command '['ffmpeg', '-y', '-nostdin', '-v', 'error', '-ss', '00:00:38.005', '-i', 'C:\\Users\\Derek\\projects\\DVR-Scan-File-Organizer\\videos\\C0017.MP4', '-t', '00:00:10.611', '-map', '0', '-c:v', 'copy', '-c:a', 'copy', '-sn', 'C:/Users/Derek/projects/DVR-Scan-File-Organizer/videos\\C0017.DSME_0001.mp4']' returned non-zero exit status 4294967274.```

derek-palmer avatar Jun 20 '25 19:06 derek-palmer

Hmm this is odd, the output from @derek-palmer seems to be correct (the path looks fine), but the original post is not correct. I don't see any weird names or symbols in the paths either. Let me see if I can reproduce the issue and get a fix in for the next release.

Thanks for the context and report.

Breakthrough avatar Jul 12 '25 00:07 Breakthrough

There's quite a bit of weird path manipulation happening within the codebase using os.path, which should probably be changed to use pathlib.Path. I'll try to make path handling consistent across the CLI and GUI for the next release, and only use strings when handling user input and when generating output commands (e.g. to invoke ffmpeg). This should help ensure the paths are normalized correctly, which isn't happening as per the examples you both have posted.

I expect this should reduce or eliminate any issues related to path handling.

Unfortunately I am unable to reproduce the issue you are facing locally. If anyone can help come up with a reliable reproduction for the issue, or can point me to an environment that this is repeatable under, that would be appreciated. I'll try to add extra logging so we can see exactly what ffmpeg is unhappy with.

Breakthrough avatar Aug 21 '25 00:08 Breakthrough