ffmpeg stuck when using Channels to extract image close to the end of a video
See original GitHub issueThis problem is when using Channels.
I used this video file as input: https://file-examples-com.github.io/uploads/2020/03/file_example_WEBM_480_900KB.webm
The video has a length of 30540 milliseconds.
If I extract an image at 30.000 milliseconds on the console it works: /mnt/Data/software/ffmpeg-4.4-amd64-static/ffmpeg -loglevel level+info -ss 30.000 -i /mnt/Data/downloads/webm/file_example_WEBM_480_900KB.webm -y -frames:v 1 -q:v 1 -f image2 /mnt/Data/downloads/data.jpeg
When I try to repeat this in Jaffree, ffmpeg gets stuck and is never interrupted (see log below). I guess Channels are not the harddisk so there are small differences. No problem. Writing out at position 29500 works. However it is somewhat of a problem, that ffmpeg gets stuck and doesn’t throw an Exception. On the console ffmpeg never “freezes” even if you get close or over the video length. It just returns with an error: [warning] Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
try (SeekableByteChannel inputChannel = Files.newByteChannel(pathToSrc, StandardOpenOption.READ); SeekableByteChannel outputChannel = Files.newByteChannel(pathToDst, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ, StandardOpenOption.TRUNCATE_EXISTING) ) { FFmpeg.atPath() .addInput(ChannelInput.fromChannel(inputChannel).setPosition(30000)) .setOverwriteOutput(true) .addArguments("-frames:v", "1") .addArguments("-q:v", "1") .addOutput(ChannelOutput.toChannel(filename, outputChannel).setFormat("image2")) .execute(); }
[main] WARN com.github.kokorin.jaffree.ffmpeg.PipeOutput - It’s recommended to use ChannelOutput since ffmpeg requires seekable output for many formats [main] WARN com.github.kokorin.jaffree.ffmpeg.FFmpeg - ProgressListener isn’t set, progress won’t be reported [main] INFO com.github.kokorin.jaffree.process.ProcessHandler - Command constructed: ffmpeg -loglevel level+info -ss 30.000 -i ftp://127.0.0.1:38773/ -n -frames:v 1 -q:v 1 -f image2 tcp://127.0.0.1:44917 [main] INFO com.github.kokorin.jaffree.process.ProcessHandler - Starting process: ffmpeg [main] INFO com.github.kokorin.jaffree.process.ProcessHandler - Waiting for process to finish [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] ffmpeg version N-59310-gd115eec979-static https://johnvansickle.com/ffmpeg/ Copyright © 2000-2021 the FFmpeg developers [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] built with gcc 8 (Debian 8.3.0-6) [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libavutil 57. 7.100 / 57. 7.100 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libavcodec 59. 11.100 / 59. 11.100 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libavformat 59. 6.100 / 59. 6.100 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libavdevice 59. 0.101 / 59. 0.101 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libavfilter 8. 12.100 / 8. 12.100 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libswscale 6. 1.100 / 6. 1.100 [StdErr] INFO com.github.kokorin.jaffree.ffmpeg.FFmpegResultReader - [info] libswresample 4. 0.100 / 4. 0.100
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (9 by maintainers)
Top GitHub Comments
@shoeoffhead It looks like problem is related to ChannelInput and TS file. FFmpeg can’t seek TS (no syncpoints?), and has to read input file from the beginning looking for required start position. Check #244 for details. Expect to merge it soon.
@shoeoffhead it’s very interesting to me how do you use Jaffree? Especially how do you use ChannelInput/Output? Could you share such information?