Recherche avancée
Médias (91)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
-
Stereo master soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Sur d’autres sites (352)
-
FFmpeg - record from stream terminating unexpectedly using kokorin/Jaffree ffmpeg wrapper for Java
18 avril, par pyrmonI am programming a Spring Boot Application using Maven and Java 21. I am trying to record a stream from a url and save it to a mkv file. I intend to do this with kokorin/Jaffree in version 2023.09.10. The recording seems to work ok, however longer videos are terminating unexpectedly. Sometimes after 5 minutes, other times an hour or even longer. Sometimes with Exit Code 0 and sometimes with 1.


I have implemented the recording like this :


@Override
 public void startRecording(RecordingSchedule recordingSchedule) {
 logger.info("Starting recording for schedule with filename {}", recordingSchedule.getFileName());

 String m3uUrl = recordingSchedule.getM3uUrl();
 LocalDateTime endTime = timeUtils.parseStringToLocalDateTime(recordingSchedule.getEndTime());
 LocalDateTime stopTime = endTime.plusSeconds(20);
 String timeToRecord = timeUtils.calculateTimeToRecord(stopTime);
 Path outputPath = Paths.get("/recordings/" + recordingSchedule.getFileName());

 try {
 FFmpeg.atPath()
 .addInput(UrlInput.fromUrl(m3uUrl))
 .addArgument("-xerror")
 .addArguments("-reconnect", "5")
 .addArguments("-reconnect_streamed", "5")
 .addArguments("-reconnect_delay_max", "20")
 .addArguments("-t", timeToRecord)
 .addArguments("-c", "copy")
 .addOutput(
 UrlOutput.toPath(outputPath))
 .setLogLevel(LogLevel.WARNING)
 .execute();
 logger.info("Recording complete. Output file: {}", outputPath.toAbsolutePath());
 } catch (Exception e) {
 logger.error("Error recording M3U stream {}: {}", recordingSchedule.getFileName(), e.getMessage());
 }
 }



And I am calling the method like this :

executorConfig.executorService().submit(() -> ffmpegService.startRecording(recording));


Any ideas what I am doing wrong ?
Here are the log lines at the beginning and end of recording of the past two attempts :


2024-04-18T00:54:48.689+02:00 INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl : Starting recording for schedule with filename Example1.mkv
2024-04-18T00:54:48.697+02:00 WARN 1 --- [pool-2-thread-1] c.github.kokorin.jaffree.ffmpeg.FFmpeg : ProgressListener isn't set, progress won't be reported
2024-04-18T00:54:48.698+02:00 INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler : Command constructed:
ffmpeg -loglevel level+warning -i http://example.stream.url.com -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 10771 -c copy /recordings/Example1.mkv
2024-04-18T00:54:48.698+02:00 INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler : Starting process: ffmpeg
2024-04-18T00:54:48.701+02:00 INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler : Waiting for process to finish
2024-04-18T01:31:02.633+02:00 WARN 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [h264 @ 0x559cd22dd940] [warning] Increasing reorder buffer to 2
2024-04-18T01:31:02.633+02:00 INFO 1 --- [pool-2-thread-1] c.g.k.jaffree.process.ProcessHandler : Process has finished with status: 0
2024-04-18T01:31:02.734+02:00 INFO 1 --- [pool-2-thread-1] m.s.r.service.impl.FfmpegServiceImpl : Recording complete. Output file: /recordings/Example1.mkv

2024-04-18T03:54:48.678+02:00 INFO 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl : Starting recording for schedule with filename Example2.mkv
2024-04-18T03:54:48.678+02:00 WARN 1 --- [pool-2-thread-2] c.github.kokorin.jaffree.ffmpeg.FFmpeg : ProgressListener isn't set, progress won't be reported
2024-04-18T03:54:48.678+02:00 INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler : Command constructed:
ffmpeg -loglevel level+warning -i http://example.stream.url.com/ -n -xerror -reconnect 5 -reconnect_streamed 5 -reconnect_delay_max 20 -t 11431 -c copy /recordings/Example2.mkv
2024-04-18T03:54:48.678+02:00 INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler : Starting process: ffmpeg
2024-04-18T03:54:48.679+02:00 INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler : Waiting for process to finish
2024-04-18T04:57:22.256+02:00 WARN 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [h264 @ 0x55707ba988c0] [warning] Increasing reorder buffer to 3
2024-04-18T04:58:47.455+02:00 ERROR 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [NULL @ 0x55707ba988c0] [error] Picture timing SEI payload too large
2024-04-18T04:58:47.456+02:00 ERROR 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [NULL @ 0x55707ba988c0] [error] non-existing PPS 1 referenced
2024-04-18T04:58:47.456+02:00 WARN 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [matroska @ 0x55707ba9a380] [warning] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
2024-04-18T04:58:47.456+02:00 ERROR 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [matroska @ 0x55707ba9a380] [error] Can't write packet with unknown timestamp
2024-04-18T04:58:47.463+02:00 ERROR 1 --- [ StdErr] c.g.k.jaffree.process.BaseStdReader : [error] av_interleaved_write_frame(): Invalid argument
2024-04-18T04:58:47.463+02:00 INFO 1 --- [pool-2-thread-2] c.g.k.jaffree.process.ProcessHandler : Process has finished with status: 1
2024-04-18T04:58:47.564+02:00 ERROR 1 --- [pool-2-thread-2] m.s.r.service.impl.FfmpegServiceImpl : Error recording M3U stream Example2.mkv: Process execution has ended with non-zero status: 1. Check logs for detailed error message.



