Encoding errors from ffmpeg x265 pass 2 which succeeded in pass 1.

rupeshforu3

In the zone
Hi I am Rupesh and I have a PC with Linux installed and I have large size YouTube and WhatsApp MP4 files with codec x264. I want to convert these files into MP4 files with codec x265.

I have tested to convert these files using ffmpeg command x265 pass 1 and Linux shell script and I have successfully completed without any errors but I want to use ffmpeg tool x265 pass 2 to do the same job but I can't.

I got the following code from ffmpeg website and first I have tried to convert a single file and after that I have tried to use the similar code in Linux shell script.

Code:
ffmpeg -y -i source.mp4 -filter_threads 3 -profile:v main -preset medium -c:v libx265 -x265-params pass=1 -an -f null /dev/null && \

ffmpeg -i source.mp4 -c:v libx265 -x265-params pass=2 -c:a aac -b:a 48k -ar 44100 source_compressed.mp4

Upon running the above command I am able to see .log and .cue files in the current directory.

For all cases I got only the following two errors.




Code:
[libx265 @ 0x742200] Cannot open libx265 encoder.

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[aac @ 0x745300] Qavg: 33846.148

[aac @ 0x745300] 2 frames left in the queue on closing

Conversion failed!

localhost:~/to convert #



Code:
[libx265 @ 0x10e43c0] Cannot open libx265 encoder.

Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Conversion failed!

The code I have executed without pass 2 is the following.

Code:
ffmpeg -y -i source.mp4 -filter_threads 3 -profile:v main -preset medium -c:v libx265 -c:a aac -b:a 48k -ar 44100 source_compressed.mp4

Can you suggest why I can't do the same job in pass 2 of ffmpeg command which has been successfull in pass 1 of ffmpeg command x265.


Sent from my LM-G710 using Tapatalk
 
OP
R

rupeshforu3

In the zone
I thought that pass 2 encoding and command line tools like ffmpeg, x265 produces more quality output than guis.
 
OP
R

rupeshforu3

In the zone
Can you say what is the meaning of the following option

-profile:v main --preset medium

Does the above option helps producing quality output.

Sent from my LM-G710 using Tapatalk
 
OP
R

rupeshforu3

In the zone
How to limit the cpu usage while running ffmpeg tool and x265 in Linux.

Sent from my LM-G710 using Tapatalk
 
Last edited:
OP
R

rupeshforu3

In the zone
I have solved this issue by the following option

-cpucount 3

Where my processor consists of 4 cores.

Another issue is suppose the input mp4 video file consists of bitrate 160 kbps then after converting this particular file the output mp4 video file consists of bitrate 250 kbps.

In the above bitrate is video bitrate not audio bitrate.

I have seen the properties of source and output mp4 video files in media info.

Can you suggest how to convert the x264 mp4 video file into x265 mp4 video file with the same video bitrate as input video file.

Sent from my LM-G710 using Tapatalk
 
OP
R

rupeshforu3

In the zone
Hi ffprobe tool can be used to extract the bitrate of the source input mp4 video file which later can be used in ffmpeg command as below.

ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 input.mp4

Actually the above process is working with one file I mean I have used ffprobe tool to get the video bitrate and after that I have used it by invoking ffmpeg command by providing the bitrate value.

I want to apply the same process in a Linux shell script and run it and so I have developed a small shell script as below.

for i in *.mp4;

do name=echo $i | cut -d'.' -f1;
echo $name;

$temp=ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 $i;

$br=echo $temp | cut -d'=' -f1;

ffmpeg -y -i "$i" -cpucount 3 -c:v libx265 -b:v $br -preset medium -c:a libfdk_aac -b:a 52k -ar 44100 "${name}_compressed.mp4";

# echo $br;
# echo $temp;
done

Upon running the above script I am getting the following errors.

syntax error near unexpected token `$temp=ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1 $i'

./ffmpeg_Linux_script_with variable.sh: line 4: =: command not found

./ffmpeg_Linux_script_with variable.sh: line 5: =: command not found

[NULL @ 0x30ab980] Unable to find a suitable output format for 'medium'

Can you suggest what's wrong with the above script.

Sent from my LM-G710 using Tapatalk
 
Top Bottom