Ask Your Question
0

increase ogg/theora framerate for streaming

asked 2011-08-01 22:33:43 -0500

Miguel Prada gravatar image

updated 2011-08-03 20:21:32 -0500

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 ;)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2011-08-03 10:49:43 -0500

Patrick Mihelich gravatar image

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 :)

edit flag offensive delete link more
1

answered 2011-08-02 08:06:44 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

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.

edit flag offensive delete link more

Comments

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 :)
Miguel Prada gravatar image Miguel Prada  ( 2011-08-02 19:14:07 -0500 )edit
Also, I know the 1fps is the expected behaviour, but I was hoping I could raise the framerate somehow.
Miguel Prada gravatar image Miguel Prada  ( 2011-08-02 19:14:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-08-01 22:33:43 -0500

Seen: 831 times

Last updated: Aug 03 '11