Hi, I'm using fobs to do some validation on .wma and .3gp files before our application upload a media file. Here is my code:
MediaLocator ml = new MediaLocator("file:///" + fileName);
com.omnividea.media.protocol.file.DataSource ds = new com.omnividea.media.protocol.file.DataSource(null);
ds.setLocator(ml);
Parser parser = new Parser();
int codec = 0;
try {
parser.setSource(ds);
parser.open();
String parserStr = parser.toString();
Track[] tracks = parser.getTracks();
Track video = null;
for (int i = 0; i < tracks.length; i ++)
{
if (tracks[i].getFormat() instanceof VideoFormat){
VideoFormat videoFormat = (VideoFormat)tracks[i].getFormat();
String videoFormatStr = videoFormat.toString();
String encoding = videoFormat.getEncoding();
if (videoFormat instanceof H263Format){
....
}
...
}
...
}
My question is how do I get the codec of the VideoFormat. I use a .3gp file with H263 codec. The encoding returned is "ffmpeg_video", not the codec. The if (videoFormat instanceof H263Format) does not work either. videoFormat is an instanceof AviVideoFormat. I need to validate the codec of the media file. Thanks a lot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I'm using fobs to do some validation on .wma and .3gp files before our application upload a media file. Here is my code:
MediaLocator ml = new MediaLocator("file:///" + fileName);
com.omnividea.media.protocol.file.DataSource ds = new com.omnividea.media.protocol.file.DataSource(null);
ds.setLocator(ml);
Parser parser = new Parser();
int codec = 0;
try {
parser.setSource(ds);
parser.open();
String parserStr = parser.toString();
Track[] tracks = parser.getTracks();
Track video = null;
for (int i = 0; i < tracks.length; i ++)
{
if (tracks[i].getFormat() instanceof VideoFormat){
VideoFormat videoFormat = (VideoFormat)tracks[i].getFormat();
String videoFormatStr = videoFormat.toString();
String encoding = videoFormat.getEncoding();
if (videoFormat instanceof H263Format){
....
}
...
}
...
}
My question is how do I get the codec of the VideoFormat. I use a .3gp file with H263 codec. The encoding returned is "ffmpeg_video", not the codec. The if (videoFormat instanceof H263Format) does not work either. videoFormat is an instanceof AviVideoFormat. I need to validate the codec of the media file. Thanks a lot.