I think that it's not saving the metadata at all when making a recording with raspivid because when I watch it, it plays at an incorrect frame rate(always plays at 25fps when I record at either 30 or 90 fps) and does not have a total time of the video(cant skip forward through the video or see how long it is). I have tried playback through Media Player Classic on Windows and through VLC Media Player on Kali Linux and get the same results. There is no playback at all with rasbmc. How can I resolve this issue?


You are correct that it's not saving the metadata: the raspivid application writes the output from the camera's H.264 encoder. This is a raw H.264 stream which does not contain metadata like the framerate, in contrast to an H.264 stream contained in an MPEG4 container (or some other suitable container format) which will contain such metadata and possibly other streams like audio channels and so forth.

The reason it's always playing back at 25fps is simply that that's VLC's default in the case that it doesn't know what the source's framerate is. In order to get it to play back at a different rate you'll need to wrap the output in a suitable container format.

I would suggest using ffmpeg for this but unfortunately there's an annoying issue: the -r switch that ffmpeg uses to force the framerate of the input file is only valid for "raw formats" (things like unencoded YUV frames; a raw H.264 stream isn't "raw enough" in this circumstance).

The best solution I've come up with so far is to decode the video to raw with one ffmpeg instance, and pipe that to a second ffmpeg instance which re-encodes it to a full MP4 file, forcing the framerate if necessary. Given that x264 (which ffmpeg uses for H.264 encoding) is extremely CPU intensive this will be dreadfully slow on the Pi, so I'd recommend running this on a desktop. Here's the command line I used to convert a 60fps VGA video on my Ubuntu (14.04LTS) desktop. The input file is input.h264; the output file is output.mp4:

avconv -i input.h264 -f rawvideo - | avconv -y -f rawvideo -r:v 60 -s:v 640x480 -i - output.mp4

Specify the framerate as the -r:v argument, and the frame size as the -s:v argument (this is necessary as the raw video passing down the pipe has absolutely no metadata, not even picture size, so the target avconv instance needs to be told). The resulting file should play back happily at 60fps in VLC.

One final thing to bear in mind is that raspivid is a demo application. It is intended to introduce people to the C API (MMAL) for controlling the camera; it is not intended to be a complete solution for camera in and of itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.