Performance Tuning for Raspberry Pi

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Performance Tuning for Raspberry Pi

Bruce Diesel
Hi All,

Please forgive my somewhat basic question, but my searching has not yielded
much information that I can easily understand as I don't have much
knowledge in this space.

I am building a dash cam type application using a Raspberry Pi Zero, some
sensors, and a Pi Camera.  I am burning data from the sensors onto video
using drawtext from a memory file that a separate python program is
continuously updating atomically.

I am really struggling to get reasonable performance.  I get around 6
frames/second at HD quality.  I am not running X Windows, and not
displaying the video, just capturing it.

Using an ffmpeg command line such as:  ffmpeg -i /dev/video0 -vf
drawtext="....." test.mpg

Inside the drawtext I am setting the font, centering the text and giving it
the filename to read.

I have very limited understanding of the pros/cons of different codecs etc
so I am looking for a source of information that can help me through this
without me having to become an expert in the subject.

Once thing I can do is stream to a memory file, but that introduces
complexities like file management, memory limitations etc.

Any pointers to a good source of information on this would be most
appreciated.

Bruce
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Carl Eugen Hoyos-2
2018-10-17 12:16 GMT+02:00, Bruce Diesel <[hidden email]>:

> Please forgive my somewhat basic question, but my searching has not yielded
> much information that I can easily understand as I don't have much
> knowledge in this space.
>
> I am building a dash cam type application using a Raspberry Pi Zero, some
> sensors, and a Pi Camera.  I am burning data from the sensors onto video
> using drawtext from a memory file that a separate python program is
> continuously updating atomically.
>
> I am really struggling to get reasonable performance.  I get around 6
> frames/second at HD quality.  I am not running X Windows, and not
> displaying the video, just capturing it.
>
> Using an ffmpeg command line such as:  ffmpeg -i /dev/video0 -vf
> drawtext="....." test.mpg
>
> Inside the drawtext I am setting the font, centering the text and giving it
> the filename to read.
>
> I have very limited understanding of the pros/cons of different codecs etc
> so I am looking for a source of information that can help me through this
> without me having to become an expert in the subject.

Please provide the command line that you tested together with
the complete, uncut console output.

Assuming you are not doing anything stupid, only small
improvements will be possible with software encoding,
the overlay is always expensive.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Bruce Diesel
Hi Carl,

The command is:
ffmpeg -f v4l2 -i /dev/video0 -vf
drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=/dev/shm/Sensors.txt:reload=1:x=(w-text_w)/2:y=(h-text_h)/2"
test.mpg

The output is:
ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg
developers
  built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version='1~deb9u1+rpt2'
--toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf
--incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping
--enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa
--enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
--enable-libcdio --enable-libebur128 --enable-libflite
--enable-libfontconfig --enable-libfreetype --enable-libfribidi
--enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg
--enable-libopenmpt --enable-libopus --enable-libpulse
--enable-librubberband --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora
--enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq
--enable-libzvbi --enable-omx-rpi --enable-mmal --enable-openal
--enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883
--arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv
--enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 19249.680868, bitrate: 283115 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1024x768,
283115 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
[Parsed_drawtext_0 @ 0x1bc90f0] Using
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
[mpeg @ 0x1bcb010] VBV buffer size not set, using default size of 130KB
If you want the mpeg file to be compliant to some specification
Like DVD, VCD or others, make sure you set the correct buffer size
Output #0, mpeg, to 'test.mpg':
  Metadata:
    encoder         : Lavf57.56.101
    Stream #0:0: Video: mpeg1video, yuv420p, 1024x768, q=2-31, 200 kb/s, 30
fps, 90k tbn, 30 tbc
    Metadata:
      encoder         : Lavc57.64.101 mpeg1video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg1video (native))
