How to work with ffmpeg tool with file names containing non ASCII characters.

Hi I am Rupesh from India and I have a PC with open suse Linux installed. I have some MP4 video files of large size. I want to compress these files using ffmpeg command line tool not gui. I can’t do this work because the file names consists of non ASCII characters.

There are 150 files to be converted. In the terminal emulator when I navigate to this directory and issue the command “ls -name” I am getting output as lines containing non ASCII characters with English characters. When I run the command “ls -name > names.txt” and open the text file in text editor I am able to see correct file names.

In the names.txt file one of the line consists of xxxxx_english_charecters_xxxxx.mp4. In this line xxxxx are non ASCII characters i mean characters from other non English language.

I have issued the following command

<code>
ffmpeg -i -y xxxxx_english_charecters_xxxxx.mp4 -c:v libx265 -b:v 400k -c:a aac -b:a 64k -ar 44100 output.mp4.
<\code>

After issuing the above mentioned command I am getting error from ffmpeg command as below

File xxxxx_english_charecters_xxxxx.mp4 not found.

My complaint is that terminal emulator is unable to display or interpret non ASCII characters.

I have written a small shell script as below

<code>
for i in *.mp4;
do name=echo $i | cut -d'.' -f1;
echo $name;
ffmpeg -i “$i” -c:v libx265 -b:v 400k -c:a aac -b:a 64k -ar 44100 “${name}_compressed.mp4”;
done
<\code>

After that I given execute permission to this script file and tried to execute

Upon running the above script in terminal emulator i am getting continuous errors from ffmpeg command as

File unknown
File unknown

If you can’t believe my words try to create an empty file with file name containing chinise characters in windows command prompt or Linux terminal emulator using command like touch. Definitely you will fail to create.

Even if you can’t believe my words try to download or copy any file from internet with file name containing chinise characters. After that try to navigate to the directory downloaded in Linux terminal emulator and issue the ls command and definitely you are not going to see file you downloaded.

Even if you navigate to the directory downloaded in Linux file browser like nautilis you can’t view the file you downloaded.

I have searched web for " unicode support in terminal emulator " but I have not found any suitable solution.

Can anyone of you suggest how to work with command line tools like ffmpeg, touch and using these commands in shell scripting. I mean how to enable unicode in terminal emulator.

Maybe tab-completion is helping you to get the right name…

I have downloaded an YouTube video in my android smartphone and after that I have copied to my Linux PC. After that I have opened file browser Nautilus and unfortunately I can’t see the file name as I have seen in my android smartphone.

There are a number of people around the world whose mother tongue is not English. They may be doing something like me but can’t.

Try to resolve this issue and so many people may be benefited.

Thats not a linux problem, thats a problem of the source not using the right Code-Page…

bor@bor-Latitude-E5450:~$ LC_ALL=C ls -name
ls: invalid option -- 'e'
Try 'ls --help' for more information.
bor@bor-Latitude-E5450:~$ 

We do not know what you downloaded, we do not know what you see on your smartphone, we do not know what you see on your Linux PC.

Try to resolve this issue and so many people may be benefited.

Try to explain the issue so that others can also understand it.

Chinese by default works well in openSUSE. Copied a string from youtube and created a link to an existing video with the weird name #$%&*":;?=|~.mp4 (any name will work):

ln \#\$%\&\*\"\\\:\;\?\=\|~.mp4 中国十大名曲.mp4

Invoked ffmpeg’s sibling ffplay and gave it a try:

karl@erlangen:~> ffplay 中国十大名曲.mp4
ffplay version 4.4.1 Copyright (c) 2003-2021 the FFmpeg developers
  built with gcc 11 (SUSE Linux)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g' --optflags='-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --enable-version3 --enable-libsmbclient --disable-openssl --enable-avresample --enable-gnutls --enable-ladspa --enable-vulkan --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdc1394 --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librubberband --enable-libsvtav1 --enable-libsoxr --enable-libspeex --enable-libssh --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lto --enable-lv2 --enable-libmfx --enable-vaapi --enable-vdpau --enable-version3 --enable-libfdk-aac-dlopen --enable-nonfree --enable-libvo-amrwbenc --enable-libx264 --enable-libx265 --enable-librtmp --enable-libxvid
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '中国十大名曲.mp4': f=0/0   
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:00:02.73, start: 0.000000, bitrate: 2756 kb/s
  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1440x1080, 2698 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
[swscaler @ 0x7f5f484e6440] deprecated pixel format used, make sure you did set range correctly
  10.31 A-V: -0.024 fd=   1 aq=    0KB vq=    0KB sq=    0B f=0/0   
karl@erlangen:~> 

You may try the above on your machine and report details.

Well, the first problem (difference between terminal output and text editor) sounds like locale issue in terminal. The last problem (name shown on Android not found on Linux) may be due to Android showing title, while Nautilus showing filename.

But as zero information is provided …

I have visited the wikipedia page related to code page and I have seen the following line.

The code page in use may differ between machines, so (pre-Unicode) files created on one machine may be unreadable on another.

But I have copied the same file from android smartphone to my windows pc and after that opened windows explorer and the file name i have seen in both cases are same.

You may be correct form your point of view but there are a number of people around the world who can’t write complex code or have any other deep knowledge on os and computer architecture.

But we can execute any script or software provided by the people like you who have lot of experience.

Start with showing screenshot of your terminal with the wrong filename and your text file with the right name. Upload to https://susepaste.org/

As you said I have pasted the output of ls command and ffmpeg commands see below

https://susepaste.org/25449410

I have uploaded names.txt file to google drive and I am providing link below

https://drive.google.com/file/d/18fwwbBzd-3ahd6_cTcroJxZ0RfbECjKU/view?usp=sharing

I have uploaded the screen shot of terminal to google drive and I am providing link below

https://drive.google.com/file/d/1_itlkItON5XzTBY4w8d9ZHI3KrxdYuFX/view?usp=sharing

As you can see there is lot of difference in screen shot and pasted content.

If you view the names.txt in linux text editor you may may not view correctly so open it in android smartphone text editor.

There are no errors related to “non ASCII characters”. Google ffmpeg error message “Error opening file ffmpeg2pass-0.log”. If you are banned by Google, open new thread about this specific ffmpeg error with suitable subject.

As you can see

No, I cannot. I do not have access to these files. And I am not going to request any access on google drive.

In the screenshot file provide there are lots of non ASCII characters and so I thought that terminal emulator is not working.

Here the issue is when I open the text file in various editors I am seeing various content but not same.