I need to verify that a video file is (in Java):
- Video is H.264 Encoded
- Audio is AAC Encoded
I've looked into JMF and Xuggle.
Xuggle makes it easier to load and decode the file and turn it into another format, but I've not been able to figure out how to determine the encoding of the file that I've loaded as of yet.
So Im wondering if Xuggle has the capability to simply return the type of Video & Audio encoding a file has or do I need to read the bits of the file to determine this myself?
If I need to determine this myself, can someone point me to some documention on the format of H.264
So I looked at Xuggler's Decoding Demo and found my answer, so for anyone in the future looking for a similar solution here is the code I wrote:
// create a Xuggler container object
IContainer container = IContainer.make();
if(container.open(file.getPath(),IContainer.Type.READ,null) < 0) {
return false;
}
// query how many streams the call to open found
boolean isH264 = false;
boolean isAAC = false;
int numStreams = container.getNumStreams();
for(int i = 0; i < numStreams; i++)
{
// find the stream object
IStream stream = container.getStream(i);
// get the pre-configured decoder that can decode this stream;
IStreamCoder coder = stream.getStreamCoder();
if (coder.getCodecID() == ID.CODEC_ID_H264) {
isH264 = true;
}
if (coder.getCodecID() == ID.CODEC_ID_AAC) {
isAAC = true;
}
}
if (container !=null)
{
container.close();
container = null;
}
return isH264 && isAAC;
This is couple of lines with JCodec ( http://jcodec.org ):
MovieBox movie = MP4Util.parseMovie(new File("path to file"));
Assert.assertEquals(movie.getVideoTrack().getSampleEntries()[0].getFourcc(), "avc1");
for (TrakBox trakBox : movie.getAudioTracks()) {
Assert.assertEquals(trakBox.getSampleEntries()[0].getFourcc(), "mp4a");
}