【米尔MYD-YG2LX开发板】在多媒体应用场景的体验-从源码开始应用开发体验
<div class='showpostmsg'><h1><b>前言</b></h1><p >前面我们搭建了ffmpeg的开发环境,进行了ffmpeg性能测试,还演示了ffmepg进行网络推流视频播放。但是很多时候我们需要自定义开发,已经构建好的ffmpeg并不能满足我们的需求,这时我们就必须基于源码进行开发。本篇就进行基于ffmpeg的应用开发体验。</p>
<h1 ><b>准备</b></h1>
<p >前面搭建好的环境</p>
<h1 ><b>编码测试</b></h1>
<h2 ><b>代码</b></h2>
<p >以官方例程代码为例</p>
<p >位于FFmpeg/doc/examples/encode_video.c下</p>
<h2 ><b>编译</b></h2>
<div class="parsedown-markdown"> aarch64-linux-gnu-gcc doc/examples/encode_video.c -O3 -o ./encode_video -I/home/lhj/opt/ffmpeg/board/include/ -L/home/lhj/opt/ffmpeg/board/lib -lavcodec -lavutil -lswresample -lpthread -lm</div>
<p > </p>
<h2 ><b>运行</b></h2>
<p >导出到win下</p>
<p >cp encode_video /mnt/d </p>
<p >然后ssh或者串口登录开发板,rz导入到开发板的~目录下</p>
<div class="parsedown-markdown">
<p>chmod +x encode_video</p>
<p > ./encode_video encode.bin mpeg1video</p>
</div>
<p > </p>
<h2 ><b>结果</b></h2>
<div class="parsedown-markdown">
<p>root@myir-yg2lx:~# ./encode_video encode.bin mpeg1video</p>
<p >Send frame 0</p>
<p >Send frame 1</p>
<p >Write packet 0 (size= 6731)</p>
<p >Send frame 2</p>
<p >Write packet 2 (size= 3727)</p>
<p >Send frame 3</p>
<p >Write packet 1 (size= 1698)</p>
<p >Send frame 4</p>
<p >Write packet 4 (size= 2744)</p>
<p >Send frame 5</p>
<p >Write packet 3 (size= 1676)</p>
<p >Send frame 6</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 6 (size= 2955)</p>
<p >Send frame 7</p>
<p >Write packet 5 (size= 1810)</p>
<p >Send frame 8</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 8 (size= 3170)</p>
<p >Send frame 9</p>
<p >Write packet 7 (size= 1937)</p>
<p >Send frame 10</p>
<p >Write packet 10 (size=12306)</p>
<p >Send frame 11</p>
<p >Write packet 9 (size= 2173)</p>
<p >Send frame 12</p>
<p >Write packet 12 (size= 3770)</p>
<p >Send frame 13</p>
<p >Write packet 11 (size= 2064)</p>
<p >Send frame 14</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 14 (size= 3340)</p>
<p >Send frame 15</p>
<p >Write packet 13 (size= 1941)</p>
<p >Send frame 16</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 16 (size= 3121)</p>
<p >Send frame 17</p>
<p >Write packet 15 (size= 1897)</p>
<p >Send frame 18</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 18 (size= 3392)</p>
<p >Send frame 19</p>
<p >Write packet 17 (size= 2172)</p>
<p >Send frame 20</p>
<p >Write packet 20 (size=12266)</p>
<p >Send frame 21</p>
<p >Write packet 19 (size= 2169)</p>
<p >Send frame 22</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 22 (size= 4000)</p>
<p >Send frame 23</p>
<p >Write packet 21 (size= 2018)</p>
<p >Send frame 24</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p > warning, clipping 1 dct coefficients to -255..255</p>
<p >Write packet 24 (size= 3072)</p>
<p >Write packet 23 (size= 1935)</p>
<p >root@myir-yg2lx:~#</p>
</div>
<p > </p>
<p > </p>
<p >生成了encode.bin</p>
<div class="parsedown-markdown">
<p>root@myir-yg2lx:~# ls -al encode.bin </p>
<p >-rw-r--r-- 1 root root 88088 Jan 1 03:11 encode.bin</p>
</div>
<p > </p>
<p > </p>
<p >导出编码后文件到电脑</p>
<p >sz encode.bin</p>
<p > </p>
<p >播放</p>
<p > .\ffplay.exe .\encode.bin</p>
<div class="parsedown-markdown">
<p>PS D:\BaiduSyncdisk\ffmpeg-master-latest-win64-gpl-shared\bin> .\ffplay.exe .\encode.bin</p>
<p >ffplay version N-108711-g3141dbb7ad-20221018 Copyright (c) 2003-2022 the FFmpeg developers</p>
<p > built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)</p>
<p > configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20221018</p>
<p > libavutil 57. 39.101 / 57. 39.101</p>
<p > libavcodec 59. 51.100 / 59. 51.100</p>
<p > libavformat 59. 34.101 / 59. 34.101</p>
<p > libavdevice 59. 8.101 / 59. 8.101</p>
<p > libavfilter 8. 49.101 / 8. 49.101</p>
<p > libswscale 6. 8.112 / 6. 8.112</p>
<p > libswresample 4. 9.100 / 4. 9.100</p>
<p > libpostproc 56. 7.100 / 56. 7.100</p>
<p > Estimating duration from bitrate, this may be inaccurate</p>
<p >Input #0, mpegvideo, from '.\encode.bin':</p>
<p > Duration: 00:00:00.01, bitrate: 104851 kb/s</p>
<p > Stream #0:0: Video: mpeg1video, yuv420p(tv), 352x288 , 104857 kb/s, 25 fps, 25 tbr, 1200k tbn</p>
<p > 10.54 M-V: 0.008 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0</p>
</div>
<p > </p>
<p > </p>
<p > </p>
<h1 ><b>解码测试</b><b> </b></h1>
<h2 ><b>代码</b></h2>
<p >以官方例程代码为例</p>
<p >位于FFmpeg/doc/examples/decode_video.c下</p>
<p > </p>
<h2 ><b>编译</b></h2>
<div class="parsedown-markdown"> aarch64-linux-gnu-gcc doc/examples/decode_video.c -O3 -o ./decode_video -I/home/lhj/opt/ffmpeg/board/include/ -L/home/lhj/opt/ffmpeg/board/lib -lavcodec -lavutil -lswresample -lpthread -lm</div>
<p > </p>
<h2 ><b>运行</b></h2>
<p >导出到win下</p>
<p >cp decode_video /mnt/d </p>
<p >然后ssh或者串口登录开发板,rz导入到开发板的~目录下</p>
<div class="parsedown-markdown">
<p>chmod +x decode_video</p>
<p >./decode_video encode.bin decode.bin</p>
</div>
<p > </p>
<h2 ><b>结果</b></h2>
<div class="parsedown-markdown">
<p>root@myir-yg2lx:~# ./decode_video encode.bin decode.bin</p>
<p >saving frame 1</p>
<p >saving frame 2</p>
<p >saving frame 3</p>
<p >saving frame 4</p>
<p >saving frame 5</p>
<p >saving frame 6</p>
<p >saving frame 7</p>
<p >saving frame 8</p>
<p >saving frame 9</p>
<p >saving frame 10</p>
<p >saving frame 11</p>
<p >saving frame 12</p>
<p >saving frame 13</p>
<p >saving frame 14</p>
<p >saving frame 15</p>
<p >saving frame 16</p>
<p >saving frame 17</p>
<p >saving frame 18</p>
<p >saving frame 19</p>
<p >saving frame 20</p>
<p >saving frame 21</p>
<p >saving frame 22</p>
<p >saving frame 23</p>
<p >saving frame 24</p>
<p >saving frame 25</p>
<p >root@myir-yg2lx:~#</p>
</div>
<p > </p>
<p > </p>
<p >生成文件如下</p>
<div class="parsedown-markdown">
<p>root@myir-yg2lx:~# ls -al decode*</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-1</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-10</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-11</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-12</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-13</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-14</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-15</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-16</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-17</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-18</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-19</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-2</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-20</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-21</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-22</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-23</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-24</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-25</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-3</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-4</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-5</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-6</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-7</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-8</p>
<p >-rw-r--r-- 1 root root 101391 Jan 1 03:17 decode.bin-9</p>
<p >-rwxr-xr-x 1 root root 80663160 May 20 2023 decode_video</p>
<p >root@myir-yg2lx:~#</p>
</div>
<p > </p>
<p > </p>
<h1 ><b>总结</b></h1>
<p >以上从源码编译开始体验了基于ffmpeg的应用程序开发,可以看到基于开发板完备的运行环境和优异的性能,进行多媒体应用开发页变得很便捷。</p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>官方的源码编译的体验,对于基于ffmpeg的应用程序开发还是比较友好的</p>
66666666 <p>感谢楼主分享~~</p>
页:
[1]