Convert mp4 into .bag file - computer-vision

I'm currently working with computer vision systems and I was just wondering if it is possible to convert .mp4 (or any other type of video format) into .bag files.
I've tried some topics and solutions online but so far none of them were successful.
Thank you!

Related

How to convert MP4 file to rosbag?

I am trying to convert an mp4 video to bagfile(.bag). I found this question:How do I convert a video or a sequence of images to a bag file? and implemented the solution
But when I use rosbag play -l "bag file" camera/image_raw:=image_raw0, and rqt_image_view.
It seems only to convert one second of the video. Does anyone know what will cause this problem?

Get encoding of audio track

Suppose I have .3g2 file. I noticed, they can contain audio track of different encoding (AAC, AMR).
Or, for example, an .m4a file can contain (AAC or ALAC) encoded audio track.
MediaInfo detects it pretty well, but I want to be able to do that using C++.
My question is, how can I detect the type of the audio track in a media file?
Thanks.
MediaInfo is also available with a C++ interface, just download MediaInfo library package, and here is a C++ example.
For getting the first audio track format: MediaInfo::Get(Stream_Audio, 0, "Format")

Convert Movie to OpenNI *.oni video

The Kinect OpenNI library uses a custom video file format to store videos that contain rgb+d information. These videos have the extension *.oni. I am unable to find any information or documentation whatsoever on the ONI video format.
I'm looking for a way to convert a conventional rgb video to a *.oni video. The depth channel can be left blank (ie zeroed out). For example purposes, I have a MPEG-4 encoded .mov file with audio and video channels.
There are no restrictions on how this conversion must be made, I just need to convert it somehow! Ie, imagemagick, ffmpeg, mencoder are all ok, as is custom conversion code in C/C++ etc.
So far, all I can find is one C++ conversion utility in the OpenNI sources. From the looks of it, I this converts from one *.oni file to another though. I've also managed to find a C++ script by a phd student that converts images from a academic database into a *.oni file. Unfortunately the code is in spanish, not one of my native languages.
Any help or pointers much appreciated!
EDIT: As my usecase is a little odd, some explanation may be in order. The OpenNI Drivers (in my case I'm using the excellent Kinect for Matlab library) allow you to specify a *.oni file when creating the Kinect context. This allows you to emulate having a real Kinect attached that is receiving video data - useful when you're testing / developing code (you don't need to have the Kinect attached to do this). In my particular case, we will be using a Kinect in the production environment (process control in a factory environment), but during development all I have is a video file :) Hence wanting to convert to a *.oni file. We aren't using the Depth channel at the moment, hence not caring about it.
I don't have a complete answer for you, but take a look at the NiRecordRaw and NiRecordSynthetic examples in OpenNI/Samples. They demonstrate how to create an ONI with arbitrary or modified data. See how MockDepthGenerator is used in NiRecordSynthetic -- in your case you will need MockImageGenerator.
For more details you may want to ask in the openni-dev google group.
Did you look into this command and its associated documentation
NiConvertXToONI --
NiConvertXToONI opens any recording, takes every node within it, and records it to a new ONI recording. It receives both the input file and the output file from the command line.

combining separate audio and video files into one file C++

I am working on a C++ project with openCV. It is a simple web cam application with basic features like capturing pictures and videos. I have already been able to save video (w/o audio). Since openCV doesnot support audio processing, I was wondering if there is any way I can record audio separately in a different file and later combine those together to get one video file.
While searching on the internet, I did hear something about using ffmpeg with openCV. But I just cant figure out how to do it exactly.....
Can you guys help me? I would be very grateful... Thankyou!
P.S. I have used openCV and QT (for GUI)
As you said, opencv doesn't by itself deal with audio. However once you get a separate audio and video file, you can combine them using a technique called muxing. There are many many ways to do this. I use VirtualDub for most of my muxing needs, although it is windows only (not sure if that's a problem). I know ffmpeg is also capable of muxing (via the command line interface), I can't recall what the command is. There's also mplayer and a multitude of other programs out there to do this.
as far as i know openCV is good for video/image processing. To support audio processing, you can use other libraries e.g. PortAudio or C-sound.

Creating web-browser playable webm files with vp8 SDK?

I'm using the vp8 SDK (www.webmproject.org) to create a vp8-encoded video file. However, the SDK sample produces an IVF file, which the browser doesn't play.
I know the webm format is a matroska container so I guess I should store the video data in that format, but the mkv format specification is lengthy and complex and I don't think I should reinvent the wheel by figuring it out by myself.
So I would like to know if someone can recommend a sample of how to encode and produce a playable webm vp8 file.
If there is no such sample (as my searches on google suggest) at least point me to a simple and usable matroska lib which is proven to work for the browsers.