0
我想合併圖像和音頻文件以創建視頻輸出。 我可以從命令行執行它: ffmpeg -loop 1 -i /tmp/image.jpeg -i /tmp/audiot.mp3 -vf'scale = 320:trunc(ow/a/2)* 2 '-acodec libvo_aacenc -b:192k -shortest /tmp/output.mp4ffmpeg-cli-wrapper:無法將圖像和音頻(mp3)輸入合併到視頻輸出(mp4)
但是當我試圖用ffmpeg-cli-wrapper java實現相同的行爲時,程序只是無限期地運行。 Raised issue on GitHub too.
我找不到這個在線的任何示例。如果有人知道如何使用相同或任何其他框架來實現此行爲,請告訴我。 這是我的示例測試java程序。
FFmpeg ffmpeg = new FFmpeg("/usr/bin/ffmpeg/ffmpeg");
FFprobe ffprobe = new FFprobe("/usr/bin/ffprobe");
FFmpegBuilder builder = new FFmpegBuilder()
.setInput("/tmp/image.jpeg")// Filename, or a FFmpegProbeResult
.addInput("/tmp/audio.mp3")
.addExtraArgs("-loop","1")
.overrideOutputFiles(true) // Override the output if it exists
.addOutput("/tmp/output.mp4") // Filename for the destination
.setFormat("mp4") // Format is inferred from filename, or can be set
//.setTargetSize(250_000) // Aim for a 250KB file
//.disableSubtitle() // No subtiles
//.setAudioChannels(1) // Mono audio
.setAudioCodec("aac") // using the aac codec
.setAudioSampleRate(48_000) // at 48KHz
.setAudioBitRate(32768) // at 32 kbit/s
.setVideoCodec("libx264") // Video using x264
.setVideoFrameRate(24, 1) // at 24 frames per second
.setVideoResolution(640, 480) // at 640x480 resolution
//.setComplexVideoFilter("scale=320:trunc(ow/a/2)*2")
.setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
.done();
FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
// Run a one-pass encode
executor.createJob(builder).run();