Skip to content

Unhandled CalledProcessError when source file violates Windows file name length limits #16

@ghost

Description

Per Microsoft's Maximum Path Length Limitation, the maximum length for a path is MAX_PATH, which is defined as 260 characters. It is possible for a source file or demuxed source file to exceed this length, which results in a CalledProcessError whenever we attempt to use this source file.

Example:

Include file '[deanzel] Tenchi Muyo! Ryo-Ohki - S01E02v2 (1448x1052 Hi10P BD Dual Audio FLAC)[49fafe63].mkv':
INFO: Retrieving source file stream/format data...
Select audio stream [0-1]: 1
INFO: Retrieving extracted audio/video stream/format data...
Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\lib\site-packages\batch_encoder\__main__.py", line 132, in <module>
    main()
  File "C:\Python39\lib\site-packages\batch_encoder\__main__.py", line 86, in main
    source_file = SourceFile.from_file(source_file_candidate, encoding_config)
  File "C:\Python39\lib\site-packages\batch_encoder\_source_file.py", line 48, in from_file
    video_format = subprocess.check_output(video_args).decode('utf-8')
  File "C:\Python39\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Python39\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_streams', '-show_format', '-show_chapters', '[Video][deanzel] Tenchi Muyo! Ryo-Ohki - S01E02v2 (1448x1052 Hi10P BD Dual Audio FLAC)[49fafe63].mkv']' returned non-zero exit status 1.

Note: When demuxing selected streams, we simply append the stream type to the original file name, which is what happened here.

Ideally we should more gracefully handle this case so that the end user knows the source of the failure, or circumvent it if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions