0

I have a script that gets video files from a folder and calls an ffmpeg command on them with subprocess. Everything works fine until i try to put accents in the filenames. When filenames have no accent i have the ffmpeg command output but i get nothing with filenames with accents so i don't know the error. I'm using Python 2.6 on Windows.

My subprocess call looks like this :

p=subprocess.Popen(command)
p.wait()

And my command arguments looks like this :

['\\\\path\\to\\ffmpeg\\bin\\ffmpeg.exe', 
 '-i',   
 u'\\\\path\\to\\root\\folder\\\xd9\xda\xdb\xdc\xdd\xe0\xe1\xe2\xe3\xe4\xe5\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf1\xf2\xf3\xf4\xf5\xf6\xf9\xfa\xfb\xfc\xfd\xff.avi', 
 '-vcodec', 'mjpeg', 
 '-qscale', '1', 
 '-y', 
 '-r', '30000/1001', 
 '-vf', 'scale=1280x720,setsar=1:1', 
 '-strict', '-2', 
 '-codec:a', 
 'copy', 
 u'\\\\path\\to\\root\\folder\\Converted\\\xd9\xda\xdb\xdc\xdd\xe0\xe1\xe2\xe3\xe4\xe5\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf1\xf2\xf3\xf4\xf5\xf6\xf9\xfa\xfb\xfc\xfd\xff_20170321.mov']

my filename raw string is ÙÚÛÜÝàáâãäåèéêëìíîïñòóôõöùúûüýÿ.avi but i tried even with only a simple accent é in the filename and it doesn't work either. Also i tried running the ffmpeg directly from the command line and it works. I guess it's an encoding issue but all the encoding stuff is a mystery for me so my apologies in advance.

EDIT : This could be a potential duplicate but i'm not using any external module.

Community
  • 1
  • 1
Narthe
  • 492
  • 1
  • 4
  • 16
  • Is this Python 2 or Python 3? Apparently the underlying system is Windows? What code page and what is the locale? – tripleee Mar 21 '17 at 14:44
  • I edited my post, i'm using Python 2.6 on Windows. – Narthe Mar 21 '17 at 15:01
  • The *crucial* question is the code page of your filesystem. – tripleee Mar 21 '17 at 15:02
  • code page is OEM United States (437) and locale is en-us – Narthe Mar 21 '17 at 15:09
  • Then I'm guessing the real question is how to convert Unicode to CP437 but I'm not finding a good duplicate and don't know enough about how this is handled on Windows anyway. Maybe a duplicate of http://stackoverflow.com/questions/33941838/python-how-to-convert-unicode-filename-to-cp437 – tripleee Mar 21 '17 at 15:11
  • 1
    @tripleee, Windows file systems are UCS-2. They're Unicode for the most part, except they allow lone surrogate codes, which isn't valid UTF-16. Narthe's problem is that Python 2.x `subprocess.Popen` calls `CreateProcessA` (ANSI, not OEM). If you search around you can find workarounds that subclass `Popen` to use `CreateProcessW` (Unicode) using ctypes or PyWin32 -- or you could write your own. – Eryk Sun Mar 21 '17 at 17:31
  • Possible duplicate of [Unicode filenames on Windows with Python & subprocess.Popen()](http://stackoverflow.com/questions/1910275/unicode-filenames-on-windows-with-python-subprocess-popen) – tripleee Mar 21 '17 at 19:08

0 Answers0