0
$\begingroup$

Rosanswers logo

I'm using a modified version of ogg_saver to create a stream of video from the images published from a camera node. However, the behaviour of recording the video at a constant rate of one frame per second is not very appropriate.

I've been trying to figure out how to increase the frame rate to something closer to the rate my camera publishes images, but I've been unable to find a solution.

How should I do this?

@patrick-mihelich Thanks for your nice answer. I'll try that!

There's still one thing that bothers me, which I guess is related to the theora header packets somehow.

  • I can start and stop the ogg_saver node as many times as I want to record several videos when the node publishing the images is the openni_node in openni_camera package.
  • I can only record one video with images published from a camera node of mine. All subsequent runs of ogg_saver without restarting the camera node will produce an invalid video file.

I guess there must be something being done in openni_node which isn't on my node, but I cannot find the key difference (of course there are many differences). Do you have any idea of what might be the reason for these different behaviours?

I can also somehow replicate this with my ogg/theora server hack (only first stream request works vs. as many stream request as needed), but it just puts more stuff in play and difficults finding the culprit.

@zxie Thanks for suggesting the mjpeg_server package. I still need to check if the rest of the infrastructure supports this encoding, but it sure will help to have several options. Also, it's way more stable than my quick-and-dirty solution ;)


Originally posted by Miguel Prada on ROS Answers with karma: 1071 on 2011-08-01

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hi Miguel,

This stems from the fact that we're semi-abusing the Theora format in ROS. It wasn't really designed for the full generality of things you can legally do when publishing ROS images, like publishing at variable rates, changing image resolution/encoding, etc. It works, but it's not a perfect fit.

In particular, when you publish your first image, theora_image_transport needs to just-in-time publish some header packets containing metadata about the image stream. Part of that metadata is the frame rate, which theora_image_transport doesn't know ahead of time. So it just makes up a number, and assumes FPS is 1. For normal ROS transport purposes, we process packets as they arrive and ignore the bogus FPS metadata.

Unfortunately, for ogg_saver this number does matter. ogg_saver basically just streams all the packets to disk, and video players end up using the bogus FPS number.

The simplest workaround is to directly edit the FPS value in theora_image_transport. Edit theora_publisher.cpp, find the line

encoder_setup_.fps_numerator = 1; // don't know the frame rate ahead of time

and hardcode to the value you need. Recompile, and you've increased the frame rate.

In principle, ogg_saver could do better. It could remember where fps_numerator is recorded near the start of the .ogv file, calculate the frame rate of the incoming stream, and then overwrite that value on exit. It's slightly messy and hasn't been a high priority for me yet. Patches welcome of course :)


Originally posted by Patrick Mihelich with karma: 4336 on 2011-08-03

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

According to the documentation this is the expected behavior: http://www.ros.org/wiki/theora_image_transport.

An alternative which might work is using rosbag record to save the images then convert the images to ogg theora video as described here.

If you're going for a live stream I've had some success with the mjpeg_server package.


Originally posted by zxie with karma: 31 on 2011-08-02

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Miguel Prada on 2011-08-02:
Also, I know the 1fps is the expected behaviour, but I was hoping I could raise the framerate somehow.

Comment by Miguel Prada on 2011-08-02:
Hi @zxie, thanks a lot for the pointer to mjpeg_server. That's exactly what I was trying to do, but using ogg/theora instead. I'll see if the remote components of the project can deal with a mjpeg stream. If they do my life just got incredibly easier :)

$\endgroup$

Your Answer

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