How to convert MP4 file to rosbag? - computer-vision

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?

Related

Convert mp4 into .bag file

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!

How to convert wav to mp3 and mp3 to wav while keeping the same size

I cannot find out how I can convert a wav to mp3 and mp3 to wav. Does anyone know how to convert a .wav file into a .mp3 or .ogg and later convert back into .wav while matching 100% same size like untouched (if it can be done in the command line its much better). I tried to use LAME and later back to .wav with some tools but the file wouldn’t match 100% byte per byte like if it was never was touched. Does anyone know any command line in SoX or FFMPEG that can help me? Thanks!
Most WAV files are raw PCM. MP3 is MP3. And, most Ogg files are going to contain Vorbis or Opus.
MP3, Vorbis, and Opus, are all lossy codecs. They work by taking advantage of what we hear and what we don't hear, psychoacoustics and all that, and saving bandwidth. It's tradeoff between bandwidth and audio quality.
You cannot use the output of a lossy codec to get back to the original source. Therefore, you definitely can't expect to binary compare the outputs and get them to be the same.
You also can't even get the same file size really without knowing more about the source. For instance, the input of your MP3 codec might have been 24-bit audio, but the output of the receiving codec is almost always going to be configured for 16-bit. Also, it's common for these lossy codecs to not be sample-accurate. MP3 in particular has a problem with this. Read up on "gapless playback" if you're in doubt.

concatenate files in libffmpeg c++

i'm a bit at loss here. My goal is to merge two video files (which might be of different file formats) and i'm already using libffmpeg for other simple tasks. I thought libffmpeg exposed some kind of function to merge files, but i can't find it.
I found these pages on the documentation that might be relevant: http://ffmpeg.org/doxygen/trunk/structConcatStream.html and http://ffmpeg.org/doxygen/trunk/group__lavf__encoding.html
I'm not sure if this is really relevant though? Can anybody point me in the right direction? Do i need to use FFmpeg muxing and manually joins streams? Is there any example that can explain to me what i should do? thanks!
For those looking for an example, i ended up using
How to use libavformat to concat 2 video files with same codec (re-muxing)?
there's a nice snippet and it works very well
Use ffmpeg to open file 1, start reading frames, converting to target format, and writing to the output file. When there are no more frames, close file 1 (leave output open). Open file 2, start reading frames, converting to target format, and writing to the output file. When there are no more frames, close file 2 and close output.
Merged and formats reconciled.

Finding Bitrate of video file

How can we find bitrate of a video file in c++? Can we do this by file handling?
Thanks
Install FFMEPG it will give you all the information related to the video
e.g.
ffmpeg -i filename.flv
If you want to implement such yourself you need to be able to read the video container format (Quicktime, ASF, AVI, Matroska etc) and try to find the bitrate from the metadata.
You can use ffprobe from the ffmpeg project to get the information about your video files and get a nice JSON ouput.
Check this answer for an example.

How to convert an mp3 to an flv with a background: conversion errors

I'm trying to convert an mp3 to an flv for use in a custom player we already had built.
I can import the mp3 to the timeline, but it's 30 minutes of talking, and you can only add so many frames at a time. That's tedious! We have a lot of these to do.
I then tried the simple import URL option and got it to stream. I put a stop() on the first frame and boom, that works when I test in Flash CS5.
But to convert to flv, I have to export as mov first. So I tested 5 minutes of streaming and converting, and got a 22mb file. I then looked for a free converter of .mov to .flv. I found "Any Video Conversion" which seems decent, but it only converts 8 seconds of the 5 minutes for some reason.
Is there some other way make a .mov from my sources? Is there an automatic way of adding enough frames to cover an mp3 on the timeline? That might work and might not give the final .mov any fits.
Is there an easy way to convert a .mov or .wav to an .flv?
It turns out you have to
Import the sound to the library
Call the sound using the Sound object
Export movie as .mov, and make sure it's set to get all the streaming content
Convert the resulting .mov with Adobe Media Encoder, which comes with CS5
The Adobe converter at the end did a great job.