caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Sun Nov 17, 2013 5:37 pm

Hi jamesh,

it seems that the video segments miss the information about the framerate. omxplayer replays the files always with 25 fps, although i record with 30 or 15 fps. Or is this a problem of omxplayer?

caerandir

tvjon
Posts: 798
Joined: Mon Jan 07, 2013 9:11 am

Re: New raspivid test release - please try.

Sun Nov 17, 2013 5:47 pm

There's no framerate info' with h264 files,

However, I see a couple of posters reporting they are playing these files with omxplayer. Can you please say which version of omxplayer? Recent versions IME do not play h264 files.
Last edited by tvjon on Mon Nov 18, 2013 12:15 am, edited 1 time in total.

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

Re: New raspivid test release - please try.

Sun Nov 17, 2013 6:52 pm

I've not had problems with my version of omxplayer...but it may not be the absolute latest, but I have done a pretty recent rpi-update....(last week)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

tvjon
Posts: 798
Joined: Mon Jan 07, 2013 9:11 am

Re: New raspivid test release - please try.

Sun Nov 17, 2013 7:05 pm

James,

that does not update omxplayer.

Try

omxplayer -v

please.

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

Re: New raspivid test release - please try.

Sun Nov 17, 2013 10:46 pm

I,ll try and remember to try it andwill mention to Dom tommorrow.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

ethanol100
Posts: 647
Joined: Wed Oct 02, 2013 12:28 pm

Re: New raspivid test release - please try.

Mon Nov 18, 2013 10:09 am

Can we request the encoder to use a frame as an I-Frame?

I have seen the parameter "MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME" and asked myself, if this could be used. Then it could be possible to request an I-Frame to exactly cut the h264 stream at a requested frame. Or would it be possible to change the intra refresh period at cut positions, i.e., set it to 1 at the position where we would like to cut. And reset it to the original values after the cut.
All this could be useful, to save individual files in the signal or keypress mode.

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 10:23 am

