Posts: 20
Joined: Sun Dec 14, 2014 5:00 pm

raspivid - h264 video doesnt have any duration data when pl

Wed Jan 21, 2015 11:11 pm

I have a rasp pi B+ model with the camera module installed. When I use the following basic cmd

Code: Select all

raspivid -o v.h264 -t 10000
If I export v.h264 to my windows machine and play it back with VLC, I see that the video timebar remains at 00:00 throughout the whole video, also the end timer is always fixed at 00:00, when usually this end timer shows the total runtime of the video file.(which in this case should be 00:10)

Is there a way to get this information up, or tell raspivid to store the data in the file without taking the raw footage and encoding it with ffmpeg and the likes.

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

Re: raspivid - h264 video doesnt have any duration data when

Thu Jan 22, 2015 8:46 am

The H264 stream is exactly that, a stream of H264 data, and H264 data has no time stamping, for example, it doesn't know what frame rate it was recorded at or it's duration.

To add that information you need to encapsulate the stream in a container such as MP4 or MKV which contains this extra information. This can be done using the avconv program, Google that and raspberry pi to find instructions. Once encapsulated you should get the information you need and it will play back on anything.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: raspivid - h264 video doesnt have any duration data when

Thu Jan 22, 2015 8:56 am

Code: Select all

sudo apt-get install gpac
MP4Box -fps 30 -add infile.h264 outfile.mp4
No re-encoding necessary , just "muxing" .


EDIT: typo corrected , thanks lbendlin
Last edited by ghans on Sun Jan 25, 2015 8:55 pm, edited 1 time in total.
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Posts: 7
Joined: Mon Jan 07, 2013 6:51 pm
Location: MA, USA

Re: raspivid - h264 video doesnt have any duration data when

Sun Jan 25, 2015 6:24 pm

small correction - it's MP4Box with a capital B.

Posts: 15
Joined: Fri Oct 11, 2013 7:08 pm

Re: raspivid - h264 video doesnt have any duration data when

Mon Jan 26, 2015 4:31 pm

I don't know if it is still an issue but in the past you couldn't be sure that #fps that have been recorded was that one cam was configured for. Especially in low light conditions, instantaneous fps rate dropped down to lower values.

My workarround was to record only segments, then compute the effective #fps by counting frames (using the real ffmpeg) and extracting segment duration by file time stamps. A little bit annoying and not perfect, but the best solution I could find.

Return to “Camera board”