Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
I need help setting up a FFmpeg command that adds a small watermark in the bottom right of the first 5 seconds of multiple videos [closed]
23 avril, par hwmThere are hundreds of videos that we'd like to add a small FFmpeg watermark to the bottom right during the first 5 seconds of each video. I don't know if there's a way to automate the command to all files in the folder, and if there is a way to make the output filename the same as the original video, or adding a -2 to the new filename. Some videos may have different file formats.
Not sure if there's an app that can facilitate this for someone not well versed in programming, or can help do it to all the videos with one command. This could potentially be done in Linux, Windows or Mac. If the command changes based on OS, please let me know what the process would be for that specific OS.
This is for a large project we are planning on releasing for free to the public fan space. Thanks!
I can likely find someone that's more competent than me but getting the full command line to make this seamless would be ideal.
-
ffmpeg xstack layout in python
23 avril, par konradI want to stack a n x n videos in a grid using ffmpeg. eg.: 4x4, 10x10, 12x12, ... Since i have a lot of videos the ffmpeg command is generated in python and then sequentially processed. The xstack filter expects a layout, which is formated in this way:
xstack=inputs=16:layout=0_0|0_h0|0_h0+h1|0_h0+h1+h2|w0_0|w0_h0|w0_h0+h1|w0_h0+h1+h2|w0+w4_0| w0+w4_h0|w0+w4_h0+h1|w0+w4_h0+h1+h2|w0+w4+w8_0|w0+w4+w8_h0|w0+w4+w8_h0+h1|w0+w4+w8_h0+h1+h2
For layouts with few videos i wrote the xstack filter by hand but for 60x60 videos it is unreasonable.
How can I generate the layout string in python given a grid of equal rows and columns?
-
Saving RTP stream on file for later conversion to MP4 format
23 avril, par Alberto PastoreI need to acquire a short RTP video stream (15 to 90 seconds) on a local on-premise small device. The device is not capable of creating natively a MP4 file by itself.
The device is simply saving RTP packets on a local dump file as received. This file is then sent to a remote server after the stream has ended.
I have no control on the local device (I cannot change its software or its behavior). I need to convert this RTP "dump" file to MP4 format on the remote server, where I can run my own software.
I am trying to figure out a quick&dirty way to perform this conversion without having to write too much "low level" code (i.e. reading the source file, analyzing packets, creating the destination MP4 and copying the encoded stream in the proper format...).
So far I've tried several combinations of ffmpeg command line switches but I was always unsuccesful.
Is there a way to perform this conversion without re-streaming the rtp packets live to ffmpeg?
-
Got Non-monotonic DTS in output stream 0:1 while concating videos using ffmpeg [closed]
23 avril, par ukkkkkkWhen I concat videos in this command:
ffmpeg -f concat -safe 0 -i filelist.txt -c copy -y new.mp4
And
filelist.txt
is:file 'video1_new.mp4' file 'new3.mp4' file 'video2_new.mp4'
I got
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0eec052c0] Auto-inserting h264_mp4toannexb bitstream filter [mp4 @ 0x7fe0eea04380] Non-monotonic DTS in output stream 0:1; previous: 9188352, current: 9187776; changing to 9188353. This may result in incorrect timestamps in the output file.
This warning results in unpredictable things while being played in certain players, so I can't the result video directly.
I have converted my videos to the same attributes by:
ffmpeg -i video1.mp4 -r 25 -c:v libx264 -c:a aac -vf setpts=PTS-STARTPTS video1_new.mp4 ffmpeg -i video2.mp4 -r 25 -c:v libx264 -c:a aac -vf setpts=PTS-STARTPTS video2_new.mp4 ffmpeg -i output.mp4 -r 25 -c:v libx264 -c:a aac -map "0:v" -map "0:a" -vf setpts=PTS-STARTPTS -y new3.mp4
The results of ffprobe are:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1_new.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.16.100 Duration: 00:03:11.41, start: 0.000000, bitrate: 349 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810, 271 kb/s, 25 fps, 25 tbr, 12800 tbn (default) Metadata: handler_name : Core Media Video vendor_id : [0][0][0][0] encoder : Lavc60.31.102 libx264 Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 71 kb/s (default) Metadata: handler_name : Core Media Audio vendor_id : [0][0][0][0] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video2_new.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.16.100 Duration: 00:03:11.41, start: 0.000000, bitrate: 349 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810, 271 kb/s, 25 fps, 25 tbr, 12800 tbn (default) Metadata: handler_name : Core Media Video vendor_id : [0][0][0][0] encoder : Lavc60.31.102 libx264 Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 71 kb/s (default) Metadata: handler_name : Core Media Audio vendor_id : [0][0][0][0] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'new3.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.16.100 Duration: 00:00:30.02, start: 0.000000, bitrate: 19 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810 [SAR 1:1 DAR 190:81], 11 kb/s, 25 fps, 25 tbr, 12800 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] encoder : Lavc60.31.102 libx264 Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 1 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0]
I have solved this by re-encoding while concatting by:
ffmpeg -f concat -safe 0 -i filelist.txt -c:v libx264 -c:a aac -r 25 -y new.mp4
But it cost too much time and too many CPU resources. Could you tell me how can I solve this problem without re-encoding while concating?
-
Generation thumbnail from video using ffmpeg [closed]
23 avril, par godvlprTry to create thumbnail from video using ffmpeg This command work perfectly:
ffmpeg -i test.mp4 -ss 00:00:00 -vframes 1 thumbnail.jpg
But I need to push video to ffmpeg from stdin, and find solution with pipe:
cat test.mp4 | ffmpeg -f mp4 -i pipe:0 -ss 00:00:00 -vframes 1 thumbnail.jpg
But it's not work for me. Error:
ffmpeg version 7.0 Copyright (c) 2000-2024 the FFmpeg developers built with Apple clang version 15.0.0 (clang-1500.3.9.4) configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --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-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x14f706460] stream 0, offset 0x30: partial file [mov,mp4,m4a,3gp,3g2,mj2 @ 0x14f706460] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1920x1080, 3496 kb/s): unspecified pixel format Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pipe:0': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.26.100 Duration: 00:00:02.01, start: 0.000000, bitrate: N/A Stream #0:0[0x1](und): Video: h264 (avc1 / 0x31637661), none, 1920x1080, 3496 kb/s, 25 fps, 25 tbr, 12800 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1[0x2](und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 96 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) [mov,mp4,m4a,3gp,3g2,mj2 @ 0x14f706460] stream 0, offset 0x30: partial file [in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x600002e2c400] Error during demuxing: Invalid data found when processing input Cannot determine format of input 0:0 after EOF [vf#0:0 @ 0x60000202c240] Task finished with error code: -1094995529 (Invalid data found when processing input) [vf#0:0 @ 0x60000202c240] Terminating thread with return code -1094995529 (Invalid data found when processing input) [vost#0:0/mjpeg @ 0x14f7080e0] Could not open encoder before EOF [vost#0:0/mjpeg @ 0x14f7080e0] Task finished with error code: -22 (Invalid argument) [vost#0:0/mjpeg @ 0x14f7080e0] Terminating thread with return code -22 (Invalid argument) [out#0/image2 @ 0x60000272c180] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A Conversion failed!
Tried on macos and ubuntu. What can be wrong here and how to fix this issue? Maybe exists other solutions without pipes, or something else..