Re-encoding video library in x265 (HEVC) with no quality loss
64
votes
3
answers
154699
views
I am trying to convert my video library to HEVC format to gain space. I ran the following command on all of the video files in my library:
#!/bin/bash
for i in *.mp4;
do
#Output new files by prepending "X265" to the names
avconv -i "$i" -c:v libx265 -c:a copy X265_"$i"
done
Now, most videos convert fine and the quality is the same as before. However, a few videos which are of very high quality (e.g. one movie print which is of 5GB) loses quality -- the video is all pixelated.
I am not sure what to do in this case. Do I need to modify the
crf
parameter in my command line? Or something else?
The thing is, I am doing a bulk conversion. So, I need a method where avconv
automatically adjusts whatever parameter needs adjustment, for each video.
### UPDATE-1
I found that crf
is the knob I need to adjust. The default CRF is 28. For better quality, I could use something less than 28. For example:
avconv -i input.mp4 -c:v libx265 -x265-params crf=23 -c:a copy output.mp4
However, the problem is that for some videos CRF value of 28 is good enough, while for some videos, lower CRF is required. This is something which I have to check manually by converting small sections of the big videos. But in bulk conversion, how would I check each video manually? Is their some way that avconv
can adjust CRF according to the input video intelligently?
### UPDATE-2
I found that there is a --lossless
option in x265: http://x265.readthedocs.org/en/default/lossless.html .
However, I don't know how to use it correctly. I tried using it in the following manner but it yielded opposite results (the video was even more pixelated):
avconv -i input.mp4 -c:v libx265 -x265-params lossless -c:a copy output.mp4
Asked by shivams
(4685 rep)
Sep 20, 2015, 02:26 AM
Last activity: Oct 22, 2020, 01:26 PM
Last activity: Oct 22, 2020, 01:26 PM