使用 MEncoder 在 Windows 环境下转换视频
官方网站:http://www.mplayerhq.hu
svn://svn.mplayerhq.hu/mplayer/trunk
核心程序:MPlayer 1.0pre8 Windows build
编码库:
Windows x86 20060611
Windows 下的操作外壳程序:winmenc.exe
参考文档
Encoding with MEncoder
http://www.mplayerhq.hu/DOCS/HTML/en/encoding-guide.html
官方的命令行参数指南
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html
用mencoder转换flv时如何控制视频品质
http://www.flashcom.com.cn/bbs/showthread.php?t=2206
转换成 flv 文件需要使用到 ffmpeg 的 libavcodec
参数示例:
mencoder "d:\wwwroot\video\MP4 测试.MP4" -o "d:\wwwroot\output.flv" -of lavf
-oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts
vcodec=flv:vbitrate=256:vb_strategy=1:mbd=2:mv0:v4mv:cmp=6:trell:cbp:dia=4:last_pred=3
-vf scale=320:240,expand=320:240:::1,crop=320:240:0:0 -ofps 24 -srate 22050
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
转换到flv格式
输出参数配置
Audio Codec:MPEG-2 Layer 3
Audio Info:22050Hz 56 kb/s (1 chnl)
Video Codec:FLV1 (Flash Video)
Frame:24
Size:320 x 240
SAP:1.333 (4:3)
Bitrate:256kbp/s
MEncoder Options
编码库指定 -of lavf
音频编码 -oac mp3lame
音频编码参数 -lameopts abr:br=56 #使用平均比特率,设置为56kbps
视频编码 -ovc lavc
视频编码参数 -lavcopts
vcodec=flv:vbitrate=256:vb_strategy=1:mbd=2:mv0:v4mv:cmp=6:trell:cbp:dia=4:last_pred=3
vcodec:
vbitrate: Specify bitrate
(default: 800)
vb_strategy=<0 - 2> (pass one
only) : strategy to choose between I/P/B-frames
mbd=<0 - 2>: Macroblock decision
algorithm (high quality mode), encode each macro block in all modes and
choose the best. This is slow but results in better quality and file
size
mv0: Try to encode each MB with
MV=<0,0> and choose the better one. This has no effect if mbd=0.
v4mv: Allow 4 motion vectors per
macroblock (slightly better quality). Works better if used with mbd>0.
cmp=<0 - 2000>: Sets the
comparison function for full pel motion estimation (default: 0)
trell: Trellis searched
quantization. This will find the optimal encoding for each 8x8 block.
cbp: Rate distorted optimal coded
block pattern. Will select the coded block pattern which minimizes
distortion + lambda*rate. This can only be used together with trellis
quantization.
dia=<-99 - 6>: Diamond type &
size for motion estimation.
last_pred=<0 - 99>: amount of
motion predictors from the previous frame
输出视频格式 -vf scale=320:240,expand=320:240:::1,crop=320:240:0:0
#视频缩放、延展和剪切设置
输出视频帧数 -vfps 24
音频采样率 -srate 22050
可以转换的格式
MP4 - MPEG4 Codec
AVI - AVI DivX5 Codec
MOV - H264 Codec
WMV - WMV1/2/9
ASF - 无法重新定位,不知道长度
转换完成的视频文件截图
使用 ffmpeg 来进行视频文件截图
参数
ffmpeg -an -y -t 0:0:00.001 -i d:\wwwroot\video\output.flv -f image2 d:\wwwroot\video\output.jpg
-ss 起始时刻
-t 持续时间
-f image2 保存为图像文件
遇到的问题
关于 B-frames 的问题
增加 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
对转换的视频会造成什么影响还不清楚
flv 文件 Meta 信息的问题