Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P PyAV
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 37
    • Issues 37
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 26
    • Merge requests 26
  • 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
  • PyAV
  • PyAV
  • Issues
  • #600
Closed
Open
Issue created Jan 22, 2020 by Administrator@rootContributor

outcontainer unicodeencodeerror

Created by: woshimanong1990

IMPORTANT: Be sure to replace all template sections {{ like this }} or your issue may be discarded.

Overview

the out file path contain chinese character, it report unicodeencodeerror

I have fix the bug. But I don't know how to sumbit a PR

`

    diff --git a/av/container/output.pyx b/av/container/output.pyx
    index 8781958..daefd1c 100644
    --- a/av/container/output.pyx
    +++ b/av/container/output.pyx
    @@ -1,5 +1,6 @@
    from fractions import Fraction
    import logging
    +import sys

    from av.codec.codec cimport Codec
    from av.container.streams cimport StreamContainer
    @@ -11,6 +12,14 @@ from av.utils cimport dict_to_avdict

    from av.dictionary import Dictionary

    +try:
    +    from os import fsencode
    +except ImportError:
    +    _fsencoding = sys.getfilesystemencoding()
    +
    +    def fsencode(s):
    +        return s.encode(_fsencoding)
    +

    log = logging.getLogger(__name__)

    @@ -162,7 +171,9 @@ cdef class OutputContainer(Container):
                stream._finalize_for_output()

            # Open the output file, if needed.
    -        cdef char *name = "" if self.file is not None else self.name
    +        file_name = "" if self.file is not None else self.name
    +        cdef bytes name_obj = fsencode(file_name) if isinstance(file_name, unicode) else file_name
    +        cdef char *name = name_obj
            if self.ptr.pb == NULL and not self.ptr.oformat.flags & lib.AVFMT_NOFILE:
                err_check(lib.avio_open(&self.ptr.pb, name, lib.AVIO_FLAG_WRITE))

`

Assignee
Assign to
Time tracking