I'm trying to create a webm file in android using the Android's MediaCodec API.
I created a VP8 encoder using MediaCodec.createEncoderByType("video/x-vnd.on2.vp8")
as is shown in this CTS test : https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
I'm passing the input to the encoder from a Surface
.
And I am using this class IvfWriter : https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/IvfWriter.java to write the file to the sdcard.
But after writing I cannot play that file neither in MxPlayer (Android) nor on my desktop using VLC/Firefox. Firefox reports that the file is corrupt.
This is the file which was created : https://www.dropbox.com/s/dwk42m9qz2mlagv/derp.webm
It would be great if anyone can tell me a way to debug the video.
The "webm" file you've created isn't a webm file - it's an ivf file (which is a much simpler format, mostly used for containing VPx codec data for testing), and firefox doesn't support that format. VLC does support it though.
But for the video itself - every byte is 0 in every video packet in your file, so something seems to be going wrong in how you call the IvfWriter class from your code - without seeing more of your code it's hard to tell what's wrong. The packets do have varying lengths though, so it's only the content of the individual packets that have gone wrong.
To do such debugging yourself, you can use the avconv (or ffmpeg) tools, e.g. like this: avconv -loglevel debug -dump -hex -i derp.webm -f null -
This will show you the metadata (size, timestamps, flags) for each packet, and the payload content itself.