ffmpeg 命令转vp9

mp4转vp9

./ffmpeg -i test.mp4 -pix_fmt yuv420p10le -c:v libvpx-vp9 -b:v 0 -crf 31 -speed 1 -quality good -static-thresh 4  -lag-in-frames 25  -f webm out.webm

yuv转vp9,需要指定yuv的高宽

//转vp9
./ffmpeg -pix_fmt yuv420p -s 704*576  -i  out.yuv  -c:v libvpx-vp9  -speed 4 -static-thresh 4  -lag-in-frames 25  -f webm out_vp9.webm

//转vp8
./ffmpeg -pix_fmt yuv420p -s 704*576  -i  out.yuv  -c:v libvpx  -speed 4 -static-thresh 4  -lag-in-frames 20  -f webm out_vp8.webm

 

VP9 Encoding Guide

Last Modified: 2016-05-18

Examples given are for 2-pass VP9 encoding with FFMpeg. Ensure that your FFMpeg has been built with libvpx support.

 

VOD Recommended Settings

ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 8 -speed 4 \
  -tile-columns 6 -frame-parallel 1 \
  -an -f webm /dev/null



ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 8 -speed 1 \
  -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  -c:a libopus -b:a 64k -f webm out.webm
c:v libvpx-vp9 tells FFmpeg to encode the video in VP9.

c:a libopus tells FFmpeg to encode the audio in Opus.

b:v 1000K tells FFmpeg to encode the video with a target of 1000 kilobits.

b:a 64k tells FFmpeg to encode the audio with a target of 64 kilobits.

Most of the current VP9 decoders use tile-based, multi-threaded decoding. In order for the decoders to take advantage of multiple cores, the encoder must set tile-columns and frame-parallel.

Setting auto-alt-ref and lag-in-frames >= 12 will turn on VP9's alt-ref frames, a VP9 feature that enhances quality.

speed 4 tells VP9 to encode really fast, sacrificing quality. Useful to speed up the first pass.

speed 1 is a good speed vs. quality compromise. Produces output quality typically very close to speed 0, but usually encodes much faster.

Multi-threaded encoding may be used if -threads > 1 and -tile-columns > 0.

 

DASH Recommended Settings

 

See http://wiki.webmproject.org/adaptive-streaming/instructions-to-playback-adaptive-webm-using-dash for WebM DASH settings.

Best Quality (Slowest) Recommended Settings

ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1000K -threads 1 -speed 4 \
  -tile-columns 0 -frame-parallel 0 \
  -g 9999 -aq-mode 0 -an -f webm /dev/null



ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1000K -threads 1 -speed 0 \
  -tile-columns 0 -frame-parallel 0 -auto-alt-ref 1 -lag-in-frames 25 \
  -g 9999 -aq-mode 0 -c:a libopus -b:a 64k -f webm out.webm
tile-columns 0frame-parallel 0: Turning off tile-columns and frame-parallel should give a small bump in quality, but will most likely hamper decode performance severely.

Constant Quality Recommended Settings

 

Objective is to achieve a constant (perceptual) quality level without regard to bitrate.

(Note that Constant Quality differs from Constrained Quality, described below.)

ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 0 -crf 33 -threads 8 -speed 4 \
  -tile-columns 6 -frame-parallel 1 \
  -an -f webm /dev/null



ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 0 -crf 33 -threads 8 -speed 2 \
  -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  -c:a libopus -b:a 64k -f webm out.webm

 

crf is the quality value (0-63 for VP9). To trigger this mode, you must use a combination of crf <q-value> and b:v 0bv MUST be 0.

Constrained Quality Recommended Settings

 

Objective is to achieve a constant (perceptual) quality level as long as the bitrate achieved is below a specified upper bound. Constrained Quality is useful for bulk encoding large sets of videos in a generally consistent fashion.

ffmpeg -i <source> -c:v libvpx-vp9 -pass 1 -b:v 1400K -crf 23 -threads 8 -speed 4 \
  -tile-columns 6 -frame-parallel 1 \
  -an -f webm /dev/null



ffmpeg -i <source> -c:v libvpx-vp9 -pass 2 -b:v 1400K -crf 23 -threads 8 -speed 2 \
  -tile-columns 6 -frame-parallel 1 -auto-alt-ref 1 -lag-in-frames 25 \
  -c:a libopus -b:a 64k -f webm out.webm

 

The quality desired is provided as the crf <q-value> parameter and the bitrate upper bound is provided as the b:v <bitrate> parameter, where bitrate MUST be non-zero.

Both crf <q-value> and b:v <bitrate> MUST be provided. In this mode, bitrate control will kick in for difficult videos, where the quality specified cannot be achieved within the given bitrate.

For easy videos, this mode behaves exactly like the constant quality mode, and the actual bitrate achieved can be much lower than the specified bitrate in the b:v parameter.

One caveat in FFMpeg is that if you do not provide the b:v parameter, FFMpeg will assume a default target bitrate of 256K -- so the constrained quality mode will be triggered with a potentially very low target bitrate.

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值