Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F ffmpeg-python
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 402
    • Issues 402
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 34
    • Merge requests 34
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Karl Kroening
  • ffmpeg-python
  • Merge requests
  • !700

Use fspath to consistently support PathLike objects as input/output filenames.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Brian Hou requested to merge github/fork/brianhou/master into master Aug 21, 2022
  • Overview 0
  • Commits 2
  • Pipelines 1
  • Changes 3

Path-like objects were already supported by input and by output when the filename was explicitly specified as a keyword argument. (subprocess.Popen accepts path-like objects in addition to strings.) However, implicitly specifying the output filename as the last element of a list of output streams/filename did not permit a path-like object; instead, this raises a ValueError with a somewhat misleading error message.

>>> import ffmpeg
>>> from pathlib import Path
>>> ffmpeg.input("input.mp4").output("output.mp4")
output(filename='output.mp4')[None] <1fa880dddf3d>
>>> ffmpeg.input("input.mp4").output(filename="output.mp4")
output(filename='output.mp4')[None] <1fa880dddf3d>
>>> ffmpeg.input(Path("input.mp4")).output(filename="output.mp4")
output(filename='output.mp4')[None] <3105870c5a1e>
>>> ffmpeg.input(Path("input.mp4")).output(filename=Path("output.mp4"))
output(filename=PosixPath('output.mp4'))[None] <3cf3744481bb>
>>> ffmpeg.input(Path("input.mp4")).output(Path("output.mp4"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../ffmpeg/_ffmpeg.py", line 85, in output
    raise ValueError('A filename must be provided')
ValueError: A filename must be provided

This PR uses a patched version of os.fspath to explicitly convert all path-like objects to strings (or raise an error). Once support is dropped for versions before 3.6, this should be updated to use os.fspath directly.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/brianhou/master