前言 我们基于WIN11+WSL2+UBUNTU的方式搭建开发环境,搭建过程可以网上搜索,这里不再赘述。需要安装必要的工具,比如sudo apt-get install gcc-aarch64-linux-gnu等。
PC端git clone https://github.com/FFmpeg/FFmpeg.git/
cd FFmpeg/
make clean
./configure --disable-x86asm --prefix=/home/lhj/opt/ffmpeg/win --enable-shared
make -j8
make install
安装位于/home/lhj/opt/ffmpeg/win
包括库,头文件
lhj@lhj:~/FFmpeg$ ls /home/lhj/opt/ffmpeg/win
bin include lib share
生成了两个工具位于/home/lhj/opt/ffmpeg/win/bin/下
lhj@lhj:~/FFmpeg$ ls /home/lhj/opt/ffmpeg/win/bin/
ffmpeg ffprobe
我们看到没有生成ffplay,需要先安装SDL2,再重新构建。
sudo apt-get install libsdl2-2.0
sudo apt-get install libsdl2-dev
此时生成了ffplay
lhj@lhj:~/FFmpeg$ ls /home/lhj/opt/ffmpeg/win/bin/
ffmpeg ffplay ffprobe
sudo vi /etc/profile 添加路径
PATH=$PATH:/home/lhj/opt/ffmpeg/win/bin
PATH=$PATH:/home/lhj/opt/ffmpeg/win/lib
source /etc/profile
sudo cp ~/opt/ffmpeg/win/lib/* /usr/lib
就可以使用ffmpeg,ffplay,ffprobe三个工具了。
开发板端由于开发板运行了Ubuntu20系统,且已经联网支持apt-get安装各种包。
且开发板性能足够,所以可以直接在开发板上构建。
sudo apt-get update
sudo apt-get upgrade
git clone https://github.com/FFmpeg/FFmpeg.git/
cd FFmpeg/
sudo apt-get install libsdl2-2.0
sudo apt-get install libsdl2-dev
./configure --prefix=/root/opt/ffmpeg
make -j4
make install
生成文件位于
root@ok3588:~/FFmpeg# ls /root/opt/ffmpeg/
bin include lib share
cp /root/opt/ffmpeg/bin/* /usr/bin/
cp /root/opt/ffmpeg/lib/lib* /usr//lib
cp -rf /root/opt/ffmpeg/include/* /usr/include/
性能测试
PC端wget https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_10mb.mp4
ffmpeg -benchmark -i big_buck_bunny_720p_10mb.mp4 -f null -
- lhj@lhj:~$ ffmpeg -benchmark -i big_buck_bunny_720p_10mb.mp4 -f null -
- ffmpeg version N-109734-g806ecace91 Copyright (c) 2000-2023 the FFmpeg developers
- built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
- configuration: --disable-x86asm
- libavutil 57. 44.100 / 57. 44.100
- libavcodec 59. 60.100 / 59. 60.100
- libavformat 59. 37.100 / 59. 37.100
- libavdevice 59. 8.101 / 59. 8.101
- libavfilter 8. 56.100 / 8. 56.100
- libswscale 6. 8.112 / 6. 8.112
- libswresample 4. 9.100 / 4. 9.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_720p_10mb.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- creation_time : 1970-01-01T00:00:00.000000Z
- encoder : Lavf53.24.2
- Duration: 00:01:02.31, start: 0.000000, bitrate: 1347 kb/s
- Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : VideoHandler
- vendor_id : [0][0][0][0]
- Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : SoundHandler
- vendor_id : [0][0][0][0]
- Stream mapping:
- Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
- Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
- Press [q] to stop, [?] for help
- Output #0, null, to 'pipe:':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf59.37.100
- Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : VideoHandler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.60.100 wrapped_avframe
- Stream #0:1(und): Audio: pcm_s16le, 48000 Hz, 5.1, s16, 4608 kb/s (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : SoundHandler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.60.100 pcm_s16le
- frame= 1557 fps=0.0 q=-0.0 Lsize=N/A time=00:01:02.29 bitrate=N/A speed=64.1x
- video:730kB audio:35052kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
- bench: utime=5.487s stime=0.943s rtime=1.000s
- bench: maxrss=94516kB
复制代码
开发板端wget https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_10mb.mp4
ffmpeg -benchmark -i big_buck_bunny_720p_10mb.mp4 -f null -
- root@ok3588:~# ffmpeg -benchmark -i big_buck_bunny_720p_10mb.mp4 -f null -
- ffmpeg version N-109968-gcc76e8340d Copyright (c) 2000-2023 the FFmpeg developers
- built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
- configuration: --prefix=/root/opt/ffmpeg
- libavutil 58. 3.100 / 58. 3.100
- libavcodec 60. 6.100 / 60. 6.100
- libavformat 60. 4.100 / 60. 4.100
- libavdevice 60. 2.100 / 60. 2.100
- libavfilter 9. 4.100 / 9. 4.100
- libswscale 7. 2.100 / 7. 2.100
- libswresample 4. 11.100 / 4. 11.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_720p_10mb.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- creation_time : 1970-01-01T00:00:00.000000Z
- encoder : Lavf53.24.2
- Duration: 00:01:02.31, start: 0.000000, bitrate: 1347 kb/s
- Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : VideoHandler
- vendor_id : [0][0][0][0]
- Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : SoundHandler
- vendor_id : [0][0][0][0]
- Stream mapping:
- Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
- Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
- Press [q] to stop, [?] for help
- Output #0, null, to 'pipe:':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf60.4.100
- Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : VideoHandler
- vendor_id : [0][0][0][0]
- encoder : Lavc60.6.100 wrapped_avframe
- Stream #0:1(und): Audio: pcm_s16le, 48000 Hz, 5.1, s16, 4608 kb/s (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : SoundHandler
- vendor_id : [0][0][0][0]
- encoder : Lavc60.6.100 pcm_s16le
- frame= 1557 fps=749 q=-0.0 Lsize=N/A time=00:01:02.29 bitrate=N/A speed=29.9x
- video:730kB audio:35052kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
- bench: utime=10.268s stime=0.513s rtime=2.106s
- bench: maxrss=55708kB
- root@ok3588:~#
复制代码
可以看到基本是PC端一半的速度左右
PC端是12th Gen Intel(R) Core(TM) i5-12500H 2.50 GHz处理器.
可以看到开发板的性能几乎可以匹敌桌面级CPU了。
Ffprobe使用
- root@ok3588:~# ffprobe big_buck_bunny_720p_10mb.mp4
- ffprobe version N-109968-gcc76e8340d Copyright (c) 2007-2023 the FFmpeg developers
- built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
- configuration: --prefix=/root/opt/ffmpeg
- libavutil 58. 3.100 / 58. 3.100
- libavcodec 60. 6.100 / 60. 6.100
- libavformat 60. 4.100 / 60. 4.100
- libavdevice 60. 2.100 / 60. 2.100
- libavfilter 9. 4.100 / 9. 4.100
- libswscale 7. 2.100 / 7. 2.100
- libswresample 4. 11.100 / 4. 11.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny_720p_10mb.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- creation_time : 1970-01-01T00:00:00.000000Z
- encoder : Lavf53.24.2
- Duration: 00:01:02.31, start: 0.000000, bitrate: 1347 kb/s
- Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : VideoHandler
- vendor_id : [0][0][0][0]
- Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
- Metadata:
- creation_time : 1970-01-01T00:00:00.000000Z
- handler_name : SoundHandler
- vendor_id : [0][0][0][0]
- root@ok3588:~#
复制代码
ffprobe -show_data big_buck_bunny_720p_10mb.mp4
ffprobe -show_packets big_buck_bunny_720p_10mb.mp4
ffprobe -show_format big_buck_bunny_720p_10mb.mp4
ffprobe -show_frames big_buck_bunny_720p_10mb.mp4
总结 以上实现了ffmpeg开发环境的搭建,得益于开发板强劲的性能,运行了Ubuntu20系统,且支持apt安装包,所以可以直接在开发板上构建,避免了繁琐的交叉编译,构建速度也和PC上差不太多。和PC端对比性能测试看到基本是PC端性能的一半,可以看到是非常强悍的,基本可以作为开发PC来使用了。
0