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))
`