Bluetarget
Posts: 13
Joined: Wed Aug 10, 2016 5:16 pm

SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Tue May 23, 2017 8:12 pm

Hello

I'm desperatly trying to livestream some video with ffmpeg (does not have alsa) or avconv (does not have hardware accelerated x264 encoding).

I would like to ask to raspbian developpers :
WHY did you include a precompiled version of avconv WITHOUT h264 hardware accelerated encoder like --enable-omx-rpi or --enable-decoder=h264_mmal ?
I'm really disappointed since I'm still trying to recompile ffmpeg myself for 4 days now...

Please, next time, consider adding important features such as video encoding acceleration. It's some very basic feature, I cannot understand why you did not include this. Just making life harder for Raspbian users.
Last edited by Bluetarget on Sun May 28, 2017 5:40 pm, edited 2 times in total.


jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22063
Joined: Sat Jul 30, 2011 7:41 pm

Re: avconv without libx264 hardware encoding ? WHY ???

Wed May 24, 2017 8:40 am

Bluetarget wrote:Hello

I'm desperatly trying to livestream some video with ffmpeg (does not have alsa) or avconv (does not have hardware accelerated x264 encoding).

I would like to ask to raspbian developpers :
WHY did you include a precompiled version of avconv WITHOUT h264 hardware accelerated encoder like --enable-omx-rpi or --enable-decoder=h264_mmal ?
I'm really disappointed since I'm still trying to recompile ffmpeg myself for 4 days now...

Please, next time, consider adding important features such as video encoding acceleration. It's some very basic feature, I cannot understand why you did not include this. Just making life harder for Raspbian users.
The Raspbian distro is based on Debian, with as few changes as possible. Basically because if we make changes to a load of apps, we need to make those same changes every time there is a new Raspbian release. This is a maintenance nightmare. It's hard enough maintaining the kernel with Pi specific stuff, doing it for the distribution as well doesn't bear thinking about, especially since it is not actually done by the Foundation.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Bluetarget
Posts: 13
Joined: Wed Aug 10, 2016 5:16 pm

Re: avconv without libx264 hardware encoding ? WHY ???

Wed May 24, 2017 9:57 am

Thanks for the reply.

Anyway, as ffmpeg and avconv already come with raspbian, why don't you activate the h264 hardware encoding by default ?
It's really annoying for a lot of users since it makes us unable to stream anything but raspicam.

Also, when I try to recompile avconv, I've got this error :
/usr/local/lib/libavcodec.a(libx264.o): In function `X264_init':
/home/pi/ffmpeg/libavcodec/libx264.c:814: undefined reference to `x264_encoder_open_148'
So I'm completely stuck :(

gkreidl
Posts: 5915
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: avconv without libx264 hardware encoding ? WHY ???

Wed May 24, 2017 12:05 pm

You could use gstreamer. Hardware decoding and encoding is supported by the gstreamer1.0 omx-plugin, which is provided by the Foundation repository.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Bluetarget
Posts: 13
Joined: Wed Aug 10, 2016 5:16 pm

Re: avconv without libx264 hardware encoding ? WHY ???

Sun May 28, 2017 5:39 pm

I finally recompiled ffmpeg successfully this way :
sudo apt-get install libtool-bin
mkdir /home/pi/Desktop/sources
mkdir /home/pi/Desktop/sources/arm

cd /home/pi/Desktop/sources
wget http://tipok.org.ua/downloads/media/aac ... 0.2.tar.gz
tar -xzf libaacplus-2.0.2.tar.gz
cd libaacplus-2.0.2
#./autogen.sh --with-parameter-expansion-string-replace-capable-shell=/bin/bash --enable-static --host=arm-unknown-linux-gnueabi --prefix=/home/pi/Desktop/sources/arm
./autogen.sh --with-parameter-expansion-string-replace-capable-shell=/bin/bash --enable-static --prefix=/home/pi/Desktop/sources/arm
make
sudo make install

cd /home/pi/Desktop/sources
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static --enable-shared
make
sudo make install

sudo apt-get install git libasound2-dev libav-tools
sudo apt-get install yasm libvpx. libx264. libxcb.
sudo apt-get install libmp3lame-dev libmp3lame0

cd /usr/src
sudo git clone https://git.ffmpeg.org/ffmpeg.git

cd ffmpeg
./configure --enable-gpl --enable-libx264 --enable-mmal --enable-omx-rpi --enable-omx --enable-libxcb --enable-libmp3lame --enable-nonfree
make
ffmpeg --list-hwaccels
#sudo make install
#ldconfig


dhempling
Posts: 3
Joined: Fri Aug 19, 2016 8:57 am

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Sun Oct 08, 2017 1:08 pm

Thank you for posting that fix to the libaacplus autogen argument list. Very Big Help!

klode
Posts: 14
Joined: Mon Dec 21, 2015 8:39 am

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Wed May 08, 2019 1:36 pm

Sorry, I've executed what you have reported in your thread, however when I try to use h264_mmal for decoding with ffmpeg:

Code: Select all

ffmpeg -c:v h264_mmal -i video.mkv [params] -vcodec libx264
I got this error:

Code: Select all

