Convert Transparent PNGs to a Transparent Video - ffmpeg

I have a set of transparent PNG pictures, and I want to convert them into a video with transparent background (play the PNGs continuously).
First, I used ffmpeg with the terminal command:
ffmpeg -framerate 30 -pattern_type glob -i '*.png' \-c:v libx264 -pix_fmt yuva420p out.mp4
And I learnt that the codec libx264 does not compatible with the alpha channel. Then, I changed to another codec and used the following command:
ffmpeg -framerate 30 -pattern_type glob -i '*.png' \-c:v libvpx-vp9 -pix_fmt yuva420p out.mp4
However, QuickTime Player cannot play the resulting out.mp4. I don't know if it was because the video conversion failed or it was the fault of QuickTime Player. The terminal didn't show any error message, though.
Therefore, I would like to ask:
Which codec I should use to create a transparent video that a normal video player can play?
Can the output MP4 video format support transparent videos?
If there is another tool that is far more superior than ffmpeg for my purpose, I am willing to give it a try.
Thank you for any advice.
All the best,
Aurora

few formats and video encoders support transparency:
-c:v prores -pix_fmt yuva444p10le logo.mov
-c:v ffv1 -pix_fmt yuva420p logo.mkv
and, with bad compatibility
-c:v libvpx-vp9 -pix_fmt yuva420p logo.webm
-c:v apng -pix_fmt rgba logo.apng

Related

Converting a large number of MP3 files to videos for YouTube, each using same the JPEG image

I am looking for a way to convert large number of MP3 files to videos, each using the same image. Efficient processing time is important.
I tried the following:
ffmpeg -i image.jpg -i audio.mp3 -vcodec libx264 video.mp4
VLC media player played the resulting video file with the correct sound, but a blank screen.
Microsoft Media Player played the sound and showed the intended image. I uploaded the video to YouTube and received the message:
"The video has failed to process. Please make sure you are uploading a supported file type."
How can I make this work?
Create video:
ffmpeg -framerate 6 -loop 1 -i input.jpg -c:v libx264 -vf format=yuv420p -t 00:10:00 video.mp4
The duration (-t) should be ≥ the MP3 with the longest duration.
Now stream copy the same video for each MP3:
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -c copy -movflags +faststart -shortest output.mp4
Some notes regarding compatibility:
MP3 in MP4 does not have universal support, but will be fine in YouTube. If your target players do not like it then add -c:a aac after -c copy to output AAC audio.
If your target player does not like it then increase the -framerate value or add the -r output option with an appropriate value, such as -r 15. Again, YouTube should be able to handle it.

FFMPEG, any video to 16:9

Help me find a command or script that will convert any video to 16:9, h264 and ~2500kbps. I have a server where people upload videos of different quality, size and length. It can be either 640x480 or 1216x2160. Ultimately, I need to get any resolution to 16:9 (with black borders, if needs) and bitrate without visible loss of quality, which will be acceptable for online broadcasting.
I have this command, but it does not check the resolution of the video. And if the video was 560x448 1000kbps and 700mb, then after conversion it will be 1280x720 3000kbps and 1.5gb, that's not right.
ffmpeg -i 5.avi -vcodec libx264 -crf 23 -preset veryfast -vf scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1 -tune zerolatency highoutput.mp4
Please try the following as a starting point:
ffmpeg -i "5.avi" -vcodec libx264 -crf 23 -vf "scale=w=trunc(ih*dar/2)*2:h=trunc(ih/2)*2, setsar=1/1, scale=w=1920:h=1080:force_original_aspect_ratio=1, pad=w=1920:h=1080:x=(ow-iw)/2:y=(oh-ih)/2:color=#000000" "output.mp4"
Please tweak the crf value depending on the picture quality.
Use
-vf scale=iw*sar:ih,setsar=1,pad='max(iw+mod(iw,2),2*trunc(ih*16/9/2))':'max(ih+mod(ih,2),2*trunc(iw*9/16/2))':-1:-1

ffmpeg: Is there a way to create video from images and overlay on image at same time?

I am trying to create a video from still images using ffmpeg. The command I use to do this is
ffmpeg -y -r 3 -i input_images%03d.png -c:v libx264 -vf fps=24 -pix_fmt yuv420p output.mp4
However, I would like to overlay this video on still image, without creating a video of the still image first. So, for example, if I have the following images
[still, frame1, frame2, frame3]
I'd like a command to create a video of frame1, frame2, and frame3 overlayed on still.
all with one command. Is there a way to do this?
I've looked at several answers to related problems (e.g., Add image overlay on video FFmpeg) but they don't answer my question, exactly.
Use
ffmpeg -framerate 24 -i still.png -framerate 3 -i input_images%03d.png -c:v libx264 -filter_complex "overlay=x='(W-w)/2':y='(H-h)/2'" -pix_fmt yuv420p -y output.mp4

Create Seamless Video and Crop Video in one command

I have a ffmpeg command that convert a video for seamless loop. But now i want to crop Video as well in same command.
is there any solution to do crop video 720x720 in same command
--Seamless Commmand--
ffmpeg -i video.mp4 -filter_complex [0:v]split[body][pre];[pre]trim=duration=1,format=yuva420p,fade=d=1:alpha=1,setpts=PTS+(28/TB)[jt];[body]trim=1,setpts=PTS-STARTPTS[main];[main][jt]overlay -c:v libx264 -strict experimental out.mp4
Change [0:v]split[body][pre] to [0:v]crop=720:720,split[body][pre]

why is streaming to an flv server with ffmpeg only showing black/blank video for clients?

When I stream to an flv server, like flash media server, using ffmpeg, like
ffmpeg -i input -vcodec libx264 rtmp://hostname/streamname
it turns out black. Why is that?
Turns out that in "more recent" versions of ffmpeg, the default x264 pixel format is "yuv422p" which isn't supported by most commercial encoders.
Fix: specify -pix_fmt yuv420p or -pix_fmt yuyv422 for the x264 format.

Resources