x265探索与研究(四):怎样编码视频?

怎样编码视频?

 

        本文介绍x265中的两种编码视频方法,一是採用命令行的方法。二是GUI的方式。

 

1命令行的方法

 

(1)、第一种方式生成*.265格式的视频文件

 

        第一种方式能够生成*.265格式的视频文件,相应的命令为:

x265 --input-res 352x288 --fps 30 hall_cif_352x288_300.yuv -o hall_cif_352x288_300.h265

 

2)、另外一种方式能够生成*.bin格式的视频流文件

 

        另外一种方式能够生成*.bin格式的视频流文件,相应的命令为:

x265.exe --preset fast --input hall_cif_352x288_300.yuv --fps 30 --input-res 352x288 --output out.bin --psnr --ssim --bitrate 128

 

两种方式生成的相应文件例如以下图所看到的:



        除了这两种经測试能够使用的方式外。网址:http://x265.ru/en/encode/还提供了两种略有差别的命令行方式,例如以下图所看到的:


(3)、第三种命令行的方式,能够生成*.x265*.csv

 

        以下对其进行測试,第三种命令行的方式。能够生成*.x265*.csv相应的命令为:

x265.exe hall_cif_352x288_300.yuv --input-res 352x288 --fps 30 -o out.x265 --csv results.csv --no-rect --max-merge 3 --rd 0 --tu-intra-depth 2 --tu-inter-depth 1 --no-tskip --frame-threads 2

 

        须要注意的是:该方式输入的视频必须是YUVY4M格式。帧的宽和高也必须指定且FPS也必须设定。

測试步骤例如以下图:


        測试结果例如以下图:


(4)、第四种命令行方式输出是*.hevc格式

 

        该命令行的方式,输入是*.y4m的视频,能够获得高质量的*.hevc格式视频,相应的命令为:

x265.exe hall_cif_352x288_300.y4m --q 17 --merange 64 --frames all --ref 4 --max-merge 3 --rect-hash 2 --me 3 --b 6 --b-adapt 1 --rd 2 --rc-lookahead 60 --input-depth 16 --tu-inter-depth 3 --tu-intra-depth 3 --no-tskip-fast --wpp --subme 2 --s 32 --F 6 -o video.hevc

 

(注:因为我这边没有*.y4m格式视频,故没有測试,兴许測试,补充在此。


2GUI的方法

 

        採用“Baka Encoder”,下载网址:http://x265.ru/en/baka-encoder/



配置方式是改动Baka Encoder.config.xml,相应的代码例如以下所看到的:

<?xml version="1.0" encoding="utf-8"?>
<!-- Baka Encoder configuration file reference can be found at http://vtt.to/baka%20encoder%20configuration%20reference -->
<baka_encoder logging="0">
	<presets>
		<preset name="preview" suffix="_preview" on="1">
			<hint quality="7" compression="14" speed="6" streaming="1"/>
			<audio cmd="-br 60000"/>
			<video tool="x264" bit_depth="8" pass_count="2" max_width="480" max_height="360" resize_method="spline" base_bitrate="0" max_bitrate="0"
				cmd="--preset placebo --no-mbtree --ratetol 100.0 --keyint 60 --ref 3 --bitrate 500 --level 4.1 --vbv-bufsize 50000 --vbv-maxrate 62500"/>
			<muxing container="mp4" cmd=" --optimize-pd"/>
		</preset>
		<preset name="normal" suffix="_normal" on="1">
			<hint quality="11" compression="9" speed="3" streaming="1"/>
			<audio cmd="-q 0.6"/>
			<video tool="x264" bit_depth="8" pass_count="2" max_width="1280" max_height="960" resize_method="spline" base_bitrate="1500" max_bitrate="3500"
				cmd="--preset placebo --no-mbtree --ratetol 100.0 --keyint 60 --ref 4 --level 4.1 --vbv-bufsize 50000 --vbv-maxrate 62500"/>
			<muxing container="mp4" cmd=" --optimize-pd"/>
		</preset>
		<preset name="normal h265" suffix="_normal.h265" on="1">
			<hint quality="12" compression="9" speed="1" streaming="0"/>
			<audio cmd="-q 0.6"/>
			<video tool="x265" bit_depth="8" pass_count="2" max_width="1280" max_height="960" resize_method="spline" base_bitrate="1200" max_bitrate="10000"
				cmd="--preset slow --bframes 4 --ref 4"/>
			<muxing container="mp4" cmd=""/>
		</preset>
		<preset name="deluxe" suffix="_deluxe" on="0">
			<hint quality="14" compression="5" speed="4" streaming="0"/>
			<audio cmd="-q 1.0"/>
			<video tool="x264" bit_depth="10" pass_count="1" max_width="0" max_height="0" resize_method="" base_bitrate="0" max_bitrate="0"
				cmd="--crf 12 --preset placebo --no-mbtree --deblock 0:-1"/>
			<muxing container="mp4" cmd=""/>
		</preset>
		<preset name="deluxe h265" suffix="_deluxe.h265" on="0">
			<hint quality="15" compression="7" speed="1" streaming="0"/>
			<audio cmd="-q 1.0"/>
			<video tool="x265" bit_depth="10" pass_count="1" max_width="0" max_height="0" resize_method="" base_bitrate="0" max_bitrate="0"
				cmd="--crf 12 --preset slow"/>
			<muxing container="mp4" cmd=""/>
		</preset>
		<preset name="express" suffix="_express" on="0">
			<hint quality="7" compression="7" speed="10" streaming="0"/>
			<audio cmd="-q 0.5"/>
			<video tool="x264" bit_depth="8" pass_count="1" max_width="0" max_height="0" resize_method="" base_bitrate="1500" max_bitrate="5000"
				cmd="--preset fast --deblock 1:0 --bframes 4 --b-adapt 1 --rc-lookahead 36 --ref 3 --level 4.1 --vbv-bufsize 50000 --vbv-maxrate 62500"/>
			<muxing container="mp4" cmd=""/>
		</preset>
		<preset name="lossless" suffix="_lossless" on="0" console="0">
			<hint quality="16" compression="3" speed="8" streaming="0"/>
			<audio cmd="-q 1.0"/>
			<video tool="x264" bit_depth="8" pass_count="1" max_width="0" max_height="0" resize_method="spline" base_bitrate="0" max_bitrate="0"
				cmd="--crf 0 --preset placebo --log-level none --quiet"/>
			<muxing container="mp4" cmd=""/>
		</preset>
	</presets>
</baka_encoder>

大笑


【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/zhchoutai/p/8297213.html