Press [q] to stop, [?] for help
frame=   11 fps=7.9 q=4.5 size=      98kB time=00:00:00.26
bitrate=3010.4kbits/s
frame=   17 fps=7.6 q=8.4 size=     150kB time=00:00:00.46
bitrate=2633.1kbits/s
frame=   22 fps=6.5 q=7.4 size=     154kB time=00:00:00.63
bitrate=1991.9kbits/s
frame=   27 fps=5.9 q=6.9 size=     210kB time=00:00:00.80
bitrate=2150.4kbits/s
frame=   32 fps=5.9 q=7.2 size=     210kB time=00:00:00.96
bitrate=1779.6kbits/s
frame=   37 fps=5.9 q=8.0 size=     218kB time=00:00:01.13
bitrate=1575.7kbits/s
frame=   43 fps=6.0 q=9.3 size=     260kB time=00:00:01.33
bitrate=1597.4kbits/s
frame=   48 fps=5.8 q=10.8 size=     264kB time=00:00:01.50
bitrate=1441.8kbits/s
frame=   53 fps=5.7 q=19.1 size=     292kB time=00:00:01.66
bitrate=1435.2kbits/s
frame=   58 fps=5.6 q=17.0 size=     294kB time=00:00:01.83
bitrate=1313.7kbits/s
frame=   63 fps=5.6 q=17.0 size=     320kB time=00:00:02.00
bitrate=1310.7kbits/
frame=   69 fps=5.7 q=18.9 size=     324kB time=00:00:02.20
bitrate=1206.5kbits/
frame=   74 fps=5.6 q=12.1 size=     350kB time=00:00:02.36
bitrate=1211.5kbits/
frame=   79 fps=5.6 q=17.9 size=     354kB time=00:00:02.53
bitrate=1144.7kbits/
frame=   84 fps=5.6 q=17.2 size=     354kB time=00:00:02.70
bitrate=1074.1kbits/
frame=   89 fps=5.6 q=23.5 size=     380kB time=00:00:02.86
bitrate=1085.9kbits/
frame=   95 fps=5.6 q=26.3 size=     384kB time=00:00:03.06
bitrate=1025.8kbits/frame=  100 fps=5.6 q=30.3 size=     406kB
time=00:00:03.23 bitrate=1028.6kbits/frame=  105 fps=5.5 q=31.0 size=
 406kB time=00:00:03.40 bitrate= 978.2kbits/frame=  110 fps=5.6 q=20.7
size=     428kB time=00:00:03.56 bitrate= 983.0kbits/frame=  115 fps=5.6
q=29.1 size=     428kB time=00:00:03.73 bitrate= 939.2kbits/frame=  121
fps=5.6 q=26.3 size=     430kB time=00:00:03.93 bitrate= 895.6kbits/frame=
126 fps=5.6 q=31.0 size=     452kB time=00:00:04.10 bitrate=
903.1kbits/frame=  131 fps=5.6 q=31.0 size=     452kB time=00:00:04.26
bitrate= 867.8kbits/frame=  136 fps=5.6 q=31.0 size=     472kB
time=00:00:04.43 bitrate= 872.2kbits/frame=  141 fps=5.6 q=31.0 size=
 474kB time=00:00:04.60 bitrate= 844.1kbits/frame=  147 fps=5.6 q=31.0
size=     494kB time=00:00:04.80 bitrate= 843.1kbits/frame=  152 fps=5.6
q=31.0 size=     496kB time=00:00:04.96 bitrate= 818.1kbits/frame=  157
fps=5.6 q=31.0 size=     498kB time=00:00:05.13 bitrate= 794.7kbits/frame=
162 fps=5.6 q=31.0 size=     518kB time=00:00:05.30 bitrate=
800.7kbits/frame=  167 fps=5.6 q=31.0 size=     518kB time=00:00:05.46
bitrate= 776.2kbits/frame=  173 fps=5.6 q=31.0 size=     542kB
time=00:00:05.66 bitrate= 783.5kbits/frame=  178 fps=5.6 q=31.0 size=
 546kB time=00:00:05.83 bitrate= 766.8kbits/frame=  178 fps=5.4 q=31.0
Lsize=     548kB time=00:00:05.86 bitrate= 765.2kbits/s dup=143 drop=0
speed=0.177x
video:545kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.612837%



On Wed, Oct 17, 2018 at 2:01 PM Carl Eugen Hoyos <[hidden email]> wrote:

> 2018-10-17 12:16 GMT+02:00, Bruce Diesel <[hidden email]>:
>
> > Please forgive my somewhat basic question, but my searching has not
> yielded
> > much information that I can easily understand as I don't have much
> > knowledge in this space.
> >
> > I am building a dash cam type application using a Raspberry Pi Zero, some
> > sensors, and a Pi Camera.  I am burning data from the sensors onto video
> > using drawtext from a memory file that a separate python program is
> > continuously updating atomically.
> >
> > I am really struggling to get reasonable performance.  I get around 6
> > frames/second at HD quality.  I am not running X Windows, and not
> > displaying the video, just capturing it.
> >
> > Using an ffmpeg command line such as:  ffmpeg -i /dev/video0 -vf
> > drawtext="....." test.mpg
> >
> > Inside the drawtext I am setting the font, centering the text and giving
> it
> > the filename to read.
> >
> > I have very limited understanding of the pros/cons of different codecs
> etc
> > so I am looking for a source of information that can help me through this
> > without me having to become an expert in the subject.
>
> Please provide the command line that you tested together with
> the complete, uncut console output.
>
> Assuming you are not doing anything stupid, only small
> improvements will be possible with software encoding,
> the overlay is always expensive.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Carl Eugen Hoyos-2
2018-10-17 21:24 GMT+02:00, Bruce Diesel <[hidden email]>:

