User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Text Annotation with raspivid

Tue Nov 17, 2015 5:07 pm

I am having trouble getting formatted dates in a text annotation using raspivid.

The numerical codes work fine so:

Code: Select all

raspivid -t 5000 -a 1036 -o video.h264
gets me a 5 second video using defaults with 15:04:46 11/17/15 on a black background at centre top, exactly as expected. (The seconds are of course increasing)

I was hoping for a little better formatting. ideally I want to get:

picam 2015-11-17 15:04:46

on a black background.

According to the documentation the following code should achieve that:

Code: Select all

raspivid -t 5000 -a 1036 -a "picam %Y-%m-%d %X" -o video.h264
but all I get is:

picam %Y-%m-%d %X

Software and firmware are as up to date as possible. uname -a output is

Code: Select all

Linux raspberrypi 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux
I can only assume that I am misreading the documentation.

Can somebody put me straight please?

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

Re: Text Annotation with raspivid

Tue Nov 17, 2015 7:00 pm

Sep 19th is not as up to date as possible.
The change you refer to was only merged 20 days ago (https://github.com/raspberrypi/userland/pull/264), so 28th Oct.
If you want that feature, you either have to build the userland repo from source, or use "sudo rpi-update" to grab the latest build, but be prepared for there to be the potential of regressions.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Re: Text Annotation with raspivid

Wed Nov 18, 2015 11:00 am

Many thanks for the speedy response.

I'm a little puzzled as I ran "sudo rpi-update", "sudo apt-get update" and "sudo apt-get upgrade" on Tuesday morning to ensure I was up to date. I must have missed an error in the "rpi-update" output.

I have run "sudo rpi-update" again which has bumped the firmware to #826 dated 13 November 2015 and everything now runs perfectly.

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

Re: Text Annotation with raspivid

Wed Nov 18, 2015 11:15 am

apt-get update and rpi-update don't talk to each other and will overwrite what the other did.
apt-get gets the latest stable release, whilst rpi-update gets the cutting edge potentially unstable release.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Re: Text Annotation with raspivid

Wed Nov 18, 2015 11:25 am

Thanks for that. I'll remember to always run rpi-update last if I want the latest firmware.

I have been playing with this this morning. It is a great addition. Extremely versatile.

User avatar
DougieLawson
Posts: 37530
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Text Annotation with raspivid

Wed Nov 18, 2015 11:33 am

yertiz wrote:Thanks for that. I'll remember to always run rpi-update last if I want the latest firmware.
Simple rule. Never run rpi-update unless an expert tells you to.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: Text Annotation with raspivid

Wed Nov 18, 2015 11:53 am

DougieLawson wrote:
yertiz wrote:Thanks for that. I'll remember to always run rpi-update last if I want the latest firmware.
Simple rule. Never run rpi-update unless an expert tells you to.
Or you want something that hasn't been merged to the stable release yet, as in this case.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
DougieLawson
Posts: 37530
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Text Annotation with raspivid

Wed Nov 18, 2015 12:41 pm

6by9 wrote:
Simple rule. Never run rpi-update unless an expert tells you to.
Or you want something that hasn't been merged to the stable release yet, as in this case.
That's predicated on you (the expert) telling the OP it's available.

I run rpi-update whenever a new kernel / new firmware is available but I know a) how to back up my systems, b) how to recover those systems and c) know precisely the updates that are made by running rpi-update. There are three of my systems that always have a back-level kernel available (two haven't been booted for more than 160 days) that I can use to undo any damage if rpi-update fails dismally. I also know how to find the commit ids so that I can pick a specific kernel / firmware level.

The general rule of "NEVER run rpi-update unless instructed to do so by an expert" is good advice for the general population.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

oskich
Posts: 3
Joined: Mon Jan 23, 2017 9:10 am

Re: Text Annotation with raspivid

Mon Jan 23, 2017 9:16 am

Remove
Last edited by oskich on Mon Jan 23, 2017 9:56 am, edited 1 time in total.

oskich
Posts: 3
Joined: Mon Jan 23, 2017 9:10 am

Re: Text Annotation with raspivid

Mon Jan 23, 2017 9:26 am

yertiz wrote:
I was hoping for a little better formatting. ideally I want to get:

picam 2015-11-17 15:04:46

on a black background.

According to the documentation the following code should achieve that:

Code: Select all

raspivid -t 5000 -a 1036 -a "picam %Y-%m-%d %X" -o video.h264
but all I get is:

picam %Y-%m-%d %X
Code should be:

Code: Select all

raspivid -t 5000 -a 1036 -a "%Y-%m-%d %X" -ae +25+25 -o video.h264
:D

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

Re: Text Annotation with raspivid

Mon Jan 23, 2017 10:18 am

oskich wrote:Code should be:

Code: Select all

raspivid -t 5000 -a 1036 -a "%Y-%m-%d %X" -ae +25+25 -o video.h264
:D
Why? What do you think that is doing for you? "+25+25" is not a valid setting for the -ae parameter.
As per the docs, something like "-ae 32,0xff,0x808000" (size 32, white on black) or "-ae 10,0x00,0x8080FF" (size 10, black on white) would make more sense. I have no idea what "+25+25" would do.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

oskich
Posts: 3
Joined: Mon Jan 23, 2017 9:10 am

Re: Text Annotation with raspivid

Mon Jan 23, 2017 2:05 pm

6by9 wrote:
oskich wrote:Code should be:

Code: Select all

raspivid -t 5000 -a 1036 -a "%Y-%m-%d %X" -ae +25+25 -o video.h264
:D
Why? What do you think that is doing for you? "+25+25" is not a valid setting for the -ae parameter.
As per the docs, something like "-ae 32,0xff,0x808000" (size 32, white on black) or "-ae 10,0x00,0x8080FF" (size 10, black on white) would make more sense. I have no idea what "+25+25" would do.
Well, it works for me? Found this in a german forum-post...

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

Re: Text Annotation with raspivid

Mon Jan 23, 2017 2:37 pm

oskich wrote:Well, it works for me? Found this in a german forum-post...
Works for you, but in what way differently than omitting the -ae parameter?
(Sorry, but I don't have a Pi to hand to try it on).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Re: Text Annotation with raspivid

Wed Jan 25, 2017 1:44 pm

Despite being a bit off base Oskich's post did pique my interest in this issue again. I thought in future it might be interesting to move away from boring black and white and use some colour in my annotations. Yellow text on a dark green background might look good.

I'm an RGB hex man myself and know nothing of YUV but fortunately found some kind soul had put a RGB/YUV converter on the web (even if it was in decimal) which enabled me to do the conversions. So I tried the following:

Code: Select all

raspivid -t 5000 -a 12 -a "pi2cam %A, %d %B %Y %H:%M:%S" -ae 16,0xE10094,0x594D3F -o testfile.h264
which appears to give me grey on a transparent background.

I then noticed that the pi docs are using VUY rather than YUV so I tried:

Code: Select all

raspivid -t 5000 -a 12 -a "pi2cam %A, %d %B %Y %H:%M:%S" -ae 16,0x9400E1,0x3F4D59 -o testfile.h264
which gave me white on a transparent background. As its difficult to tell with black and white whether the docs are using VUY or UVY I tried

Code: Select all

raspivid -t 5000 -a 12 -a "pi2cam %A, %d %B %Y %H:%M:%S" -ae 16,0x0094E1,0x4D3F59 -o testfile.h264
which gave me white on a transparent background which surprised me as I would have put money on black text with 00 leading the code.

I even tried the code from the docs:

Code: Select all

raspivid -t 5000 -a 12 -a "pi2cam %A, %d %B %Y %H:%M:%S" -ae 16,0xFF,0x8080FF -o testfile.h264
which gave me white on a transparent background.

So I decided that I knew even less than I thought about YUV and it was time to ask the experts. Have I got this entirely wrong? Is colour not an option? Am I misreading the documentation? Can you put me straight again?

I'm using a pi2 for this exercise. Just in case there may be a problem with how up to date it is uname -a yields:

Code: Select all

Linux raspix 4.4.42-v7+ #946 SMP Sat Jan 14 10:14:34 GMT 2017 armv7l GNU/Linux
yertiz

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

Re: Text Annotation with raspivid

Wed Jan 25, 2017 2:50 pm

https://github.com/raspberrypi/userland ... ol.c#L1482 is converting the value into the underlying structure. Ordered as VUY.
The text colour only uses the Y value. U&V will remain the same as the background.

viewtopic.php?f=43&t=97929 was the thread discussing all these changes, and at least viewtopic.php?f=43&t=97929&start=25#p701272 mentioning that custom txt colour wasn't supported.
You're probably right that the raspicam app help text ought to be updated to reflect reality, or I need to start playing with vector assembly to write the U&V planes (not trivial).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Re: Text Annotation with raspivid

Wed Jan 25, 2017 6:00 pm

6by9 wrote:https://github.com/raspberrypi/userland ... ol.c#L1482 is converting the value into the underlying structure. Ordered as VUY.
The text colour only uses the Y value. U&V will remain the same as the background.

viewtopic.php?f=43&t=97929 was the thread discussing all these changes, and at least viewtopic.php?f=43&t=97929&start=25#p701272 mentioning that custom txt colour wasn't supported.
You're probably right that the raspicam app help text ought to be updated to reflect reality, or I need to start playing with vector assembly to write the U&V planes (not trivial).
Many thanks for the links. I think it has finally penetrated my thick skull.

Coloured backgrounds are not a matter of life and death. I can live with black and white. I was only looking to take advantage of colour if it was available.

It might be helpful to make some minor amendments to the docs to make them clearer. From my reading of the docs I had assumed that -ae worked independently of -a 1024 as the docs say 1024 adds a black background. But clearly -ae only inverts the text/background. Would the following help?

"Adds some text and/or metadata to the picture. Text/data is white by default on a transparent background. See -ae below to change."

"-a 1024 Adds a background to the text/data (Default black - see -ae below to change)"

"-annotateex, -ae Set extra annotation parameters

Specifies annotation size, text colour, and background colour.

Sizes range from 6 to 160. Default is 32. An invalid parameter should default to 32.

For white text on a transparent or black background no further parameters are necessary.

It is possible to change the text and background colours to black text on transparent background or black text on a white background or various shades of grey.

Colours are in hex YUV format. Text colour uses only the Y channel. Background colour requires all three channels in VUY order.

If you wish to change colours you must specify a text size even if you only want the default of 32.

-ae 16 gives size 16 text leaving text and background colours as defined in -a

-ae 32,0x00 gives size 32 black text on a transparent background (if no background is set in -a)

-ae 48,0x00,0x8080ff gives size 48 black text on a white background

-ae 10,0x66,0x8080cc gives size 10 dark grey text on a light grey background"


But don't let me stop you playing with vector assembly if you need something to occupy you on these long dark winter evenings!


yertiz

markhsieh
Posts: 1
Joined: Mon Jun 12, 2017 6:51 am

Re: Text Annotation with raspivid

Tue Jul 18, 2017 11:03 am

Many thank for your guys selfless help,
this email.list help me to show annotation ... (finally) :lol:

Code: Select all

raspivid -t 0 -w 1920 -h 1080 -b 2000000 -sh 0 -co 0 -br 60 -sa 0 -ex night -awb auto -ifx none -a 12 -a 1024 -a "HaHa %Y-%m-%d %Z%z %p:%X" -ae 64,0x00,0x8080ff
demo.jpg
demo.jpg (42.96 KiB) Viewed 3198 times
And then, I try to track the latest raspivid source content from git, but I still can not find the option to adjust the annotation location.
https://github.com/raspberrypi/userland
The raspicamcontrol_set_annotate () control item in the source code RaspiCamControl.c does not contain a position adjustment item.
Mmal_port_parameter_set () does not seem to provide source code can be modified, at least I did not find in the original code.

Code: Select all

 {you src location}/ usrland / interface / mmal /
I would like to ask if I want to increase the function of replace annotation text can refer to what information? Is there an example? thx ... ;)

Return to “Camera board”