4

I've recorded some video with my Raspicam using:

raspivid --timeout 5000 --output video001.h264 --width 1080 --height 720 --bitrate 10000000 --framerate 24

I've converted this to mp4 using:

ffmpeg -r 24 -i video0001.h264 -vcodec copy video0001.mp4

and when I play it with:

mplayer video0001.mp4

It finishes in about 2 seconds. All the video is there, just really, really fast.

Is there a standard way to box up an h264 video?

0

2 Answers 2

3

You can play the file that is output by raspivid in mplayer. You can also try on another computer using VLC.

All you doing with ffmpeg is copying the data stream from the source to destination. You can simply this by renaming the extension from .h264 to .mp4, but you may as well amend raspivid extension to use .mp4

Extensions do not govern what data lies in the file. If the stream is h264 that is what it will be regardless of the filename or extension.

The doubling up in speed might be caused by the -r 24 option on ffmpeg. If you do not need to change source settings then there is no need to specify this option. It may be the culprit.

Just play the original video0001.h264 file and see if that is what you were epxecting.

3
  • Playing with mplayer just spits out repeated: [h264 @ 0x7fe588815400]non-existing PPS 0 referenced [h264 @ 0x7fe588815400]decode_slice_header error [h264 @ 0x7fe588815400]non-existing PPS 0 referenced [h264 @ 0x7fe588815400]decode_slice_header error [h264 @ 0x7fe588815400]non-existing PPS 0 referenced [h264 @ 0x7fe588815400]decode_slice_header error [h264 @ 0x7fe588815400]non-existing PPS 0 referenced [h264 @ 0x7fe588815400]decode_slice_header error [h264 @ 0x7fe588815400]no frame! Error while decoding frame!
    – tompreston
    Commented Sep 25, 2013 at 9:01
  • And VLC gives me: [h264 @ 0x7f855c027480] max_analyze_duration reached [h264 @ 0x7f855c027480] Estimating duration from bitrate, this may be inaccurate [0xbbe1e8] main input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR But does manage to play the video.
    – tompreston
    Commented Sep 25, 2013 at 9:02
  • Ohh You must be missing the PSIPS. Are you using the latest raspivid? It uses a patch that embeds PSIPS. I use it and I can play video directly from raspivid without the need of ffmpeg copy. That is why it might be faster as ffmpeg is skipping these headers but increasing the FPS so it goes faster. Try and remove the -r option and see what happens. I bet it will be well jittery! Or the data written to the SD card is getting corrupted. Try another SD card too.
    – Piotr Kula
    Commented Sep 25, 2013 at 9:03
0

I've never tried 24fps on a Pi, as it is a pretty unusual rate.

ffmpeg -i <input> -vcodec copy <output.mp4>

does package the video stream in a container, not as mentioned above "just changing the extension".

When providing a frame rate on recording, and on packaging, it might end up not being recorded in that framerate, and later packaged with this frame rate explicitly.

On my Pi B recording works without any parameter, and converting on the mac without framerate produces a quicktime playable mp4, with correct frame rate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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