oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Hw acceleration on ffmpeg

Sat Oct 13, 2018 1:14 pm

Hi,

Raspbian October 2018 adds hw acceleration to ffmpeg (from http://downloads.raspberrypi.org/raspbi ... _notes.txt)

Can I use it to convert mjpeg from an IP camera to mp4? The following works, but doesn`t look like it uses hw acceleration:

Code: Select all

ffmpeg -f mjpeg -i "http://user:[email protected]:xxx/mjpeg.cgi" -c:v libx264 -an output.mp4
Thanks

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5339
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 2:24 pm

You need to specify the right encoder/decoder. I don't remember the specifics off the top of my head, but there should be a command to list what's available.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5805
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 2:25 pm

Libx264 is a software codec so will never be hardware accelerated.
h264_omx is the hardware accelerated codec in ffmpeg, so I'm assuming they've enabled the relevant build options for that.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 3:22 pm

Sorry, the command should be:

Code: Select all

ffmpeg -f mjpeg -i "http://user:[email protected]:xxx/mjpeg.cgi" -c:v h264_omx -an output.mp4
It says Using OMX.broadcom.video_encode, but %CPU goes to 99% anyway, when a comparable gstreamer command uses around 30 %CPU...

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5339
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 3:26 pm

I wouldn't expect miracles.

Is it faster on a pi zero than libx264?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5805
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 4:16 pm

You're still software decoding mjpeg on the cpu. I can't recall if the mmal_dec codec can do mjpeg or not, which should be hardware accelerated for decode.
What resolution are you getting from your ip camera?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 4:24 pm

6by9 wrote:
Sat Oct 13, 2018 4:16 pm
You're still software decoding mjpeg on the cpu. I can't recall if the mmal_dec codec can do mjpeg or not, which should be hardware accelerated for decode.
What resolution are you getting from your ip camera?
640 x 480

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5805
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Hw acceleration on ffmpeg

Sat Oct 13, 2018 4:53 pm

oguime wrote:
Sat Oct 13, 2018 4:24 pm
6by9 wrote:
Sat Oct 13, 2018 4:16 pm
You're still software decoding mjpeg on the cpu. I can't recall if the mmal_dec codec can do mjpeg or not, which should be hardware accelerated for decode.
What resolution are you getting from your ip camera?
640 x 480
VGA should be no hassle software decoding on anything other that a Pi Zero or 1.
I've checked and the MMAL decoder plugin doesn't support mjpeg. It's just possible that ffmpeg is having to do a software format conversion which would have a performance hit, but overall it should work quite happily.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Graphics, sound and multimedia”