请看一下这段代码示例。它应该从一个样本视频(30到40)减少10秒。
public Example() {
factory = new MediaPlayerFactory();
mediaPlayer = factory.newHeadlessMediaPlayer();
}
public void start(Semaphore semaphore) {
String fileName = "/home/damian/Videos/SampleVideo_1080x720_30mb.mp4";
Media media = new SimpleMedia(fileName);
mediaPlayer.playMedia(fileName, ":start-time=30", ":stop-time=40", ":sout=#transcode{vcodec=h264,vb=4096,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=" + "/home/damian/vout/v.mp4" + "}}");
mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {
@Override
public void finished(MediaPlayer mediaPlayer) {
mediaPlayer.stop();
mediaPlayer.release();
semaphore.release();
}
});
结果的问题是它总是在开始时包含0.5秒的初始样本。所以眨眼之间,我可以看到原始视频的开始,然后是10秒请求。有谁知道如何摆脱这个问题?