They were supposed to run nearly 3 hours and the other one over 3 hours. And with the timestamps you can see that they are not running nearly as long.
Thank you for your help !


-
FFmpeg dynamic cropping using sendcmd correct syntax ?
19 avril, par SulliI'm trying to dynamically crop a video using FFmpeg's
sendcmd
filter based on coordinates specified in a text file, but the crop commands do not seem to be taking effect. Here's the format of the commands I've tried and the corresponding FFmpeg command I'm using.

Following the documentation https://ffmpeg.org/ffmpeg-filters.html#sendcmd_002c-asendcmd, commands in the text file (
coordinates.txt
) like this :

0.05 [enter] crop w=607:h=1080:x=0:y=0;
0.11 [enter] crop w=607:h=1080:x=0:y=0;
...



Ffmpeg command :


ffmpeg -i '10s.mp4' -filter_complex "[0:v]sendcmd=f=coordinates.txt" -c:v libx264 -c:a copy -r 30 output.mp4



This doesn’t seem to do anything.


And with the commands in the text file (
coordinates.txt
) like this :

0.05 crop w 607, crop h 1080, crop x 0, crop y 0;
0.11 crop w 607, crop h 1080, crop x 0, crop y 0;
...



Ffmpeg command :


ffmpeg -i '10s.mp4' -filter_complex "[0:v]sendcmd=f=coordinates.txt,crop" -c:v libx264 -c:a copy -r 30 output.mp4



(following this answer https://stackoverflow.com/a/67508233/1967110)


This one does something, but something very messy. It looks like it crops at the correct x, but does not take into account the y, w or h, and it puts the crop at the right side of the input video.


Edit : what I’m trying to do is create a 607x1080 (portrait format, 9:16) video from a 1920x1080 video, with the x parameter varying across time (imagine sliding horizontally a 9:16 frame over a 16:9 video). So fixed w, h and y, just x varying.


I’m using this ffmpeg version :


ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
configuration: --prefix=/home/ffmpeg-builder/release --pkg-config-flags=--static --extra-libs=-lm --disable-doc --disable-debug --disable-shared --disable-ffprobe --enable-static --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-avfilter --enable-filters --enable-nvenc --enable-nvdec --enable-cuvid --toolchain=hardened --disable-stripping --enable-opengl --pkgconfigdir=/home/ffmpeg-builder/release/lib/pkgconfig --extra-cflags='-I/home/ffmpeg-builder/release/include -static-libstdc++ -static-libgcc ' --extra-ldflags='-L/home/ffmpeg-builder/release/lib -fstack-protector -static-libstdc++ -static-libgcc ' --extra-cxxflags=' -static-libstdc++ -static-libgcc ' --extra-libs='-ldl -lrt -lpthread' --enable-ffnvcodec --enable-gmp --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libkvazaar --enable-libmp3lame --enable-libopus --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libshine --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libvidstab --ld=g++ --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-openssl --enable-zlib --enable-nonfree --extra-libs=-lpthread --enable-pthreads --extra-libs=-lgomp



-
Cutting sections with -ss and -t is not frame accurate
16 avril, par Théo ChampionI'm using
ffmpeg 6.0
to extract small sections from longer videos. According to the doc i can use the-ss
option to specify the start time and the-t
option to specify the duration and this should result in frame accurate cuts (since FFmpeg 2.1).

However, in my testing i found that the cuts are not frame accurate. I'm using the following command :


ffmpeg -ss 10 -i ffmpeg -ss 10 -i https://storage.googleapis.com/klap-assets/Frame%20Counter%20%5B4K%2C%2060%20FPS%5D%20%E2%80%93%200100.mp4 -t 10 -y -vcodec libx264 -acodec aac -movflags +faststart out2.mp4 -t 10 -y -vcodec libx264 -acodec aac -movflags +faststart out.mp4



This result in a video that start at
9:57
(-2 frames) and ends at19:57
(-2 frames) instead of10:00
and20:00
.

Also weird is that ffprobe on the resulting video show its duration being exactly 10 seconds.


FFprobe of the resulting video :


ffprobe version 6.0 Copyright (c) 2007-2023 the FFmpeg developers
 built with Apple clang version 14.0.0 (clang-1400.0.29.202)
 configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
 libavutil 58. 2.100 / 58. 2.100
 libavcodec 60. 3.100 / 60. 3.100
 libavformat 60. 3.100 / 60. 3.100
 libavdevice 60. 1.100 / 60. 1.100
 libavfilter 9. 3.100 / 9. 3.100
 libswscale 7. 1.100 / 7. 1.100
 libswresample 4. 10.100 / 4. 10.100
 libpostproc 57. 1.100 / 57. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out2.mp4':
 Metadata:
 major_brand : isom
 minor_version : 512
 compatible_brands: isomiso2avc1mp41
 encoder : Lavf60.3.100
 Duration: 00:00:10.00, start: 0.000000, bitrate: 303 kb/s
 Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 287 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
 Metadata:
 handler_name : ISO Media file produced by Google Inc.
 vendor_id : [0][0][0][0]
 encoder : Lavc60.3.100 libx264
 Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
 Metadata:
 handler_name : ISO Media file produced by Google Inc.
 vendor_id : [0][0][0][0]



I've done some testing with other videos and results are never totally frame accurate.


What am i missing here ? How can i get frame accurate cuts with FFmpeg ?