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
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 am using the following commandline under windows to convert a video file to individual frames for use of a project. But the project will eventually use a 16bit RGB565 palette. Is it possible to use palettegen to create a 256 colour rgb565 palette instead of rgb888? I want to cut down the colour depth before reducing the images to 256 colours in the hopes of a slightly better fit for the palette.
ffmpeg -y -i "input.mpg" -filter_complex "fps=15,scale=220:-1:flags=bilinear:sws_dither=none[x];[x]split[x1][x2];[x1]palettegen=reserve_transparent=off:stats_mode=single:max_colors=256[p];[x2][p]paletteuse=new=1:dither=none" frames/%%03d.bmp
Thanks.
paletteuse outputs pal8 which is paletteized 8-bits (see ffmpeg -pix_fmts).
The bmp encoder supports these pixel formats: bgra bgr24 rgb565le rgb555le rgb444le rgb8 bgr8 rgb4_byte bgr4_byte gray pal8 monob (see ffmpeg -h encoder=bmp).
By default the output encoder will automatically select the closest matching pixel format supported by the encoder. In this case the bmp encoder directly supports pal8, so pal8 will be used.
If you want to force conversion to a different pixel format use the format filter:
ffmpeg -i "input.mpg" -filter_complex "fps=15,scale=220:-1:flags=bilinear:sws_dither=none[x];[x]split[x1][x2];[x1]palettegen=reserve_transparent=off:stats_mode=single:max_colors=256[p];[x2][p]paletteuse=new=1:dither=none,format=rgb565le" frames/%03d.bmp
I have two problems with FFmpeg, when I use it to join DNG files sequence into mp4 video file. I also need to downgrade the resolution of the video from 6016x3200 to 2030x1080.
First of all I got almost black screen in the resulting video. Had to play with gamma and brightness options. But it was not enough!
New problems:
something strange happens with aspect ratio in resulting video file: in the first frame aspect is normal, just like in the original picture, but all the rest frames are getting squeezed. can't figure out why this happen!? (see picture attached).
colors are desaturated. despite the fact that I set "saturation" option to the maximum value. and also, the first frame of the video is different from the rest (while DNG files are all similar, first is no exception)
I tried prores codec as well, with the same result.
command I use is simple:
ffmpeg.exe -start_number 1 -i "K:\video\copter_R%5d.dng" -c:v libx264 -vf "fps=25,format=yuv420p, eq=gamma=3.2:brightness=0.2:contrast=1.6:saturation=3, scale=w=2030:h=1080" e:\output.mp4
I tried to use different variants of scale parameter: "scale=-1:1080" as well.
Illustration:
UPDATE: ffmpeg log report for operation:
https://drive.google.com/file/d/1H6bdpU0Eo4WfR3h-SRtgf7WBNYVFRwz2/view?usp=sharing
I have a quick time video file, video stream is in motion jpeg format, I extract every frame in the file with
ffmpeg -i a.mov -vcodec copy -f image2 %d.jpg
I found that in every jpeg file, there are actually two FFD8 marker, which means there are actually two images in one single jpeg file.
Is this correct? Is the file interlaced? Anything special need to pass to codec?
Yes, motion Jpeg supports interlaced format. If the jpeg file is half of the full video size, will mean that the mov is interlaced, and you cannot use -vcodec copy to extract the frames. Try ffmpeg -deinterlace or use yadif filter.
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.