[h264_mmal @ 0x34a5760] Did not get output frame from MMAL.
Error while decoding stream #0:0: Unknown error occurred
Without using the parameter:

Code: Select all

-c:v h264_mmal
I got the cpu at 100%.

I'm using Raspbian of 2019-04, and this is my ffmpeg version:

Code: Select all

ffmpeg version N-93791-gcc86982fc5 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --enable-gpl --enable-libx264 --enable-mmal --enable-omx-rpi --enable-omx --enable-libxcb --enable-libmp3lame --enable-nonfree
Somebody can help me?

fruitoftheloom
Posts: 19483
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Wed May 08, 2019 1:45 pm

klode wrote:
Wed May 08, 2019 1:36 pm
Sorry, I've executed what you have reported in your thread, however when I try to use h264_mmal for decoding with ffmpeg:

Code: Select all

ffmpeg -c:v h264_mmal -i video.mkv [params] -vcodec libx264
I got this error:

Code: Select all

[h264_mmal @ 0x34a5760] Did not get output frame from MMAL.
Error while decoding stream #0:0: Unknown error occurred
Without using the parameter:

Code: Select all

-c:v h264_mmal
I got the cpu at 100%.

I'm using Raspbian of 2019-04, and this is my ffmpeg version:

Code: Select all

ffmpeg version N-93791-gcc86982fc5 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --enable-gpl --enable-libx264 --enable-mmal --enable-omx-rpi --enable-omx --enable-libxcb --enable-libmp3lame --enable-nonfree
Somebody can help me?

The original post was TWO years ago when Raspbian Jessie was the de-facto Operating System.

You have stated you are running Debian Stretch !!
adieu

My other Computer is an Asus CS10 ChromeBit running Chrome Operating System.
HP Envy 4500 Wireless Printer supported by HPLIP software in Raspbian Stretch.

klode
Posts: 14
Joined: Mon Dec 21, 2015 8:39 am

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Wed May 08, 2019 5:05 pm

fruitoftheloom wrote:
Wed May 08, 2019 1:45 pm
The original post was TWO years ago when Raspbian Jessie was the de-facto Operating System.

You have stated you are running Debian Stretch !!
What's the meaning?

fruitoftheloom
Posts: 19483
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Wed May 08, 2019 5:29 pm

klode wrote:
Wed May 08, 2019 5:05 pm
fruitoftheloom wrote:
Wed May 08, 2019 1:45 pm
The original post was TWO years ago when Raspbian Jessie was the de-facto Operating System.

You have stated you are running Debian Stretch !!
What's the meaning?

You are running a different Operating System, that is why you should not of hijacked a SOLVED Post.....
adieu

My other Computer is an Asus CS10 ChromeBit running Chrome Operating System.
HP Envy 4500 Wireless Printer supported by HPLIP software in Raspbian Stretch.

klode
Posts: 14
Joined: Mon Dec 21, 2015 8:39 am

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Thu May 09, 2019 1:21 pm

Oh, nice!
So, what is, about your opinion, the best solution to obtain a ffmpeg version with libx264 for hardware encoding?
1. Rollback to Jessie
2. apply a new solution for Stretch

In case of option 2, where can I found a good info to resolve this?

gkreidl
Posts: 5915
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Thu May 09, 2019 5:08 pm

klode wrote:
Thu May 09, 2019 1:21 pm
Oh, nice!
So, what is, about your opinion, the best solution to obtain a ffmpeg version with libx264 for hardware encoding?
1. Rollback to Jessie
2. apply a new solution for Stretch

In case of option 2, where can I found a good info to resolve this?
The actual Stretch version of ffmpeg supports accelerated decoding and encoding (h264_mmal, h264_omx).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

klode
Posts: 14
Joined: Mon Dec 21, 2015 8:39 am

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Fri May 10, 2019 5:28 am

gkreidl wrote:
Thu May 09, 2019 5:08 pm
klode wrote:
Thu May 09, 2019 1:21 pm
Oh, nice!
So, what is, about your opinion, the best solution to obtain a ffmpeg version with libx264 for hardware encoding?
1. Rollback to Jessie
2. apply a new solution for Stretch

In case of option 2, where can I found a good info to resolve this?
The actual Stretch version of ffmpeg supports accelerated decoding and encoding (h264_mmal, h264_omx).
I don't think so. I mean, in my Rpi2 I have some trouble on using accelerated decoding... So, I think I have ffmpeg works with accelerated deconding on Rpi3, but for Rpi2 what I need to use instead? Jessie?

gkreidl
Posts: 5915
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: SOLVED Recompiling ffmpeg with libx264 for hardware encoding

Fri May 10, 2019 5:51 am

klode wrote:
Fri May 10, 2019 5:28 am
I don't think so. I mean, in my Rpi2 I have some trouble on using accelerated decoding... So, I think I have ffmpeg works with accelerated deconding on Rpi3, but for Rpi2 what I need to use instead? Jessie?
Is your Stretch version in your RPi2 fully upgraded (I think HW decoding/encoding have been added some time ago)?
Run
ffmpeg -codecs
and earch for H264 in the output (quite large). It should contain the HW decoder and encoder.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Return to “Raspbian”