> The command is:
> ffmpeg -f v4l2 -i /dev/video0 -vf
> drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=/dev/shm/Sensors.txt:
> reload=1:x=(w-text_w)/2:y=(h-text_h)/2" test.mpg
>
> The output is:
> ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg

This is more than two years old and it is possible that current
FFmpeg git head contains more optimizations for arm (I don't
know). If they exist, they should make a measurable difference.

In any case, don't expect miracles, there is nothing obviously
wrong with your command line, but you can always compare
with x264 ultrafast, it may be faster, I never tested.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Bruce Diesel
Thanks Carl.   Would the bottleneck by storage I/O or processing.  In other
words, would getting a faster SC Card improve things?  I will test with
lower resolution, maybe 720 instead of full HD.  I have seen mention of
hardware acceleration on Raspberry Pi, is that applicable to this
situation, or is that about video playback?

I will compile the latest ffmpeg and see how that goes.

Bruce


Bruce

On Wed, Oct 17, 2018 at 8:29 PM Carl Eugen Hoyos <[hidden email]> wrote:

> 2018-10-17 21:24 GMT+02:00, Bruce Diesel <[hidden email]>:
>
> > The command is:
> > ffmpeg -f v4l2 -i /dev/video0 -vf
> >
> drawtext="fontsize=20:fontfile=FreeSerif.ttf:textfile=/dev/shm/Sensors.txt:
> > reload=1:x=(w-text_w)/2:y=(h-text_h)/2" test.mpg
> >
> > The output is:
> > ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg
>
> This is more than two years old and it is possible that current
> FFmpeg git head contains more optimizations for arm (I don't
> know). If they exist, they should make a measurable difference.
>
> In any case, don't expect miracles, there is nothing obviously
> wrong with your command line, but you can always compare
> with x264 ultrafast, it may be faster, I never tested.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Moritz Barsnick
On Wed, Oct 17, 2018 at 20:44:31 +0100, Bruce Diesel wrote:
> Thanks Carl.   Would the bottleneck by storage I/O or processing.

It would usually be the processing.

> I have seen mention of hardware acceleration on Raspberry Pi, is that
> applicable to this situation, or is that about video playback?

It probably depends on the hardware on your Raspberry Pi. ffmpeg can be
compiled with support for OpenMAX, that's the omx encoder. Firstly,
this needs to apply to your Pi Zero (it probably doesn't). Secondly, it
can only accelerate encoding to MPEG4 and H.264, not MPEG1 as you are
using.

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Moritz Barsnick
On Wed, Oct 17, 2018 at 23:08:48 +0200, Moritz Barsnick wrote:
> Firstly, this needs to apply to your Pi Zero (it probably doesn't).

I was wrong, it probably does apply (if the Linux kernel for the Zero
supports it) as all Pis seem to have the Broadcom VideoCore IV:
https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Francois Visagie
> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> Moritz Barsnick
> Sent: 17 October 2018 22:28
> To: FFmpeg user discussions
> Subject: Re: [FFmpeg-user] Performance Tuning for Raspberry Pi
>
> On Wed, Oct 17, 2018 at 23:08:48 +0200, Moritz Barsnick wrote:
> > Firstly, this needs to apply to your Pi Zero (it probably doesn't).
>
> I was wrong, it probably does apply (if the Linux kernel for the Zero
> supports it) as all Pis seem to have the Broadcom VideoCore IV:
> https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications

Regarding MPEG support, a hardware _de_coder is available for the Raspberry Pi. It may be worth checking whether an encoder is included with that and/or available separately, if you're going to use MPEG encoding.

>
> Moritz
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Performance Tuning for Raspberry Pi

Bruce Diesel
I don't really mind what encoding I use, I don't know enough about the
subject to be able to choose one over another, so as long as I can play it
back with adequate quality and compression, I don't really mind.

On Thu, Oct 18, 2018 at 6:48 PM Francois Visagie <[hidden email]>
wrote:

> > -----Original Message-----
> > From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> > Moritz Barsnick
> > Sent: 17 October 2018 22:28
> > To: FFmpeg user discussions
> > Subject: Re: [FFmpeg-user] Performance Tuning for Raspberry Pi
> >
> > On Wed, Oct 17, 2018 at 23:08:48 +0200, Moritz Barsnick wrote:
> > > Firstly, this needs to apply to your Pi Zero (it probably doesn't).
> >
> > I was wrong, it probably does apply (if the Linux kernel for the Zero
> > supports it) as all Pis seem to have the Broadcom VideoCore IV:
> > https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications
>
> Regarding MPEG support, a hardware _de_coder is available for the
> Raspberry Pi. It may be worth checking whether an encoder is included with
> that and/or available separately, if you're going to use MPEG encoding.
>
> >
> > Moritz
> > _______________________________________________
> > ffmpeg-user mailing list
> > [hidden email]
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> > To unsubscribe, visit link above, or email
> > [hidden email] with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".