I am generating an animated gif from an mp4 ... but due (I think) to color reduction (gif requires -pix_fmt rgb24) the result is somewhat ... blotchy? like running an image through an oil paint (or maybe "posterize") special effect filter. I think that the quality could be better, but I don't know what to tweak.
Not sure about this ... but ooking at the color palette of the resulting gif in an image editor it does not even appear to have attempted to create a color palette specific to this clip, but instead is attempting to us a generic palette ... which wastes a lot of pixmap space. That is, if I am interpreting this correctly.
Any tips on preserving the original video image instead of getting a "posterized" animated gif?
To get better looking gifs, you can use generated palettes. palettegen filter will generate a png palette to use with the paletteuse filter.
ffmpeg -i input.mkv -vf palettegen palette.png
ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif
You can try using -vf format=rgb8,format=rgb24.
Related
I need to add a text to a video using ffmpeg and it needs to be with perspective like in the image.
img
i have tried with perspective but i get perspective into the whole video not only the text.
How can i do this?
You want to add a text overlay, so your best option is to pick a perspective font and use that, with the drawtext filter.
Here's an example with the font Therp. It isn't perfect but might point you in the right direction.
ffmpeg -i input.mp4 -vf "drawtext=fontfile=./.fonts/Therp.ttf:text='Perspective': x=300: y=300:font='Therp Regular':fontsize=40:fontcolor=white:" -c:a copy -f matroska - | ffplay -autoexit -i -
Result:
I have a set of transparent images, where each one represents a frame of a video. I know that I can overlay them on top of another video using -i %d.png. What I want to be able to do is turn them into a transparent video ahead of time, and then later be able to overlay that transparent video onto another video. I've tried just doing -i %d.png trans.mov and then overlaying trans.mov on top of another video, but it doesn't seem like trans.mov is actually transparent.
You have to use an encoder that supports transparency/alpha channel. You can view a list of encoders with ffmpeg -h encoders and get further details with ffmpeg -h encoder=<encoder name>, such as ffmpeg -h encoder=qtrle. Then refer to the Supported pixel formats line: if has as "a" in the supported pixel format name, such as rgba, then it supports alpha. See a general list of pixel formats with ffmpeg -pix_fmts.
The simplest solution is to mux the PNG files into MOV:
ffmpeg -framerate 25 -i %d.png -c copy output.mov
Similar to what alphamerge / alphaextract do, but instead of having two sources I want to use three
InputVideo1, AlphaofInputVideo1, BackgroundVideo
The idea would be to overlay inputvideo1 on top of backgroundvideo using AlphaofInputVideo1 to do a more accuracte blending. Is this possible? Using intermediate steps (e.g. using alphamerge and generate intermediate rgba bitmaps) is acceptable.
Basic syntax for this operation is
ffmpeg -i input -i alpha -i bg -filter_complex "[0][1]alphamerge[ia];[2][ia]overlay" out.mp4
The frame sizes of input and alpha must be the same. So should the framerate and framecount to avoid misaligned merges.
I'm trying to convert a video with black bars, to one without and if the source is 4k, I want the video to be converted to 1080p
Now to do this, I'm using the following command:*
ffmpeg -i input ... -filter:v "crop=..." -filter:V "scale=1920:-1" ouput
But running this, I found that the end product still has said black bars and is 1920x1080 as opposed to the 1920x800 I'd expect.
What gives, why does this not work?
*: Other settings have been left out for convenience.
I got it to work by putting both the crop and the scale in the same -vf tag. I was cropping and then increasing the size of an old video game, and I just did this:
-vf crop=256:192:2:16,scale=-2:1080:flags=neighbor
I knew it worked as soon as I saw it display the output file size as 1440x1080 (4:3 ratio at 1080p).
how to mirror + add logo to video?
How to mirror video, then add logo to video using ffmpeg?
To flip a video horizontally, you can use -vf hflip (or vflip for vertical flipping).
To add a watermark of any image to a video is more complex, especially if you want to position it:
-i logo.png -filter_complex "overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2"
There are a lot of things you can do with the overlay filter, check the documentation. It gets extremely complex if you also want to scale the overlay, so make sure your logo file is the right size before that.
However, you cannot mix -vf and -filter_complex, so the flipping has to become part of the complex filter. So, for your desired result, you'd have to do this (assuming you want the logo to be at position 10/10):
ffmpeg -i input.mp4 -i logo.png -filter_complex "hflip[flipped];[flipped]overlay=x=10:y=10" out.mp4