I guess its possible (I've never tried) but why do you need such accurate segment sizes or cut off points?

You have the source - give it a go.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

ethanol100
Posts: 647
Joined: Wed Oct 02, 2013 12:28 pm

Re: New raspivid test release - please try.

Mon Nov 18, 2013 10:43 am

It is more the lack of simple video editors on linux. I do not know an easy way to cut and paste h264 streams without I-Frames at the right places. I think raspivid with a start/stop event would then behave more like a usual camcorder (or more like a still camera with video a feature/My old camcorder creates only chapters but mpeg2 was much easer to be edited). And you could easily copy and paste parts together. I will see if I can get it the encoder to insert I-Frames.

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 11:17 am

The segments already have I-frames inserted as their start frame, so should be editable in that respect. If you want to be slightly more accurate with the start/stopping, then increase the number of I-frames (intraframe period)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

tvjon
Posts: 798
Joined: Mon Jan 07, 2013 9:11 am

Re: New raspivid test release - please try.

Mon Nov 18, 2013 11:24 am

ethanol100 wrote:... I think raspivid with a start/stop event would then behave more like a usual camcorder (or more like a still camera with video a feature...
I've already asked about that earlier in this thread……

http://www.raspberrypi.org/phpBB3/viewt ... 69#p454382

ethanol100
Posts: 647
Joined: Wed Oct 02, 2013 12:28 pm

Re: New raspivid test release - please try.

Mon Nov 18, 2013 11:54 am

I think increasing the number of intra frames only increases file size. I have quickly tested to request i-frames after each "pause" of the video stream, and it is working, giving me additional I-Frames(and starting to count from there on i.e. 60,63,123...), but I have not tested, if there are at the right frame. Now I need to initial a split after pause, will quickly give it another try.

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 12:01 pm

ethanol100 wrote:I think increasing the number of intra frames only increases file size. I have quickly tested to request i-frames after each "pause" of the video stream, and it is working, giving me additional I-Frames(and starting to count from there on i.e. 60,63,123...), but I have not tested, if there are at the right frame. Now I need to initial a split after pause, will quickly give it another try.
Actually, the it makes the stream more resilient to errors, but does increase size. There's always a tradeoff!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

ethanol100
Posts: 647
Joined: Wed Oct 02, 2013 12:28 pm

Re: New raspivid test release - please try.

Mon Nov 18, 2013 1:40 pm

I can now use i.e.: "raspivid -v -i 'pause' -t 0 -k -o vid%02d.h264"
Then I get for each "start-stop cycle" a h264 file. Thank you for the "inline header" and "segment" features. With these it was really easy to modify the source to reach my goal.

My modifications can be found here:
http://www2.geo.uni-bonn.de/members/kro ... VidSplit.c

I think something similar could be useful in raspivid.

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 2:03 pm

ethanol100 wrote:I can now use i.e.: "raspivid -v -i 'pause' -t 0 -k -o vid%02d.h264"
Then I get for each "start-stop cycle" a h264 file. Thank you for the "inline header" and "segment" features. With these it was really easy to modify the source to reach my goal.

My modifications can be found here:
http://www2.geo.uni-bonn.de/members/kro ... VidSplit.c

I think something similar could be useful in raspivid.
Looks OK. You should really push this as a git change to the raspi userland. It will be code reviewed by me and Dom, then pushed to the main tree if OK. Just make sure to keep to the coding standards (3 space tabs, allman braces) and it should get through quickly. I would say that the change as it stands would need to have some scheme for turning it on or off on the command line, so as not to affect current the current default functionality.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Mon Nov 18, 2013 2:04 pm

tvjon wrote:There's no framerate info' with h264 files,

Accoring to http://www.ietf.org/rfc/rfc3984.txt I understand that there may be framerate info included (honestly, everything else I'd find strange...). I assume that it is not in raspivid-videos. Perhaps that can be improved?
tvjon wrote:However, I see a couple of posters reporting they are playing these files with omxplayer. Can you please say which version of omxplayer? Recent versions IME do not play h264 files.
omxplayer -v says "invalid option -v" - it seems that there is no version info easily available. However, the stock omxplayer in the current raspbian certainly works well with h264, at least with those recorded by raspivid.

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 2:12 pm

caerandir wrote:
tvjon wrote:There's no framerate info' with h264 files,

Accoring to http://www.ietf.org/rfc/rfc3984.txt I understand that there may be framerate info included (honestly, everything else I'd find strange...). I assume that it is not in raspivid-videos. Perhaps that can be improved?
H264 streams don't have time stamp or frame rate information - that's the job of the container. It's not strange. A bitstream of information can be played back at any rate - it has no inherent value except for width and height.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Mon Nov 18, 2013 2:22 pm

Ah, I see. So I'd need to wrap the container around. Is there any easy way to do this?

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

Re: New raspivid test release - please try.

Mon Nov 18, 2013 2:26 pm

caerandir wrote:Ah, I see. So I'd need to wrap the container around. Is there any easy way to do this?
ffmpeg (avconv) can take a stream and wrap a container around it. It been posted on around here somewhere.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
jbeale
Posts: 3699
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: New raspivid test release - please try.

Mon Nov 18, 2013 3:02 pm

This article http://www.raspberrypi-spy.co.uk/2013/0 ... ra-module/ shows how to do it with MP4Box (what I use) and also avconv. It notes that the mp4 files generated by avconv are not as widely playable as those from MP4Box, for whatever reason.

Code: Select all

sudo apt-get update
sudo apt-get install -y gpac
MP4Box -fps 30 -add myvid.h264 myvid.mp4

caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Mon Nov 18, 2013 3:08 pm

Thanks for the quick help!

caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Tue Nov 19, 2013 8:45 pm

Hi jamesh,

I started to have a look into the raspivid source code because I think if I want to have the motion detection working reliably I need to directly look into the motion vectors. As far as I was able to follow the code, there is the encoder_buffer_callback function that handles output from the codec. What I could not find out: Is the buffer always of fixed size and may thus contain anything from half an I-Frame up to several P- or B-frames, or is one buffer always one frame?

Thanks!

Caerandir

User avatar
waveform80
Posts: 359
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK
Contact: Website Twitter

Re: New raspivid test release - please try.

Tue Nov 19, 2013 9:50 pm

caerandir wrote:Hi jamesh,

I started to have a look into the raspivid source code because I think if I want to have the motion detection working reliably I need to directly look into the motion vectors. As far as I was able to follow the code, there is the encoder_buffer_callback function that handles output from the codec. What I could not find out: Is the buffer always of fixed size and may thus contain anything from half an I-Frame up to several P- or B-frames, or is one buffer always one frame?

Thanks!

Caerandir
The buffer is of fixed size (or more precisely is size limited) and thus can contain bits of big I-frames (or I suppose P-frames). Whether a single callback can deal with multiple P-frames I'm not sure - I suspect in the case that the P-frames were smaller than the buffer size, the callback would be called once for each frame, but this is merely an untested hunch. As far as I know, B-frames aren't used by the camera's encoder (not entirely surprising - I get the impression they're only used when transcoding a pre-existing source, not when recording "live").


Cheers,

Dave.
Author of / contributor to a few pi related things (picamera, Sense HAT emulator, gpio-zero, piwheels, etc.), and currently a software engineer at Canonical responsible for Ubuntu Server and Core on the Raspberry Pi.

caerandir
Posts: 131
Joined: Tue Dec 18, 2012 11:26 am
Location: Bonn, Germany

Re: New raspivid test release - please try.

Tue Nov 19, 2013 10:09 pm

Hi Dave,

thanks for the clarification. I just implemented a few lines to drop out buffer sizes to stdout, and learned as much:
  • Buffer size is limited to 64 K
  • Each frame (regardless of which kind) will be "dumped" seperately. If 64 K is not enough, multiple buffers will be used, until all data is processed. Each buffer except the last will use the full 64K.
  • Every now and then, a frame is split up into two buffers that are both smaller then 64 K - could not find any systematic in that... it is about every 20th frame, but not exactly.
I think to get further, I need to analyze deeper into the content of the buffers. I must confess my learnings make some assumptions - I did not look into the binary data to confirm that the frames come one by one, but using the -g and -ih parameters to influence the number of P-Frames and having a "flag" on each I-Frame there is enough evidence...

I'll go deeper on the weekend.

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

Re: New raspivid test release - please try.

Wed Nov 20, 2013 12:06 pm

With regard to OMXplayer, Dom has committed a fix that should mean it's back to working on top of tree.

With regard to buffers, on arrival in the callback each buffer has a flag set - check out the flag definitions to see what information can be gleaned from those.

Buffer could be larger than 64K - you can specify the size when the encoder is set up - I just use the recommended size. I don't think there is any guarantee as to what a buffer may or may not contain.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

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

Re: New raspivid test release - please try.

Wed Nov 20, 2013 12:09 pm

Since there don't appear to be any problems, I've just sent a pull request for the segmentation branch to be merged in to the raspi userland master.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Return to “Camera board”