At WyeWorks headquarters, every once in a while, we come across some project that needs a media edition/transcoding solution to build into. This was the case of our latest project in which we built a pretty simple interface with Brightcove(Brightcove - The Leading Online Video Platform), a powerful video platform on which we may write something about it in our forthcoming posts, but it’s not the point right now.
Turns out to be that Brightcove recommends that files should be encoded using either H.264 or VP6. As usual, we ask ffmpeg for salvation when we need to transcode media files and this was not the exception. But we didn’t want to transcode just every file nor make the choice based on the file’s extension. We wanted a way to check the current file encoding.
Searches made at that time lead us to think that the usual way to get a media file encoding is by running:
which i must say that it’s pretty ugly for me since that command it’s supposed to be used for conversion and as far as i know it doesn’t offer some flag to get only the file information. In fact, that command returns an error (but still prints the information we need):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The information we need is the video codec (in this case vp6f) to determine if we need to transcode it.
Another thing to mention is that nothing that you see as the output there outputs to the stdout. No rocket science needed but i was kind of lazy to parse this from scratch. Lucky for me, there was this not so new rvideo(rvideo) gem (still unknown for me) that made me save some precious time.
RVideo(rvideo) still relies in ffmpeg command and also it’s internal work to get the information we need involves that same output parsing, you just don’t have to do it yourself. After installation (not covered here, just check rvideo readme file), you can do things as shown below:
1 2 3 4 5 6 7
We’ve just made a tiny introduction to inspection. I’m not covering video processing. Check rvideo(rvideo) for more details! Enjoy!