How to create an image using images with FFMPEG? - image-processing

How to create an image using images with FFMPEG? Something like below?
-f lavfi -i color=c=white:s=1080x1920 -loop 1 -i 1.png -loop 1 -i 2.png -filter_complex [0:v][1:v]overlay=shortest=1:x=0:y=0[v1];[v1][2:v]overlay=shortest=1:x=10:y=10 -vframes 1 -q:v 5

Found out by myself
-f lavfi -i color=c=white:s=1080x1920 -loop 1 -i 1.png -loop 1 -i 2.png -filter_complex [0:v][1:v]overlay=shortest=1:x=0:y=0[v1];[v1][2:v]overlay=shortest=1:x=10:y=10 -r 1 -vframes 1 -pix_fmt yuv420p -c:v libx264 export.jpg

Related

FFMPEG to periscope or twitter

In twitter studio to stream they specify
RTMP URL rtmp://va.pscp.tv:80/x
RTMPS URL rtmps://va.pscp.tv:443/x
but when I do
ffmpeg -re -i file.webm -c:v libx264 -preset ultrafast -vf "scale=-2:1080" -g 60 -pix_fmt yuv420p -c:a aac -b:a 128k -ac 2 -r 30 -vb 900k -minrate 900k -maxrate 900k -bufsize 900k -ar 44100 rtmps://va.pscp.tv:443/x/
I get this error
Unable to find a suitable output format for rtmps://va.pscp.tv:443/x/key: Invalid argument
I tried with and without the x but nothing goes, still same error
how to fix this
Turns out it was only missing -f flv
ffmpeg -re -i str_CAM_HGgs_con_XZQOm4Zem0.webm -c:v libx264 -preset ultrafast -vf "scale=-2:1080" -g 60 -pix_fmt yuv420p -c:a aac -b:a 128k -ac 2 -r 30 -vb 900k -minrate 900k -maxrate 900k -bufsize 900k -ar 44100 -f flv rtmps://va.pscp.tv:443/x/{KEY}

Streamed video frames going upside down

I'm new to FFMPEG. I'd used:
ffmpeg -re -y -f rawvideo -vcodec rawvideo -s 1920x1080 -pix_fmt bgr24 -i - -an -preset ultrafast -pix_fmt yuv420p -vcodec libx264 -f flv rtmp://rtmp_url/app/instance
this command. I'd got the successful streaming but the frames are distorted and moving upside down.
Below is the link to the snapshot of the frame.
Image of the upside down frame
Please help me out with this one.

Overlaying alpha images on a video using ffmpeg

I have the following ffmpeg-cli command which does not produce the described effect in documentation. Could this be a bug, or I have something wrong with the command.
ffmpeg \
-y \
-i small.mp4 \
-i monkey/monkey_%04d.png \
-filter_complex "[0:v][1:v]overlay=enable='between(t,1,5)'[out1]" \
-map '[out1]' \
output.mp4
I expect it to overlay the #1 stream on top of #0 between seconds 1 and 5.
You may download the test tarball from this link:
https://drive.google.com/file/d/0BxIQVP1zErDPYXRveG9hN0c0Qjg/view?usp=sharing
It includes assets for the test case.
The build I tried with:
ffmpeg-3.0.2-64bit-static (available online)
FFmpeg is a time-based processor i.e. it aligns packets by timestamps, so you have to align the start of the image sequence to the start of the overlay.
ffmpeg \
-y \
-i small.mp4 \
-i monkey/monkey_%04d.png \
-filter_complex "[1:v]setpts=PTS-STARTPTS+(1/TB)[1v]; \
[0:v][1v]overlay=enable='between(t,1,5)'[out1]" \
-map '[out1]' \
output.mp4

ImageMagick mogrify/convert performance slow when over 1120 pixels on resize

I am using IM to resize an image, like this;
mogrify -path . \
-format 1120.jpg \
-filter Triangle \
-define filter:support=2 \
-scale 1120 \
-unsharp 0.25x0.08+8.3+0.045 \
-dither None \
-posterize 136 \
-quality 82 \
-define jpeg:fancy-upsampling=off \
-define png:compression-filter=5 \
-define png:compression-level=9 \
-define png:compression-strategy=1 \
-define png:exclude-chunk=all \
-interlace none \
-colorspace sRGB \
0c7c93160ef416ed39ed7600b17a017b.jpg
Works really good, and just takes a couple of seconds. But if I increase the size of the output file by 1 pixel, from 1120 to 1121 it takes about 2 minutes to complete.
mogrify -path . \
-format 1121.jpg \
-filter Triangle \
-define filter:support=2 \
-scale 1121 \
-unsharp 0.25x0.08+8.3+0.045 \
-dither None \
-posterize 136 \
-quality 82 \
-define jpeg:fancy-upsampling=off \
-define png:compression-filter=5 \
-define png:compression-level=9 \
-define png:compression-strategy=1 \
-define png:exclude-chunk=all \
-interlace none \
-colorspace sRGB \
0c7c93160ef416ed39ed7600b17a017b.jpg
I do not understand why that should be.
I did read somewhere that -resize (and -thumbnail) increase the image internally to 5 times what the final output will be, in order to do some operations on it. (5x1120)^2 is quite close to 32,000,000 which I think is some kind of magic number in computers. Anyway, I don't really know why.
Can anyone suggest an alternative way of resizing that does not have this draw back.

How to swap SBS LR 3D videos?

I have this command
ffmpeg -i "D:\Neuer Ordner\Test.mkv" -c copy -ss 00:00:00 -t 00:08:00 -sn "D:\Neuer Ordner\Test1.mkv" -c copy -ss 00:08:00 -t 00:08:00 -sn "D:\Neuer Ordner\Test2.mkv" -c copy -ss 00:16:00 -t 00:08:00 -sn "D:\Neuer Ordner\Test3.mkv" -c copy -ss 00:24:00 -sn "D:\Neuer Ordner\Test4.mkv"
My goal is to upload them to youtube. Yet I need to swap each pair before converting it, so left becomes right and right becomes left.
I found the complex filter and tried
ffmpeg -i "D:\Neuer Ordner\Test.mkv" -filter:v "crop=1280:720:0:0" -i "D:\Neuer Ordner\Test.mkv" -filter:v "crop=1280:720:1280:0" -filter_complex "pad=in_w*2:in_h, overlay=main_w/2:0, scale=in_w/2:in_h, scale=-1:720" -c:a copy "D:\Neuer Ordner\output.mkv"
Which led to
Option filter:v (set stream filtergraph) cannot be applied to input file D:\Neuer Ordner\Test.mkv -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file D:\Neuer Ordner\Test.mkv.
Error opening input files: Invalid argument
Which command solves this?
Try this instead:
ffmpeg -i "D:\Neuer Ordner\Test.mkv" \
-c copy -ss 00:00:00 -t 00:08:00
-metadata stereo_mode=right_left -sn "D:\Neuer Ordner\Test1.mkv" \
-c copy -ss 00:08:00 -t 00:08:00 \
-metadata stereo_mode=right_left -sn "D:\Neuer Ordner\Test2.mkv" \
-c copy -ss 00:16:00 -t 00:08:00 \
-metadata stereo_mode=right_left -sn "D:\Neuer Ordner\Test3.mkv" \
-c copy -ss 00:24:00 -metadata stereo_mode=right_left -sn "D:\Neuer Ordner\Test4.mkv"

Resources