String cpreset = cmdLine.getOptionValue("cpreset");
if (cpreset != null)
Configuration.configure(cpreset, mOContainer);
IContainerFormat iFmt = null;
IContainerFormat oFmt = null;
// override input format
if (icontainerFormat != null)
{
iFmt = IContainerFormat.make();
/**
* Try to find an output format based on what the user specified, or
* failing that, based on the outputURL (e.g. if it ends in .flv, we'll
* guess FLV).
*/
retval = iFmt.setInputFormat(icontainerFormat);
if (retval < 0)
throw new RuntimeException("could not find input container format: "
+ icontainerFormat);
}
// override the input codec
if (iacodec != null)
{
ICodec codec = null;
/**
* Looks like they did specify one; let's look it up by name.
*/
codec = ICodec.findDecodingCodecByName(iacodec);
if (codec == null || codec.getType() != ICodec.Type.CODEC_TYPE_AUDIO)
throw new RuntimeException("could not find decoder: " + iacodec);
/**
* Now, tell the output stream coder that it's to use that codec.
*/
mIContainer.setForcedAudioCodec(codec.getID());
}
/**
* Open the input container for Reading.
*/
IContainerParameters parameters = IContainerParameters.make();
if (isampleRate > 0)
parameters.setAudioSampleRate(isampleRate);
if (ichannels > 0)
parameters.setAudioChannels(ichannels);
mIContainer.setParameters(parameters);
retval = mIContainer.open(inputURL, IContainer.Type.READ, iFmt);
if (retval < 0)
throw new RuntimeException("could not open url: " + inputURL);
/**
* If the user EXPLICITLY asked for a output container format, we'll try to
* honor their request here.
*/
if (containerFormat != null)
{
oFmt = IContainerFormat.make();
/**
* Try to find an output format based on what the user specified, or
* failing that, based on the outputURL (e.g. if it ends in .flv, we'll
* guess FLV).
*/
retval = oFmt.setOutputFormat(containerFormat, outputURL, null);
if (retval < 0)
throw new RuntimeException("could not find output container format: "
+ containerFormat);
}