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

rupeshforu3

In the zone
Hi I am Rupesh and I have a PC with windows 8 and 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 command prompt 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

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



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 windows command prompt or linux terminal emulator are unable to display or interpret non ASCII characters.

I have written a small shell script for Linux as below


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



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


After that I have written a batch script for windows as follows


@echo off

setlocal EnableExtensions DisableDelayedExpansion

rem // Define constants here:
set "_SOURCE=E:\to_convert\new2"
set "_TARGET=F:\FFOutput"

rem // Change to source directory temporarily:
pushd "%_SOURCE%" || exit /B 1

rem // Enumerate source files, return paths relative to the source directory:

for /F "delims=" %%F in ('xcopy /L /S /I ".\*.mp4" "%_TARGET%" ^| find "."') do (
echo Currently converting "%%F"...
rem // Create destination directory, suppress error if it aready exists:
mkdir "%_TARGET%\%%F\.." 2> nul

rem // Perform actual file conversion, using paths relative to target directory:
ffmpeg -y -i "%%F" -c:v libx265 -b:v 400k -pass 2 -c:a aac -b:a 48k -ar 44100 "%_TARGET%\%%F\..\%%~nF.mp4"

)
echo Completed.
popd

endlocal

exit /B


After execution of this batch file also I am getting continuous errors from ffmpeg command as

File not found
File not found.

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 windows power shell and issue the ls command and definitely you are not going to see file you downloaded.


I have searched web for " unicode support in command prompt " " 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 or windows command prompt and windows power shell.


Regards,
Rupesh.


Sent from my LM-G710 using Tapatalk
 
OP
R

rupeshforu3

In the zone
One of the line from the link you specified consists of the following

chcp 65001 is very dangerous.


Sent from my LM-G710 using Tapatalk
 
OP
R

rupeshforu3

In the zone
Hi I have copied script code from Linux tutorial and ffmpeg x265 help page. The ffmpeg x265 link is

*trac.ffmpeg.org/wiki/Encode/H.265

I am listing the code as below

for i in *.mp4;
do name=echo $i | cut -d'.' -f1;
echo $name;
ffmpeg -y -i "$i" -c:v libx265 -x265-params pass=1 -an -f null /dev/null && \
ffmpeg -i input -c:v libx265 -x265-params pass=2 -c:a aac -b:a 48k -ar 44100 "${name}_compressed.mp4";
done

Fortunately ffmpeg command in Linux shell scripting is working properly and previously I have not noticed.

After execution of the above script i am able to see some processing progress of ffmpeg command in Linux terminal emulator but at finally it is showing error as " atleast one input must be specified ".

May I know what's wrong with the above script.

One small request is how to convert an x264 with mp4 file extension to x265 with mp4 file extension and at the same time the video resolution, frame rate of output file and input file must be same.

Suppose I have a source x264 file with file name as my_video.mp4 with video resolution as 1920*1080 and frame rate as 28 frames per second.

I want to convert it to x265 with file name as my_video.mp4 with video resolution as 1920*1080 and frame rate as 28 frames per second.

I have searched web and found that we must include -vtag hvc1 in the options of ffmpeg command.

Somewhere I found we must include -vtag hev1 in the options of ffmpeg command.

May I know what is the difference between hvc1 and hev1 and which is best.

Sent from my LM-G710 using Tapatalk
 
Top Bottom