Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
6th December 2021, 17:35 | #1 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
Encoding errors from ffmpeg x265 pass 2 which succeeded in pass 1.
Hi I am Rupesh from India 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. Regards, Rupesh. Sent from my LM-G710 using Tapatalk |
6th December 2021, 19:10 | #3 | Link |
Registered User
Join Date: Nov 2004
Location: Poland
Posts: 2,843
|
What if you do this:
...-x265-params pass=1 -an -f null - && You don't need 2 pass encode. Do 1 pass just add -crf 24 to control bitrate. If you see encoder produces too high bitrate (compared to source) raise crf value. Last edited by kolak; 6th December 2021 at 19:16. |
9th December 2021, 14:01 | #5 | Link |
Pig on the wing
Join Date: Mar 2002
Location: Finland
Posts: 5,718
|
You'll want to read this: https://x265.readthedocs.io/en/stable/cli.html
I'd use main10 profile and preset slower or slow for better quality.
__________________
And if the band you're in starts playing different tunes I'll see you on the dark side of the Moon... |
10th December 2021, 05:43 | #8 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
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 Last edited by rupeshforu3; 10th December 2021 at 05:46. |
10th December 2021, 06:20 | #9 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,750
|
Quote:
2-pass VBR encoding would improve quality of a fixed bitrate, if you actually need that. |
|
10th December 2021, 08:06 | #10 | Link | |
Registered User
Join Date: Mar 2021
Posts: 86
|
Quote:
See the following link which is similar to my need. https://stackoverflow.com/questions/...ere-a-shortcut Sent from my LM-G710 using Tapatalk |
|
10th December 2021, 10:25 | #11 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
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 Last edited by rupeshforu3; 10th December 2021 at 10:28. |
16th December 2021, 22:30 | #12 | Link | |
Video Fanatic
Join Date: Jul 2021
Location: Surrey
Posts: 89
|
You seem to have made it overly complicated. The purpose you mention in another thread - to 'compress YouTube videos' - (not sure if VP9, AV1, H264) could be done with the GUIs you mention. Although for a very different purpose, I have a very simple macro set (I realise it's not ideal but it does the job - taking ~30GB of images and creating a video to work from).
Quote:
And why the "-cpucount 3" on a 4C CPU? It makes no sense. Also, the licence for fdk_aac is not clear for redistributing (you link to your script in another thread)...
__________________
PC: R9 5900X | 32GB 3600 MT/s RAM | 2*1TB NVMe | RTX 3080 | water-cooled NAS: SM 48-bay 240TB+ storage | Xeon 1220 | 32GB DDR4 ECC HTPC: Pentium J5005 | 16GB RAM | 256GB SSD | 15W Last edited by tonemapped; 16th December 2021 at 22:34. |
|
17th December 2021, 17:35 | #13 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
I have downloaded videos from youtube in android smartphone and after that I have transferred all the downloaded mp4 video files to my system.
There is an app called playtime which recursively shows all the properties of video files. For all files i have seen video codec as avc and so I thought that the source video files are in h264. While converting using ffmpeg tool i have seen many times as (H264)-->(h265) First I thought that h265 offers more compression at the same video bitrate of source h264 file. Suppose my source file size is 100 mb and with bitrate as 150 kbps. When crf 10 option is used the converted output video file size is 170 mb with video bitrate as 240 kbps. When crf 20 option is used the converted output video file size is 150 mb with video bitrate as 200 kbps. Here the lesson is as you give lowest crf value the more the output video file size is and if you give higher crf value the output video file size is lesser. I have given option cpucount value 3 because when I have not used it and while running ffmpeg tool all my four cpu cores are always running at 99 percent and producing more heat. If this process runs for one hour my cpu may totally burn. After giving cpu option 3 I am free as always the cpu runs at lower temperatures. I have used fdkaac codec and if you don't like use normal aac codec which is provided by default by all ffmpeg builds. My opinion is aac sound quality is not good than fdkaac. 2 pass encoding has lot of benifits regarding quality output video file at lowest possible size. Sent from my LM-G710 using Tapatalk |
17th December 2021, 17:51 | #14 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
I thought converting vp9 or anything else to x265 would reduce the output video file size a lot but it's not true.
There are other codecs like daala, av1 but I have not tried but I will try in future. Sent from my LM-G710 using Tapatalk |
19th December 2021, 16:19 | #15 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
Hi the main reason behind creating these scripts is to reduce the size group of video files. These scripts must be modified by people who are experts in video encoding concepts and distribute to others.
Upto now there are lot of guis for ffmpeg tool but there are no proper scripts. Using guis are not always recommend because you can't achieve what you want using them. For example in some guis you can't how much cpu resources you want to use. I have used upto 3 ffmpeg guis to compress the video file captured from android smartphone camera by giving video bitrate as 400 kbps in options window. The file has been compressed and after that I have opened the output video file in VLC media player and found that the image is stretched. I have not passed any option to stretch the image. Many of you have android smartphone and capture videos from camera. I have captured video from android smartphone of size 400 mb with length just 4 minutes. I have tried to compress this particular video file using ffmpeg gui but failed as the output video is stretched but I have used simple ffmpeg command and it compressed this particular video file to 6 mb by passing video bitrate as 400 kbps. The quality of both output video file and source file are almost same. Many of you asked what is the need of re encoding a video file with same parameters and my answer is I forgot to provide a script to compress video file at specific video bitrate. So I have uploaded new script to source forge. Let all of us collaborate and produce nice scripts to ffmpeg for our daily use. Sent from my LM-G710 using Tapatalk |
19th December 2021, 19:37 | #16 | Link | |||||||||||||
Video Fanatic
Join Date: Jul 2021
Location: Surrey
Posts: 89
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
__________________
PC: R9 5900X | 32GB 3600 MT/s RAM | 2*1TB NVMe | RTX 3080 | water-cooled NAS: SM 48-bay 240TB+ storage | Xeon 1220 | 32GB DDR4 ECC HTPC: Pentium J5005 | 16GB RAM | 256GB SSD | 15W |
|||||||||||||
20th December 2021, 11:32 | #17 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
Thanks for your suggestions.
I will try to stick to x265 and use staxrip. Is it possible to play av1 and daala video files in android. In the wikipedia pages of av1 and daala they said that video and audio are contained in mkv and ogg containers. I think that we can play any mkv video file and so av1 and daala can be played. Sent from my LM-G710 using Tapatalk Last edited by rupeshforu3; 20th December 2021 at 15:58. |
20th December 2021, 19:01 | #18 | Link |
Registered User
Join Date: Aug 2013
Posts: 191
|
For reference, PlayTime.
"Quickly calculate the total play time of a list of most any music or movie file. That was the original request. Due to further user requests, PlayTime has since been expanded to be a fairly complete front-end for the MediaInfo library." Last edited by therube; 20th December 2021 at 19:04. |
21st December 2021, 01:49 | #19 | Link | |
Video Fanatic
Join Date: Jul 2021
Location: Surrey
Posts: 89
|
Quote:
2. Android's supported formats are listed here: https://developer.android.com/guide/.../media-formats 3. Matroska is an excellent container with fairly wide support. Do you have a requirement for a different container? 4. Both AV1 and Daala are for video. Why do you want to use relatively unsupported (globally) formats when more mature options exist? Do you have hardware decoding for AV1 and Daala?
__________________
PC: R9 5900X | 32GB 3600 MT/s RAM | 2*1TB NVMe | RTX 3080 | water-cooled NAS: SM 48-bay 240TB+ storage | Xeon 1220 | 32GB DDR4 ECC HTPC: Pentium J5005 | 16GB RAM | 256GB SSD | 15W |
|
21st December 2021, 04:08 | #20 | Link |
Registered User
Join Date: Mar 2021
Posts: 86
|
I have downloaded sample av1 file with file extension.mp4 in my android smartphone and opened it in es file explorer and it is playing well without any errors.
I have seen the properties of the above file in media info tool of video file and seen av1 codec. aomedia is open source foundation for advanced video technologies. It's video codec is supported by all devices in the world. Visit the following link. https://aomedia.org/about/ Sent from my LM-G710 using Tapatalk Last edited by rupeshforu3; 21st December 2021 at 05:27. |
Thread Tools | Search this Thread |
Display Modes | |
|
|