我正在尝试使用Xuggle API运行基本场景,我在其中提供输入FLV文件并将其写入另一个FLV文件。
我使用了相同的输入参数(例如比特率,宽度和高度);但是,转换后,我输出视频文件的输出视频大小要大2-3倍。
请参阅以下两个视频的FFMPEG命令输出。
输入视频:
anilj@desk1:~/workspace/androws/XuggleMedia$ ffmpeg -i input/internetCrashing.flv
ffmpeg version N-36083-g2501f93-xuggle-5.5 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 3 2014 13:43:04 with gcc 4.6.4
configuration: --prefix=/home/anilj/workspace/xugglehome --extra-version=xuggle-5.5 --extra-cflags=-I/home/anilj/workspace/xuggle-xuggler/build/native/x86_64-unknown-linux-gnu/captive/stage/home/anilj/workspace/xugglehome/include --extra-ldflags=-L/home/anilj/workspace/xuggle-xuggler/build/native/x86_64-unknown-linux-gnu/captive/stage/home/anilj/workspace/xugglehome/lib --disable-shared --enable-pic --enable-gpl --enable-nonfree --enable-libx264 --enable-version3 --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libvo-aacenc --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-openssl --enable-zlib --enable-libvpx
Input #0, flv, from 'input/internetCrashing.flv':
Metadata:
starttime : 0
totalduration : 344
totaldatarate : 299
bytelength : 12850666
canseekontime : true
sourcedata : B4A7DD5A3MM1402426875642882
purl :
pmsg :
Duration: 00:05:43.97, start: 0.000000, **bitrate: 298 kb/s**
Stream #0:0: Video: flv1, yuv420p, 400x226, 263 kb/s, 29.97 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16, 56 kb/s
At least one output file must be specified
输出视频:
anilj@desk1:~/workspace/androws/XuggleMedia$ ffmpeg -i output/output1.flv
ffmpeg version N-36083-g2501f93-xuggle-5.5 Copyright (c) 2000-2012 the FFmpeg developers
built on Jun 3 2014 13:43:04 with gcc 4.6.4
configuration: --prefix=/home/anilj/workspace/xugglehome --extra-version=xuggle-5.5 --extra-cflags=-I/home/anilj/workspace/xuggle-xuggler/build/native/x86_64-unknown-linux-gnu/captive/stage/home/anilj/workspace/xugglehome/include --extra-ldflags=-L/home/anilj/workspace/xuggle-xuggler/build/native/x86_64-unknown-linux-gnu/captive/stage/home/anilj/workspace/xugglehome/lib --disable-shared --enable-pic --enable-gpl --enable-nonfree --enable-libx264 --enable-version3 --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libvo-aacenc --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-openssl --enable-zlib --enable-libvpx
Input #0, flv, from 'output/output1.flv':
Metadata:
encoder : Lavf54.3.100
Duration: 00:05:44.05, start: 0.000000, **bitrate: 935 kb/s**
Stream #0:0: Video: flv1, yuv420p, 226x400, 200 kb/s, 29.97 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
At least one output file must be specified
anilj@desk1:~/workspace/androws/XuggleMedia$
我发现比特率之间存在巨大差异(以BOLD显示)。我无法理解这个比特率是如何变化的,以及我在哪里从Xuggle API控制它。
我使用下面的代码进行处理。请注意,我使用的视频输入参数相同。
public void onAddStream(IAddStreamEvent event) {
int streamIndex = event.getStreamIndex();
IStreamCoder streamCoder = event.getSource().getContainer()
.getStream(streamIndex).getStreamCoder();
if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {
streamCoder.setBitRate((int) audioBitRate);
writer.addAudioStream(streamIndex, streamIndex, audioChannelCount, audioSampleRate);
} else if (streamCoder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {
streamCoder.setWidth(VIDEO_WIDTH);
streamCoder.setHeight(VIDEO_HEIGHT);
streamCoder.setBitRate((int) videoBitRate);
writer.addVideoStream(streamIndex, streamIndex, VIDEO_WIDTH, VIDEO_HEIGHT);
}
super.onAddStream(event);
}
public void onVideoPicture(IVideoPictureEvent event) {
IVideoPicture pic = event.getPicture();
if (videoResampler == null) {
videoResampler = IVideoResampler.make(VIDEO_WIDTH, VIDEO_HEIGHT,
pic.getPixelType(), pic.getWidth(),
pic.getHeight(), pic.getPixelType());
}
IVideoPicture out = IVideoPicture.make(pic.getPixelType(), VIDEO_WIDTH, VIDEO_HEIGHT);
videoResampler.resample(out, pic);
IVideoPictureEvent asc = new VideoPictureEvent(event.getSource(), out, event.getStreamIndex());
super.onVideoPicture(asc);
out.delete();
}
public void onAudioSamples(IAudioSamplesEvent event) {
IAudioSamples samples = event.getAudioSamples();
if (audioResampler == null) {
audioResampler = IAudioResampler.make(audioOutputChannels, samples.getChannels(), audioOutputRate, samples.getSampleRate());
}
if (event.getAudioSamples().getNumSamples() > 0) {
IAudioSamples out = IAudioSamples.make(samples.getNumSamples(), samples.getChannels());
audioResampler.resample(out, samples, samples.getNumSamples());
AudioSamplesEvent asc = new AudioSamplesEvent(event.getSource(), out, event.getStreamIndex());
super.onAudioSamples(asc);
out.delete();
}
}
我在这里遗漏了什么,这会导致问题吗?