WhyCan Forum

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132 (挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-09-29 16:18:49

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 7,862

解决搬瓦工(bwh)主机运行ffmpeg出错问题

/tmp# avconv -i gotest2.gif 1.mp4
avconv version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Dec  7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
Input #0, image2, from 'gotest2.gif':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: gif, pal8, 1914x1036, 25 tbn
avconv: common/cpu.c:248: x264_cpu_detect: Assertion `!(cpu&(0x0000040|0x0000080))' failed.
Aborted (core dumped)

离线

#2 2019-09-29 16:28:41

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 7,862

Re: 解决搬瓦工(bwh)主机运行ffmpeg出错问题

https://www.hostloc.com/thread-551858-1-1.html

各位大佬,小弟最近在研究KVS系统,因为不确定KVS是否能满足自己的需求,所以先购买了一个月的使用期,在搬瓦工上弄了个4G内存的VPS测试研究系统。

结果各种KVS需要的环境安装出错,无奈只能花了99美元请KVS的官方配置服务器,到了安装配置ffmpeg的时候KVS后台一直报错,KVS技术说是服务器CPU指令集权限不够,让我找VPS的技术支持要更高的指令集权限,然后搬瓦工那边又告诉我不能提供最高的CPU指令集权限。。。。WTF,前后各种花费快小两千了,结果现在一个完整的站点还没搭起来。。。请教各位大佬,有没有在搬瓦工上完整配置过ffmpeg的?系统是CentOS 7


具体报错的错误提示如下:

nice -n 4 /usr/bin/ffmpeg -y -i /home/admin/web/xxxx.com/public_html/admin/data/plugins/audit/test_video-11577847.tmp -vcodec libx264 -movflags +faststart -threads 0 -r 25 -g 50 -crf 25 -me_method hex -trellis 0 -bf 8 -acodec aac -strict -2 -ar 44100 -ab 128k -f mp4 /home/admin/web/xxxx.com/public_html/admin/data/plugins/audit/test_video-11577847_720p.mp4 2>&1: ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --extra-ldflags='-Wl,-z,relro ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, avi, from '/home/admin/web/xxxx.com/public_html/admin/data/plugins/audit/test_video-11577847.tmp':
Metadata:
encoder : Lavf52.78.3
Duration: 00:00:31.07, start: 0.000000, bitrate: 348 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 270 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 24k tbc
Stream #0:1: Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 64 kb/s
ffmpeg: common/cpu.c:251: x264_cpu_detect: Assertion `!(cpu&(0x0000040|0x0000080))' failed.


KVS技术跟我说如下:

Please ask your host support to switch the processor emulation mode on this server to host-passthrough , we need this for correct works of ffmpeg library.
We need this for ffmpeg, now we see error "ffmpeg: common/cpu.c:251: x264_cpu_detect: Assertion `!(cpu&(0x0000040|0x0000080))' failed." - that's easy to switch from "QEMU Virtual CPU version (cpu64-rhel6)" to " host-passthrough" or host support can't make this?



然后搬瓦工跟我说:

Unfortunately we are not able to offer host-passthrough cpuid at this time. Do you know what specific flag ffmpeg is looking for?


崩溃中。。。

离线

#3 2019-09-29 16:29:54

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 7,862

Re: 解决搬瓦工(bwh)主机运行ffmpeg出错问题

离线

#4 2019-09-29 16:31:26

晕哥
Administrator
注册时间: 2017-09-06
累计积分: 7,862

Re: 解决搬瓦工(bwh)主机运行ffmpeg出错问题

解决方案,重新编译 x264.tar.bz2 源码: https://minidevices.info/post_5818acedda427

x264_cpu_detect: Assertion `!(cpu&(0x0000040|0x0000080))' failed
Linux Ubuntu  /  Tweaks 




Sometimes ffmpeg users could meet following error message when decoding something using ffmpeg with x264 codec...

ffmpeg: common/cpu.c:248: x264_cpu_detect: Assertion `!(cpu&(0x00000400x0000080))' failed.

Or

ffmpeg: common/cpu.c:251: x264_cpu_detect: Assertion `!(cpu&(0x00000400x0000080))' failed.

This means that your CPU doesn't supports real hardware decoding, and could be slow during this process. Unfortunately bad developer guys decided to interrupt entire process if CPU doesn't support this feature. Even if you will re-compile ffmpeg from source - you will get this error message.

I spent few hours before understood how to fight and win this problem.


So, let's compile ffmpeg from scratch using Ubuntu (other distro could be different with package names, but process of compilation is the same):


1. Install required packages. apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev
  libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev
  libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev yasm


2. mkdir ~/ffmpeg_sources

3. cd ~/ffmpeg_sources

4. Compile x264 codec: wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2

tar xjvf last_x264.tar.bz2
cd x264-snapshot*
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --disable-opencl


Now, and this is urgent, we must open .c file and make few bad things into code: vi common/cpu.c

We should find part of code similar to this:

if( model == 9 model == 13 model == 14 )
            {
                cpu &= ~(X264_CPU_SSE2X264_CPU_SSE3);
                assert(!(cpu&(X264_CPU_SSSE3X264_CPU_SSE4)));
            }


Usually it's about 251-th line. We should replace our CPU id to something else, or just comment this checking. For example replace line "if( model == 9 model == 13 model == 14 )" to "if( model == 900 model == 1300 model == 1400 )".



That's all. Then we must save file and continue compilation.

PATH="$HOME/bin:$PATH" make
make install
make distclean
5. Compile ffmpeg: cd ~/ffmpeg_sources
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure
  --prefix="$HOME/ffmpeg_build"
  --pkg-config-flags="--static"
  --extra-cflags="-I$HOME/ffmpeg_build/include"
  --extra-ldflags="-L$HOME/ffmpeg_build/lib"
  --bindir="$HOME/bin"
  --enable-gpl
  --enable-libx264
PATH="$HOME/bin:$PATH" make
make install

6. Enjoy.

If this manual will not work for you, please google for another, but please understand trick to make x264 working with your PC: edit file "common/cpu.c" and comment/remove from it CPU checking.

Hope I helped you. If so, please say thanks smile)

离线

页脚