Your ffmpeg
has not been configured with --enable-gpl
and --enable-libx264
which are required to support encoding with libx264.
参看:wiki -- ffmpeg
上一篇已讲将了 ffmpeg 的安装说明,接一下来讲一下我们要实现的功能,将 jpeg 转成 mp4.
参看:使用ffmpeg将jpeg转成mp4
参看:FFmpeg and H.264 Encoding Guide
本版本使用的是 ffmpeg-3.3.1
# ./ffmpeg -f image2 -i ../jpg/IMG_3870.jpg -vcodec libx264 -b:v 200k -r 10 -s 640x480 -acodec libfaac -y single_jpg.mp4
ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --prefix=/usr/local/ffmpeg
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
Input #0, image2, from '../jpg/IMG_3870.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 2592x1728, 25 tbr, 25 tbn, 25 tbc
Unknown encoder 'libx264'
上述出现错误信息 Unknown encoder 'libx264'
查看原因,参看:“Unknown encoder libx264” on Windows
Your |
一开始的配置只是简单的:(后面会在 ffmpeg再学习 -- 安装说明 更改的)
# ./configure --enable-shared --prefix=/usr/local/ffmpeg
如果按照上面的提示修改配置:
# ./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264
ERROR: libx264 not found
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
[email protected] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.
又会出现错误 ERROR: libx264 not found
查看原因,参看:How to resolve “ERROR: libx264 not found”?
Make sure your $ADDI_CFLAGS variable (which you pass in |
查看config.log,详细信息如下:
check_lib stdint.h x264.h x264_encoder_encode -lx264
check_func_headers stdint.h x264.h x264_encoder_encode -lx264
check_ld cc -lx264
check_cc
BEGIN /tmp/ffconf.SkjtKMss.c
1 #include
2 #include
3 #include
4 long check_x264_encoder_encode(void) { return (long) x264_encoder_encode; }
5 int main(void) { int ret = 0;
6 ret |= ((intptr_t)check_x264_encoder_encode) & 0xFFFF;
7 return ret; }
END /tmp/ffconf.SkjtKMss.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -std=c99 -fomit-frame-pointe r -pthread -c -o /tmp/ffconf.bfZpW8gZ.o /tmp/ffconf.SkjtKMss.c
/tmp/ffconf.SkjtKMss.c:2:18: fatal error: x264.h: No such file or directory
compilation terminated.
ERROR: libx264 not found
最后结论即,只要在配制 configure 时,添加额外的 include/link 路径应该能够解决问题。
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
巴特,我使用的 Ubuntu 上未安装 x264,需要下载安装:
参看:ffmpeg x264安装
下载:(git clone 文件下载到当前的目录下)
# git clone http://git.videolan.org/git/x264.git
进入 x264 文件,进行配置、编译
进入x264 文件
cd x264
配置:
# ./configure --enable-shared --enable-static --disable-asm
编译:
首先执行(时间比较长,需耐心等待几分钟)
# make
再执行:
# make install
查看:
# ls /usr/local/lib/
libjpeg.la libjpeg.so.62 libmp3lame.a libmp3lame.so libmp3lame.so.0.0.0 libx264.so pkgconfig site_ruby
libjpeg.so libjpeg.so.62.0.0 libmp3lame.la libmp3lame.so.0 libx264.a libx264.so.150 python2.7
# ls /usr/local/include/
jconfig.h jerror.h jmorecfg.h jpeglib.h x264_config.h x264.h
然后,不知道你有没有注意到,其实我耍懒了。音频的 mp3lame 和 faac 没有下载安装配置。
如果需要的话,其实还是有必要再重新 参看:ffmpeg x264安装 下载安装配置一下的。
趁现在有时间,还是将其安装上吧,以后可能会用到。
后续,还有一些其他需要安装的,参看:Compile FFmpeg on CentOS
(1)安装配置 facc (实际不需要安装,ffmpeg已删除它了)
下载:facc 下载
配置:
./configure --enable-shared --enable-static
编译:
首先执行:
# make
出现错误:
make[3]: 正在进入目录 `/home/tarena/project/jpg to mp4/faac-1.28/common/mp4v2'
if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../include -Wall -g -O2 -MT 3gp.o -MD -MP -MF ".deps/3gp.Tpo" -c -o 3gp.o 3gp.cpp; \
then mv -f ".deps/3gp.Tpo" ".deps/3gp.Po"; else rm -f ".deps/3gp.Tpo"; exit 1; fi
In file included from mp4common.h:29:0,
from 3gp.cpp:28:
mpeg4ip.h:126:58: 错误: 对‘char* strcasestr(const char*, const char*)’的新声明
/usr/include/string.h:369:28: 错误: 使旧的声明‘const char* strcasestr(const char*, const char*)’出现歧义
make[3]: *** [3gp.o] 错误 1
make[3]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28/common/mp4v2'
make[2]: *** [all-recursive] 错误 1
make[2]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28/common'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/home/tarena/project/jpg to mp4/faac-1.28'
make: *** [all] 错误 2
解决方法:
将 faac-1.28/common/mp4v2/mpeg4ip.h 第 123行~129行,进行如下修改:
修改前:
#ifdef __cplusplus
extern "C" {
#endif
char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
修改后:
#ifdef __cplusplus
extern "C++" {
#endif
const char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
再执行:
# make install
(2)安装配置 mp3lame
下载:lame-3.99.5 下载
配置:
# ./configure --enable-shared --enable-static
编译:
首先执行:
# make
再执行:
# make install
出现错误:
/bin/bash: /home/tarena/project/jpg: No such file or directory
make[3]: *** [install-libLTLIBRARIES] 错误 127
make[3]:正在离开目录 `/home/tarena/project/jpg to mp4/lame-3.99.5/libmp3lame'
make[2]: *** [install-am] 错误 2
make[2]:正在离开目录 `/home/tarena/project/jpg to mp4/lame-3.99.5/libmp3lame'
make[1]: *** [install-recursive] 错误 1
make[1]:正在离开目录 `/home/tarena/project/jpg to mp4/lame-3.99.5/libmp3lame'
make: *** [install-recursive] 错误 1
原因是:/home/tarena/project/jpg 名字不一致,文件名我有空格不显示。重命名问题解决。
当配置改为:
./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-libfaac --enable-libmp3lame --disable-yasm
又会出错:
Unknown option "--enable-libfaac"
查看:./configure --help 未发现该选项,后来查看资料,显示已经删除 libfaac。
最后得出,配置应为:
./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-libmp3lame --disable-yasm
然后重新执行:
# ./ffmpeg -f image2 -i ../jpg/IMG_3870.jpg -vcodec libx264 -b:v 200k -r 10 -s 640x480 -acodec libfaac -y single_jpg.mp4
ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --disable-yasm
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, image2, from '../jpg/IMG_3870.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 2592x1728, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x8b81740] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x8b6ff60] using cpu capabilities: none!
[libx264 @ 0x8b6ff60] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 0x8b6ff60] 264 - core 150 r2829 d1fe6fd - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'single_jpg.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj444p(pc), 640x480, q=-1--1, 200 kb/s, 10 fps, 10240 tbn, 10 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 1 fps=0.0 q=32.0 Lsize= 43kB time=00:00:00.00 bitrate=3585959.2kbits/s speed=0.000289x
video:42kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.854943%
[libx264 @ 0x8b6ff60] frame I:1 Avg QP:34.43 size: 42425
[libx264 @ 0x8b6ff60] mb I I16..4: 0.8% 75.3% 23.8%
[libx264 @ 0x8b6ff60] final ratefactor: 48.61
[libx264 @ 0x8b6ff60] 8x8 transform intra:75.3%
[libx264 @ 0x8b6ff60] coded y,u,v intra: 94.6% 73.8% 20.7%
[libx264 @ 0x8b6ff60] i16 v,h,dc,p: 10% 10% 10% 70%
[libx264 @ 0x8b6ff60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 14% 24% 8% 8% 7% 8% 9% 12%
[libx264 @ 0x8b6ff60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 13% 18% 10% 10% 9% 8% 8% 9%
[libx264 @ 0x8b6ff60] kb/s:3394.00
生成并播放 single_jpg.mp4 文件(因为是I帧所以不会显示图像,跳帧)
# ./ffmpeg -f image2 -stream_loop 500 -i ../jpg/IMG_3870.jpg -vcodec libx264 -b:v 200k -r 10 -s 640x480 -acodec libfaac -y multi_jpg.mp4
ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --disable-yasm
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, image2, from '../jpg/IMG_3870.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 2592x1728, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x98336e0] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x9821f80] using cpu capabilities: none!
[libx264 @ 0x9821f80] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 0x9821f80] 264 - core 150 r2829 d1fe6fd - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'multi_jpg.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj444p(pc), 640x480, q=-1--1, 200 kb/s, 10 fps, 10240 tbn, 10 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 202 fps=2.3 q=20.0 Lsize= 344kB time=00:00:19.90 bitrate= 141.5kbits/s dup=0 drop=299 speed=0.225x
video:341kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.934512%
[libx264 @ 0x9821f80] frame I:1 Avg QP:23.69 size:133878
[libx264 @ 0x9821f80] frame P:51 Avg QP:22.63 size: 3985
[libx264 @ 0x9821f80] frame B:150 Avg QP:33.91 size: 74
[libx264 @ 0x9821f80] consecutive B-frames: 1.0% 0.0% 0.0% 99.0%
[libx264 @ 0x9821f80] mb I I16..4: 0.3% 53.3% 46.3%
[libx264 @ 0x9821f80] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 27.3% 0.2% 0.6% 0.0% 0.0% skip:71.9%
[libx264 @ 0x9821f80] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 8.6% 0.0% 0.0% direct: 0.0% skip:91.4% L0: 0.4% L1:99.6% BI: 0.0%
[libx264 @ 0x9821f80] final ratefactor: 23.26
[libx264 @ 0x9821f80] 8x8 transform intra:53.3% inter:47.0%
[libx264 @ 0x9821f80] coded y,u,v intra: 99.9% 94.2% 56.7% inter: 2.1% 2.1% 1.4%
[libx264 @ 0x9821f80] i16 v,h,dc,p: 0% 0% 75% 25%
[libx264 @ 0x9821f80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 14% 20% 8% 8% 7% 9% 8% 15%
[libx264 @ 0x9821f80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 10% 16% 10% 10% 10% 10% 11% 14%
[libx264 @ 0x9821f80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x9821f80] ref P L0: 84.6% 0.2% 11.1% 4.1%
[libx264 @ 0x9821f80] ref B L0: 80.7% 19.3%
[libx264 @ 0x9821f80] ref B L1: 75.6% 24.4%
[libx264 @ 0x9821f80] kb/s:137.88
# ./ffmpeg -f image2 -i ../jpg/%02d.jpg -vcodec libx264 -b:v 200k -r 10 -s 640x480 -acodec libfaac -y multi_jpg2.mp4
ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-shared --prefix=/usr/local/ffmpeg --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --disable-yasm
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, image2, from '../jpg/%02d.jpg':
Duration: 00:00:01.24, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 5184x3456, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x85e69a0] deprecated pixel format used, make sure you did set range correctly
No pixel format specified, yuvj444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x85d3b80] using cpu capabilities: none!
[libx264 @ 0x85d3b80] profile High 4:4:4 Predictive, level 2.2, 4:4:4 8-bit
[libx264 @ 0x85d3b80] 264 - core 150 r2829 d1fe6fd - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'multi_jpg2.mp4':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj444p(pc), 640x480, q=-1--1, 200 kb/s, 10 fps, 10240 tbn, 10 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[swscaler @ 0x85e66c0] deprecated pixel format used, make sure you did set range correctly 0x
frame= 14 fps=1.1 q=48.0 Lsize= 63kB time=00:00:01.10 bitrate= 471.5kbits/s dup=0 drop=17 speed=0.0895x
video:62kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.496486%
[libx264 @ 0x85d3b80] frame I:1 Avg QP:27.12 size: 29594
[libx264 @ 0x85d3b80] frame P:9 Avg QP:44.71 size: 3723
[libx264 @ 0x85d3b80] frame B:4 Avg QP:40.50 size: 20
[libx264 @ 0x85d3b80] consecutive B-frames: 57.1% 14.3% 0.0% 28.6%
[libx264 @ 0x85d3b80] mb I I16..4: 8.8% 69.6% 21.6%
[libx264 @ 0x85d3b80] mb P I16..4: 19.2% 52.2% 2.9% P16..4: 0.7% 0.1% 0.0% 0.0% 0.0% skip:25.0%
[libx264 @ 0x85d3b80] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0:50.0% L1:50.0% BI: 0.0%
[libx264 @ 0x85d3b80] final ratefactor: 42.18
[libx264 @ 0x85d3b80] 8x8 transform intra:70.1% inter:90.5%
[libx264 @ 0x85d3b80] coded y,u,v intra: 33.1% 27.8% 18.6% inter: 0.3% 0.5% 0.4%
[libx264 @ 0x85d3b80] i16 v,h,dc,p: 25% 39% 18% 18%
[libx264 @ 0x85d3b80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 23% 33% 5% 5% 4% 6% 3% 5%
[libx264 @ 0x85d3b80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 22% 15% 7% 7% 6% 7% 5% 6%
[libx264 @ 0x85d3b80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x85d3b80] ref P L0: 69.1% 17.3% 9.9% 3.7%
[libx264 @ 0x85d3b80] ref B L0: 33.3% 66.7%
[libx264 @ 0x85d3b80] kb/s:361.03
生成并播放 multi_jpg2.mp4 文件:
%d就是普通的输出了
%2d是将数字按宽度为2,采用右对齐方式输出,若数据位数不到2位,则左边补空格
%02d,和%2d差不多,只不过左边补0
%.2d没见过,但从执行效果来看,和%02d一样
#!/bin/sh
i=1;
for img in `ls *.jpg`;
do mv $img `printf %.2d $i`.jpg;
i=`expr $i + 1`;
done
./ffmpeg -f image2 -i ../jpg/%02d.jpg -vcodec libx264 -b:v 200k -r 10 -s 640x480 -acodec libfaac -y multi_jpg2.mp4
安装说明里都有的,参看:ffmpeg再学习 -- 安装说明-f: 格式
-i:文件
-vcodec:视频编解码器
-b:视频比特率 ( 请使用- b:v )
-r:设置帧率 ( Hz 值,分数或缩写)
-s:设置帧大小 ( WxH 或缩写)
-acodec:音频编解码器 (“复制”复制流 )
-y:覆盖输出文件
帧率是、帧大小,参看:ffmpeg-比特率,帧率和文件大小./ffmpeg -f image2 -i ../jpg/%02d.jpg -vcodec libx264 -s 1920x1080 multi_jpg2.mp4
查看视频信息:
# ./mp4info multi_jpg2.mp4
/home/tarena/project/mp4v2/mp4v2-2.0.0/.libs/lt-mp4info version 2.0.0
multi_jpg2.mp4:
Track Type Info
1 video H264 Unknown Profile f4@4, 3.160 secs, 32411 kbps, 1920x1080 @ 25.000000 fps
Encoded with: Lavf57.71.100