I'm trying to transcode an FLV file in Java using the Xuggler libraries, which has two streams:
Stream 0: Video, H264 avc1
Stream 1: Audio, AAC, mp4a
Now, the getNumStreams()
call on the input container returns 2 streams which is correct.
My problem appears because both of the streams have type CODEC_TYPE_UNKNOWN
rather than CODEC_TYPE_VIDEO
/AUDIO.
Hence my code here:
stream.getStreamCoder().getCodecType().equals(ICodec.Type.CODEC_TYPE_AUDIO)
never actually matches a specific stream.
I have tried to manually assign a stream to stream 2 which goes through fine however when I query the codec from the IStreamCoder
, it is null. The CodecID
of the same IStreamCoder
is the correct CODEC_ID_AAC
, and the codec type is CODEC_TYPE_UNKNOWN
as I have mentioned above.
Now my question is, why are these streams marked as unknown rather than the correct audio/video? This piece of code works flawlessly for most other formats such as mp4 containers. My overall goal is extracting the audio streams for transcoding.
Please advise if you need an example code segment to better answer this question, as I'd have to snip out quite a bit of what I have to produce something.
Found out the answer:
I was using the following method to open files, since it was blocking on all other files (mp4, etc) and crashing the program.
if (input.open(file.getName(), IContainer.Type.READ, null, false, false) < 0)
While this works for all other files, it does not search the entire file for the FLV stream info.
I modified this to:
if (input.open(file.getName(), IContainer.Type.READ, null) < 0)
And it now works correctly. Should just be a case of a simple condition to handle flv files from now on.