WebRTC World Feature Article

February 16, 2016

Here's a Workaround for Testing .Y4M Files in Chrome


WebRTC has already proven itself to be a wonderful technological breakthrough, enabling the creation of applications with rich, high-quality Real-Time Communications (RTC) capabilities developed for browsers and mobile devices. Using a common set of protocols, WebRTC essentially standardizes the underlying components of web-based audio and video communications via APIs to eliminate compatibility issues.

Google Chrome was one of the first browsers to support the WebRTC standard, but developers hoping to test such applications in the browser may run into a problem when trying to replace the camera feed with a preset media file. Chrome requires files to be converted into the .Y4M format, but also expects a certain item of metadata in the header to match its backend before it will work properly. Namely, the section of the header that describes the “color space used” must read ‘C420’, not ‘C420mpeg2’; this may seem like an arbitrary detail (and it sort of is) but it is critical for getting the file to work in Chrome and therefore allow media testing to commence.

Many developers use FFmpeg, a comprehensive piece of software for recording, converting and streaming audio and video as well as managing codecs, for tasks such as this, but every .Y4M file it outputs will have those fatal five “mpeg2” characters and as a result crash Chrome. There is a workaround, but it’s not very intuitive. First, you must run the following two commands in the sed command line program:

ffmpeg -i <your-file-here>.mp4 -pix_fmt yuv420p
sed -i '0,/C420mpeg2/s//C420/' *.y4m

Then, you can run Chrome to invoke the newly created file and it should display correctly within the application in question, using this command:

google-chrome --use-fake-device-for-media-stream --use-file-for-fake-video-capture=<your-file-here>.y4m

Ideally, the file being converted into .Y4M will already be of high quality and accurately portray what a live video stream would look like. Upon successful completion of this step, the developer can comfortably move on to live testing of the app and eventually a public release.

WebRTC applications are undeniably the way of the future and Google has done its best to support the movement through expansion of its Chrome browser’s capabilities, but it’s inevitable that troublesome quirks such as this will arise. We must simply keep in mind that the web development world is consistently striving toward eliminating these boundaries between an idea and it’s ability to come to fruition, and it should be expected that kinks like this one will need to be ironed out.




Edited by Kyle Piscioniere




Comments powered by Disqus


FOLLOW US

Free WebRTC eNewsletter

Sign up now to recieve your free WebRTC eNewsletter for all up to date news and conference details. Its free! what are you waiting for.

Featured Videos