FFMpeg command output shows 'green pixelated' video - ffmpeg

I am trying to take a single image and add audio resulting in a video playing the entire song with that single image; much like you see for YouTube videos for songs. The command I am using is from this link: https://askubuntu.com/questions/868283/image-audio-mp4-how-to-make-video-smaller
This is the command:
ffmpeg -loop 1 -framerate 1 -i image.png -i song.aac -c:v libx264 -preset veryslow -crf 0 -c:a copy -shortest output.mp4
It works as intended for having the video file be a small size, and the song plays as well, but depending on the image I used, some of the images appear 'Green' when playing the video.
However though, this command works for any image used:
ffmpeg -loop 1 -framerate 1 -i image.jpg -i music.mp3 -c copy -shortest output.mp4
But the result is a very big file whereas I would like it to be smaller. Any help would be greatly appreciated! Thank you!
FFMpeg version: 4.3.1

The command you used from the answer you linked to is for YouTube specifically and even says, "your player probably won't like it but YouTube will". I'm assuming you're using a player and not YouTube.
In the same answer is another command under Widest compatibility for any player:
ffmpeg -loop 1 -i image.png -i music.mp3 -vf "scale='min(1280,iw)':-2,format=yuv420p" -c:v libx264 -preset medium -profile:v main -c:a aac -shortest -movflags +faststart output.mp4
Try that instead.

Related

How to replace the video track in a video file with a still image?

I am trying to use ffmpeg to replace the video track in a video file with a still image. I tried some commands I got from other questions such as the one here
ffmpeg -i x.png -i orig.mp4 final.mp4
ffmpeg -r 1/5 -i x.png -r 30 -i orig.mp4 final.mp4
But these didn't work. I'm not sure which of these arguments are required or not. The output should be accepted by YouTube as a valid video - I was able to simply remove the video track, but apparently they don't let you upload a video without a video track.
You can try looping the still image like this:
ffmpeg -loop 1 -i x.png -i orig.mp4 final.mp4
Then you can tweak the encoding process by introducing the following quality parameters:
ffmpeg -loop 1 -i x.png -i orig.mp4 -crf 22 -preset slow final.mp4
they are described here.
If your colorspace gets rejected by YouTube you can try adding: -pix_fmt yuv420p.
Solution: A final solution is something like this:
Where -t 30 is an example duration of 30 seconds.
Using -c:a copy will directly copy the original audio without a new re-encoding (is faster).
ffmpeg -loop 1 -i x.png -i orig.mp4 -map 0 -map 1:a -c:v libx264 -pix_fmt yuv420p -crf 22 -preset slow -c:a copy -shortest final.mp4

Merge one audio file and one image file to create a video with ffmpeg

I first tried:
ffmpeg -y -i image.jpg -i audio.mp3 -c:a copy output.mp4
but when I uploaded to video sharing websites (bilibili.com), it says "no video track", so I tried:
ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 1 -shortest output.mp4
The file was successfully uploaded, but when I watched it on the website, the image disappeared and it turned grey. I merged 6 videos and only one of them can be normally played back.
What should I do?
Problems with your command #2:
Frame rate is too low. Most players are unable to play 1 fps. Use 10 fps or higher for output, or set input -framerate to 10 fps or higher.
Chroma subsampling. Most players can only play 4:2:0, so use the format filter to force it to 4:2:0.
MP3 in MP4. Some players are unable to play MP3 in MP4. For highest compatibility use AAC. ffmpeg will choose AAC by default for MP4.
Faststart (optional). Add -movflags +faststart so MP4 can begin playback faster.
Command:
ffmpeg -framerate 1 -loop 1 -i image.jpg -i audio.mp3 -vf format=yuv420p -r 10 -shortest -movflags +faststart output.mp4

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.

Make video from images with ffmpeg/imagemagic

I want to convert jpg images to mp4 video without resizing image(keep original images size and well formated video)
I have tried lot's of solutions of ffmpeg and imagemagic (links given below)but both crop images after converting in video format and i want a video from images with original image size.
Solution will be appreciated with ffmpeg or imagemagick. :)
slow ffmpeg's images per second when creating video from images
image to video ffmpegf
FFMPEG An Intermediate Guide/image sequence
How can I create a video file from a set of jpg images? [duplicate]
How to create a video from images with FFmpeg?
FFmpeg
Make video from still image sequence
Combining images with ImageMagick
Imagemagick.org
ffmpeg -framerate 1/5 -i na%03d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4
on large image(1600X1200) its execute successfully but not generate a smooth video.
on small image(300x168) its show error. i also try this command on small image
ffmpeg -framerate 1/5 -i abc%03d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"
this work for me i use this in loop
ffmpeg -loop 1 -i na002.jpg -c:a copy -c:v libx264 -strict 1 -shortest -vf "scale='min(1280,iw)':min'(720,ih)':force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" test.mp4
ffmpeg -y -i video.mp4 -vf "scale='min(1280,iw)':min'(720,ih)':force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" out1.media
ffmpeg -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp0.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp1.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp2.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp3.mp4" -filter_complex "[0]setdar=16/9[a];[1]setdar=16/9[b];[2]setdar=16/9[c];[3]setdar=16/9[d];[a][0:a][b][1:a][c][2:a][d][3:a] concat=n=4:v=1:a=1[v][a]" -map "[outv]" -map "[outa]"

animation between images using FFmpeg

Hi I am new in FFmpeg,
I have made video from slideshow of sequential images (img001.jpg, img002.jpg, img003.jpg....). Using following commands in Ubuntu 14.04
ffmpeg -framerate 1/5 -i img%03d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p -vf scale=320:240 out.mp4
But now I want to put animation like fade-in, fade-out between each sequential images, I want to generate video,
can anybody help me how to make it, i have searched lots of things but could not get....
The best way to do this is create intermediate mpeg's for each image and then concatenate them all into a video. For example, say you have 5 images; you would run this for each one of the images to create the intermediate mpeg's with a fade in at the beginning and a fade out at the end.
ffmpeg -y -loop 1 -i image -vf "fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5" -c:v mpeg2video -t 5 -q:v 1 image-1.mpeg
where t is the duration, or time, of each image. Once you have all of these mpeg's, you use ffmpeg's concat command to combine them all into an mp4.
ffmpeg -y -i image-1.mpeg -i image-2.mpeg -i image-3.mpeg -i image-4.mpeg -i image-5.mpeg -filter_complex '[0:v][1:v][2:v][3:v][4:v] concat=n=5:v=1 [v]' -map '[v]' -c:v libx264 -s 1280x720 -aspect 16:9 -q:v 1 -pix_fmt yuv420p output.mp4
This gives you the desired video and is the simplest and highest quality solution with ffmpeg. Let me know if you have any questions about how the above command works.

Resources