ffmpeg-cli-wrapper icon indicating copy to clipboard operation
ffmpeg-cli-wrapper copied to clipboard

How to cut from the end AND how to concat several videos?

Open willy-wonka-git opened this issue 5 years ago • 5 comments

The ffmpeg-cli-wrapper library is a simple wrapper around the ffmpeg command line. If you have questions on how to use the library, please check out the usage, or random examples. If that doesn't solve your problem please fill out the following:

The question How to cut from the end AND how to concat several videos?

What you have tried I try to concat two videos. But can`t

willy-wonka-git avatar Jun 08 '19 20:06 willy-wonka-git

What have you tried? and how would you do it with just the pure ffmpeg command?

bramp avatar Jun 08 '19 20:06 bramp

What have you tried? and how would you do it with just the pure ffmpeg command?

I'm trying but not working. Windows

try {
    FFprobe ffprobe = new FFprobe("d:\\Distr\\ffprobe.exe");
    FFmpeg ffmpeg = new FFmpeg("d:\\Distr\\ffmpeg.exe");

    FFmpegProbeResult probeResult = ffprobe.probe("d:\\11111\\lqCfwIbG1EU.mp4");
    FFmpegFormat format = probeResult.getFormat();
    
    FFmpegStream  stream = probeResult.getStreams().get(0);
    
    FFmpegBuilder builder = new FFmpegBuilder()
            .setInput("d:\\11111\\list.txt") 
            .setFormat("concat") 
            .addExtraArgs("-safe", "0")
            .overrideOutputFiles(true) // Override the output if it exists
            .addOutput("d:\\11111\\output.mp4") // Filename for the destination
            //.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(1080, 720) // at 640x480 resolution

            .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
            .done();

        builder.setVerbosity(FFmpegBuilder.Verbosity.DEBUG);
    
    FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);

    // Run a one-pass encode
    executor.createJob(builder).run();

    // Or run a two-pass encode (which is better quality at the cost of being slower)
    //executor.createTwoPassJob(builder).run();
    
} catch (Exception e) {
    System.err.println(e);
}

ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 34.100 / 55. 34.100 libavcodec 57. 64.100 / 57. 64.100 libavformat 57. 56.100 / 57. 56.100 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 Splitting the commandline. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'. Reading option '-f' ... matched as option 'f' (force format) with argument 'concat'. Reading option '-safe' ... matched as AVOption 'safe' with argument '0'. Reading option '-i' ... matched as input file with argument 'd:\11111\list.txt'. Reading option '-strict' ...Routing option strict to both codec and muxer layer matched as AVOption 'strict' with argument 'experimental'. Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'. Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1080x720'. Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '24/1'. Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'aac'. Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '1'. Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'. Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '32768'. Reading option '-sn' ... matched as option 'sn' (disable subtitle) with argument '1'. Reading option 'd:\11111\output.mp4' ... matched as output file. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option v (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options: input file d:\11111\list.txt. Applying option f (force format) with argument concat. Successfully parsed a group of options. Opening an input file: d:\11111\list.txt. [file @ 000000000030ac40] Setting default whitelist 'file,crypto' [concat @ 000000000030a4e0] Impossible to open 'lqCfwIbG1EU.mp4' [AVIOContext @ 0000000000312d80] Statistics: 38 bytes read, 0 seeks d:\11111\list.txt: No such file or directory java.lang.RuntimeException: java.io.IOException: d:\Distr\ffmpeg.exe returned non-zero exit status. Check stdout.

willy-wonka-git avatar Jun 08 '19 21:06 willy-wonka-git

directory

09.06.2019 00:12 list.txt 08.06.2019 19:00 lqCfwIbG1EU.mp4 08.06.2019 18:26 outer24.mp4

list.txt: file lqCfwIbG1EU.mp4 file outer24.mp4

willy-wonka-git avatar Jun 08 '19 21:06 willy-wonka-git

Ok, I see two errors:

[concat @ 000000000030a4e0] Impossible to open 'lqCfwIbG1EU.mp4'
d:\11111\list.txt: No such file or directory

I'm assuming its opening list.txt, and then failing to find lqCfwIbG1EU.mp4. Could you try changing list.text to contain:

file d:\11111\lqCfwIbG1EU.mp4
file d:\11111\outer24.mp4

This might be a working directory problem.

bramp avatar Jun 08 '19 21:06 bramp

Ok, I see two errors:

[concat @ 000000000030a4e0] Impossible to open 'lqCfwIbG1EU.mp4'
d:\11111\list.txt: No such file or directory

I'm assuming its opening list.txt, and then failing to find lqCfwIbG1EU.mp4. Could you try changing list.text to contain:

file d:\11111\lqCfwIbG1EU.mp4
file d:\11111\outer24.mp4

This might be a working directory problem.

Yes. Thank you! Correct absolute pathes with double slashes: file d:\11111\lqCfwIbG1EU.mp4 file d:\11111\outer24.mp4

willy-wonka-git avatar Jun 08 '19 21:06 willy-wonka-git

I'll close this for now because the question seems answered. If necessary, feel free to reopen or create a new issue.

Euklios avatar Mar 11 '24 19:03 Euklios