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 :))








Метки текста: ffpmeg, x264_cpu_detect, x264, ffmpeg compile


https://minidevices.top/images/ava.png
https://minidevices.top/images/ava.png
2016-11-01 16:55
root
 01 ноября 2016 в 16:55 
  0  

3512
2016-11-01 16:55
guest     09 апреля 2018 в 09:04 Ответить
thanks