使用ffmpeg.exe进行转码参数说明
使用ffmpeg.exe进行转码参数说明
摘自:https://blog.csdn.net/coloriy/article/details/47337641
本文主要介绍如何使用ffmpeg.exe进行转码。编译好的ffmpeg可以从下面目录下载:
http://ffmpeg.org/download.html
首先,可以使用-formats命令,查看ffmpeg支持的封装格式。
下面截取一段:(D、E分别表示解复用和复用)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
File formats: D. = Demuxing supported .E = Muxing supported -- E 3g2 3GP2 (3GPP2 file format) E 3gp 3GP (3GPP file format) D 4xm 4X Technologies E a64 a64 - video for Commodore 64 D aac raw ADTS AAC (Advanced Audio Coding) DE ac3 raw AC-3 D act ACT Voice file format D adf Artworx Data Format D adp ADP E adts ADTS AAC (Advanced Audio Coding) DE adx CRI ADX D aea MD STUDIO audio D afc AFC DE aiff Audio IFF DE alaw PCM A-law D alias_pix Alias/Wavefront PIX image DE amr 3GPP AMR D anm Deluxe Paint Animation D apc CRYO APC D ape Monkey's Audio D apng Animated Portable Network Graphics D aqtitle AQTitle subtitles DE asf ASF (Advanced / Active Streaming Format) E asf_stream ASF (Advanced / Active Streaming Format) DE ass SSA (SubStation Alpha) subtitle DE ast AST (Audio Stream) |
可以使用-codecs命令,查看ffmpeg支持的编解码器,
ffmpeg输出格式如下:(D、E表示的解码器、编码器)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
Codecs: D..... = Decoding supported .E.... = Encoding supported ..V... = Video codec ..A... = Audio codec ..S... = Subtitle codec ...I.. = Intra frame-only codec ....L. = Lossy compression .....S = Lossless compression ------- D.VI.. 012v Uncompressed 4:2:2 10-bit D.V.L. 4xm 4X Movie D.VI.S 8bps QuickTime 8BPS video .EVIL. a64_multi Multicolor charset for Commodore 64 (encoders: a64multi ) .EVIL. a64_multi5 Multicolor charset for Commodore 64, extended with 5th color (colram) (encoders: a64multi5 ) D.V..S aasc Autodesk RLE D.VIL. aic Apple Intermediate Codec DEVI.S alias_pix Alias/Wavefront PIX image DEVIL. amv AMV Video D.V.L. anm Deluxe Paint Animation D.V.L. ansi ASCII/ANSI art D.V..S apng APNG (Animated Portable Network Graphics) image DEVIL. asv1 ASUS V1 DEVIL. asv2 ASUS V2 D.VIL. aura Auravision AURA D.VIL. aura2 Auravision Aura 2 D.V... avrn Avid AVI Codec DEVI.. avrp Avid 1:1 10-bit RGB Packer D.V.L. avs AVS (Audio Video Standard) video DEVI.. avui Avid Meridien Uncompressed DEVI.. ayuv Uncompressed packed MS 4:4:4:4 |
ffmpeg命令通常格式如下:
ffmpeg -i xxx out_file
常用的转换格式命令如下:
1. mpeg audio转pcm原始数据
ffmpeg -i cctv2_4101.mpa -f s16le -ar 48000 -acodec pcm_s16le cctv2-4101-Normal.pcm
2. jpg转yuv
jpeg -> yuv420
ffmpeg.exe -i input_file.jpg -pix_fmt yuv420p -y output_file.yuv -v 0
yuv -> jpeg
将大小为720x576的input_file.yuv原始数据另存为jpg格式
ffmpeg.exe -y -s 720x576 -i input_file.yuv -vcodec mjpeg output_file.jpg
3. 不同封装格式转换
3gp to avi
ffmpeg -i source.3gp -f avi -vcodec xvid -acodec mp3 -ar
22050 destination.avi
flv to 3gp
ffmpeg -i source.flv -s 176×144 -vcodec h263 -r 25 -b 200
-ab 64 -acodec mp3 -ac 1 -ar 8000 destination.3gp
flv to mp4
ffmpeg -i source.flv -vcodec h264 -r 25 -b 200 -ab 128
-acodec mp3 -ac 2 -ar 44100 destination.mp3
avi to mp4
ffmpeg -i source.avi -f psp -r 29.97 -b 768k -ar 24000 -ab
64k -s 320×240 destination.mp4
mp4 to 3gp
ffmpeg -i source.mp4 -s 176×144 -vcodec h263 -r 25 -b 12200
-ab 12200 -ac 1 -ar 8000 destination.3gp
avi to 3gp
ffmpeg -i source.avi-s qcif -vcodec h263 -acodec mp3 -ac 1
-ar 8000 -r 25 -ab 32 -y destination.3gp
mpg to 3gp
ffmpeg -i source.mpg -s qcif -vcodec h263 -acodec mp3 -ac 1
-ar 8000 -ab 32 -y destination.3gp
4. yuv转h264 raw/TS
ffmpeg.exe -s 352x288 -pix_fmt yuv420p -i test_352x288.yuv -vcodec libx264 out.h264
(若输出文件改为out.ts,即可实现yuv转ts)
以下简单总结下ffmpeg命令参数:
-i 指定要转换视频的源文件
-s 视频转换后视频的分辨率
-vcodec 视频转换时使用的编解码器(-codecs)
-r 视频转换换的桢率(默认25桢每秒)
-b 视频转换换的bit率
-ab 音频转换后的bit率(默认64k)
-acodec 制度音频使用的编码器(-codecs)
-ac 制定转换后音频的声道
-ar 音频转换后的采样率