Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How do I independently fade in/out multiple (3+) overlay images over video using FFMPEG ?
3 mars 2017, par blahblahberUsing an arbitrary source video, I would like to INDEPENDENTLY fade in/fade out a minimum of three .png overlays/watermarks at various times throughout the video. I'm having trouble getting the syntax right for the filter chain.
In these failed attempts below, I'm using four transparent .png images all at 1920x1080 using the same sized source input video. No scaling/positioning needed, just the overlays fading in and out at the defined times.
I have the functionality working without fade, unsing 'enable', like so:
ffmpeg -i vid1.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex "overlay=0:0:enable='between(t,8,11)' [tmp]; [tmp]overlay=0:0:enable='between(t,10,15)'[tmp1]; [tmp1]overlay=0:0:enable='between(t,15,138)'[tmp2]; [tmp2]overlay=0:0:enable='between(t,140,150)" -c:v libx264 -c:a copy -flags +global_header -shortest -s 1920x1080 -y out.mp4
I just want the same control, using fade in/out.
The following almost works as I'd like but I obviously don't want the entire output stream to fade out. I realize that adding the fade=out to lines 7, 8 & 9 is fading the combined output (starting at line 7), but this is as close as I've come where I see each overlay image actually fading. The defined fades in lines 3, 4 and 5 apparently don't affect anything, and that's where I defined them originally. When I copied them to the output stream, the fade works on each overlay image, but again I don't want it to affect the entire output stream, just the individual overlays.
ffmpeg -i vid1.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex "[1:v]fade=out:st=3:d=1[watermark0]; [2:v]fade=out:st=4:d=1[watermark1]; [3:v]fade=out:st=5:d=1[watermark2]; [4:v]fade=out:st=6:d=1[watermark3]; [0:v][watermark0] overlay=0:0 [tmp0]; [tmp0][watermark1] overlay=0:0,fade=out:st=4:d=1 [tmp1]; [tmp1][watermark2] overlay=0:0,fade=out:st=6:d=1 [tmp2]; [tmp2][watermark3] overlay=0:0,fade=out:st=8:d=1 [out]" -map "[out]" -c:v libx264 -c:a copy -flags +global_header -shortest -s 1920x1080 -y out.mp4
I've also tried 'split' with similar results to the above, but the fade only seems to work on the first image (this one uses fade in as well):
ffmpeg -i vid.mp4 -loop 1 -i img1.png -i img2.png -i img3.png -i img4.png -filter_complex "[1:v]split=4[wm1][wm2][wm3][wm4]; [wm1]fade=in:st=1:d=1:alpha=1,fade=out:st=3:d=1:alpha=1[ovr1]; [wm2]fade=in:st=2:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[ovr2]; [wm3]fade=in:st=3:d=1:alpha=1,fade=out:st=5:d=1:alpha=1[ovr3]; [wm4]fade=in:st=4:d=1:alpha=1,fade=out:st=6:d=1:alpha=1[ovr4]; [0:v][ovr1]overlay=0:0[base1]; [base1][ovr2]overlay=0:0[base2]; [base2][ovr3]overlay=0:0[base3]; [base3][ovr4]overlay=0:0[out]" -map "[out]" -t 10 -c:v libx264 -c:a copy -flags +global_header -shortest -s 1920x1080 -y out.mp4
Any help is greatly appreciated! :)
-
How to add a new filter to ffmpeg library
2 mars 2017, par CroolmanI am trying to add functionality to FFmpeg library. The issue is that in developer guide there are just general instruction on how to do it. I know that when I want to add something to ffmpeg I need to register the new functionality and rebuild the library so I can then call it somehow like so:
ffmpeg -i input.avi -vf "myfilter" out.avi
I do not want to officialy contribute. I would like to try to create the extra functionality and test it. The question is - is there any scelet file where the basic structure would be ready and you would just get a pointer to a new frame and processed it? Some directions or anything, because the source files are kinda hard to read without understanding its functions it calls inside.
-
how to convert RTPDUMP video file to mp4
2 mars 2017, par Asain KujovicViber recently got "instant video message" option, called also "video push-to-talk" (vptt).
Inside viber data in directory ".vptt" there are files with vptt extension. Envelope format is classic ZIP file, when extracted gives jpg-thumbnail and 'video' file.
Video file says "#!rtpplay1.0" inside first line, so it should be format of rtp-tools, used by wireshark too, and somehow related to actual WebRTC trends...
So if video content inside this rtpdump file is not encrypted ( ? ), "how to save viber instant message push to talk video" boils down to just: "how to convert rtpdump video to mp4".
rtpplay can send it to some port, but ffmpeg/ffplay/vlc needs correct sdp file.
does someone knows something further about this?
-
Sharing installed tools from one container to all containers with docker compose
2 mars 2017, par rbzI am pretty new with Docker, and understanding how containers work and work together. I am creating a LEMP stack where i have nginx and php7-fpm as seperate containers. Each one has a Dockerfile and basically creates all i need. My issue though is when installing tools (such as ffmpeg, exiftool, etc..) in one container, is not available with the other container.
Is there any possible to have these tools available within all containers?
-
FFmpeg (Thumbnail from video) works in command line, but not in PHP script
2 mars 2017, par Jun KimI looked at the similar questions, and the solutions there do not work in my case. Anyone has any idea? I am trying to capture a thumbnail from a given video file.
Later, my goal is to capture a thumbnail from live streaming video file.
Below is my current set up.
Linux Ubuntu 16.04
PHP version 7.0
Nginx Version 1.10.3
FFmpeg Version FFmpeg 2.8.11
I installed FFmpeg through below commands in my Ubuntu server.
apt-get update apt-get install ffmpeg
When I type the below command line in the terminal, it does the conversion fine.
ffmpeg -i /etc/nginx/html/test.mp4 -ss 00:00:01 -vframes 1 -vf scale=240:120 /etc/nginx/html/Share/ffmpeg/thumbnails/test.png;
In order to use it in php file, I confirmed the location of ffmpeg binaries by I typing in the terminal,
which ffmpeg
, and it returns/usr/bin/ffmpeg
I also gave permission to the directory by using
chmod 755
command line.Here is what I have in my ffmpeg.php file. I included the full path to my ffmpeg as you can see.
<?php header("Content-Type: text/html;charset=UTF-8"); $ffmpeg = "/usr/bin/ffmpeg"; $videoFile="/etc/nginx/html/test.mp4"; $thumbnail= "/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg"; $cmd = "$ffmpeg -i $videoFile -ss 00:00:01 -vframes 1 -vf scale=240:120 $thumbnail 2>&1 &"; $output = shell_exec($cmd); echo "
".$output."
"; ?>This returns the message like below.
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609 configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/etc/nginx/html/Share/test.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf53.24.2 Duration: 00:00:06.40, start: 0.000000, bitrate: 1321 kb/s Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : SoundHandler [swscaler @ 0x1621be0] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to '/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 encoder : Lavf56.40.101 Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 240x120 [SAR 20:23 DAR 40:23], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler encoder : Lavc56.60.100 mjpeg Stream mapping: Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native)) Press [q] to stop, [?] for help [image2 @ 0x16165a0] Could not open file : /etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail1.jpg av_interleaved_write_frame(): Input/output error frame= 1 fps=0.0 q=3.9 Lsize=N/A time=00:00:00.04 bitrate=N/A video:8kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Conversion failed!
UPDATED: I also gave permission to ffmpeg by chmod +x $(which ffmpeg)
I tried
php /etc/nginx/html/Share/ffmpeg/ffmpeg.php
in the terminal, and it also does conversion fine.libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/etc/nginx/html/Share/test.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf53.24.2 Duration: 00:00:06.40, start: 0.000000, bitrate: 1321 kb/s Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x368 [SAR 1:1 DAR 40:23], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : SoundHandler [swscaler @ 0x72dbe0] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to '/etc/nginx/html/Share/ffmpeg/thumbnails/thumbnail.jpg': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 encoder : Lavf56.40.101 Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 240x120 [SAR 20:23 DAR 40:23], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default) Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler encoder : Lavc56.60.100 mjpeg Stream mapping: Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native)) Press [q] to stop, [?] for help frame= 1 fps=0.0 q=3.9 Lsize=N/A time=00:00:00.04 bitrate=N/A video:8kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown