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

Intermittent non-zero exit status 123 #103

Open
sundeepgoel72 opened this issue Aug 21, 2022 · 4 comments
Open

Intermittent non-zero exit status 123 #103

sundeepgoel72 opened this issue Aug 21, 2022 · 4 comments
Labels

Comments

@sundeepgoel72
Copy link

sundeepgoel72 commented Aug 21, 2022

Bug/Issue Description:

Running dvr-scan via a windows batch file to process a large number of files. Periodically processing stops, and CTRL-C has to be pressed multiple times to resume. On pressing CTRL-C following error log is printed, pointing to exit code 123 from ffmpeg.

any pointers on what could be causing it ?


--- Logging error ---
Traceback (most recent call last):
File "dvr_scan\scanner.py", line 929, in _encode_thread
File "dvr_scan\scanner.py", line 907, in _on_motion_event
File "dvr_scan\scanner.py", line 166, in _extract_event_ffmpeg
File "subprocess.py", line 415, in check_output
File "subprocess.py", line 516, in run
subprocess.CalledProcessError: Command '['ffmpeg', '-y', '-nostdin', '-v', 'error', '-hwaccel', 'dxva2', '-ss', '00:01:08.400', '-i', 'H:\Surveilance\Ch8\2020-10-17\ch8-20201017125205_20201017125401.dav', '-t', '00:00:16.040', '-map', '0', '-c:v', 'libx265', '-preset', 'fast', '-crf', '28', '-c:a', 'aac', '-sn', 'H:\Surveilance\Ch8\2020-10-17\extracted\ch8-20201017125205_20201017125401.DSME_0006.mp4']' returned non-zero exit status 123.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "tqdm\contrib\logging.py", line 30, in emit
File "logging_init_.py", line 1069, in flush
OSError: [Errno 22] Invalid argument
Call stack:
File "threading.py", line 890, in bootstrap
File "threading.py", line 932, in bootstrap_inner
File "threading.py", line 870, in run
File "dvr_scan\scanner.py", line 934, in encode_thread
File "logging_init
.py", line 1493, in critical
File "logging_init
.py", line 1589, in log
File "logging_init
.py", line 1599, in handle
File "logging_init
.py", line 1661, in callHandlers
File "logging_init_.py", line 954, in handle
File "tqdm\contrib\logging.py", line 34, in emit
Message: 'Fatal error: Exception raised in encode thread.'
Arguments: ()
Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='cp1252'>
OSError: [Errno 22] Invalid argument

executed ffmpeg manually : c:\sg-bin\ffmpeg-full\bin\ffmpeg.exe -y -nostdin -v error -hwaccel dxva2 -ss 00:01:08.400 -i H:\Surveilance\Ch8\2020-10-17\ch8-20201017125205_20201017125401.dav -t 00:00:16.040 -map 0 -c:v libx265 -preset fast -crf 28 -c:a aac -sn out.mp4

ran fine without any issue...

@Breakthrough
Copy link
Owner

Breakthrough commented Aug 21, 2022

  1. Please add --verbosity debug to your command when running DVR-Scan, and provide the full output after adding that.
  2. Please include the full command you are invoking in your batch script. If possible please share the entire batch file as well.
  3. Does the same error happen when you run DVR-Scan outside of a batch file on the same input?
  4. Are you specifying a logfile?
  5. Is the ffmpeg.exe in the location of dvr-scan.exe the same as the one you used in the last command you wrote above?

If you're able to successfully run ffmpeg yourself, that points to item 5 being the issue. If so, you can replace the ffmpeg exe in the dvr-scan folder with a newer version.

The exception is happening somewhere due to the way logging works, I have not seen this error before. DVR-Scan should continue to run after ffmpeg fails, but for some reason it fails to log the error. OSError: [Errno 22] Invalid argument points to it being unable to write the log to a logfile or stdout/stderr. I'm unable to reproduce the issue, so I suspect your batch file is doing something with stdout/stderr or the logfile has an invalid path.

Thank you.

@sundeepgoel72
Copy link
Author

so I suspect your batch file is doing something with stdout/stderr or the logfile has an invalid path.

Batch file is a below. The error occurs on DSME_0006.mp4, implies that first 5 extracts have run fine, indicates issue probably not with batch file.

I'll reply to other points shortly.

@echo off
for /d %%i in (%1) do call :$DoSomething "%%i"
exit /B

::**************************************************
:$DoSomething
::**************************************************
mkdir %~1\extracted

for %%f in (%~1\*.dav); do (
	echo %%f | findstr /c:"delete"  1>nul
	if errorlevel 1 (
		dvr-scan -c "E:\sg-bin\python\PersonDetection\dvr-scan-config-ch8.txt" -i %%f --logfile %~1\extracted\motionlog.txt -d %~1\extracted | findstr /c:"No motion events detected" && ren %%f %%~nf-delete%%~xf  || echo Motion in %%f >>  %~1\extracted\Nomotionlog.txt
)
	
exit /B

@sundeepgoel72
Copy link
Author

Ran DVR-scan outside of batch, get following at the last extract

[DVR-Scan] Failed to decode 6 frame(s) from video, timestamps may be incorrect. Try re-encoding or remuxing video (e.g. ffmpeg -i video.mp4 -c:v copy out.mp4). See #62 for details.
[DVR-Scan] Processed 2898 frames read in 67.4 secs (avg 43.0 FPS).
[DVR-Scan] Detected 6 motion events in input.
[DVR-Scan] List of motion events:

DVR-scan doesnt "hang" but exits normally (logfile attached) - so wonder why the batch file is hanging ...
motionlog.txt

@Breakthrough
Copy link
Owner

Can you let me know if you get the same issue if you uninstall the tqdm module? Also are there any special characters in the logfile path?

This seems to be failing after changing logging to work correctly with the progress bar. If the root cause of the issue cannot be determined, a potential workaround would be to add a config file to disable the progress bar. A command line argument should probably be added to disable the progress bar anyways as it may not work under all systems. If you are using the Python version of DVR-Scan, you can simply uninstall the tqdm module.

This means DVR-Scan won't show any progress bars, but it will help determine if this is the reason the batch file is failing or not.

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

2 participants