Skip to content

Example 10: change aspect ratio

rosariod edited this page Jul 5, 2019 · 2 revisions

FFmpegBuilder builder = new FFmpegBuilder() .setInput(pathFileInput) // Filename, or a FFmpegProbeResult //.setInput(pathFileLogo) .addInput(pathFileLogo) .overrideOutputFiles(true) // Override the output if it exists .setComplexFilter("overlay="+position_width+":"+position_height+"")

		  .addOutput(pathFileOutput)   // Filename for the destination
		   .setFormat("mp4")        // Format is inferred from filename, or can be set
		   .setAudioBitRate(bitRateAudio)      // at 32 kbit/s*/
		    //.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
		    .setVideoResolution(height, width) // at 640x480 resolution
		    .setVideoBitRate(bitRateVideo)			    
		    .addExtraArgs("-aspect","16:9")//means to change the aspect ratio and add argument "-aspect 4:3" to ffmpeg command line
		    .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
		    .done();

Clone this wiki locally