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

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

Related

Convert mp4 video with joining animation mp4 + audio(wav, mp3) using ffmpeg shell command

I want to create .mp4 video by joining short animation(.mp4) + audio(wav, mp3) using ffmpeg shell command.
I have tried few commands to join mp4 + audio here is my example command which will generate output video.
./ffmpeg -y -i ./output/preview-2.mp4 -i ./output/audio-file.mp3 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -r 25 -vcodec libx264 -pix_fmt yuv420p ./output/converted-video.mp4
But I want to play my animation till audio playing. The above FFMPEG command only join my animation(short video .mp4) file with audio and stopped animation playing after duration of short video reached to end (let's say animation file duration is 10seconds and stopped playing after 10 seconds). But my audio is about 3 minutes and I want to re-play the animation video again and again till the audio file duration (3 minutes). Just like a looping effect.
Add -stream_loop -1 and -shortest:
./ffmpeg -y -stream_loop -1 -i ./output/preview-2.mp4 -i ./output/audio-file.mp3 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -r 25 -vcodec libx264 -pix_fmt yuv420p -shortest ./output/converted-video.mp4

FFMpeg command output shows 'green pixelated' video

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.

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 (windows7) can't get the output video to show more than 3 out of 10 jpgs

I have 10 jpg files (image0.jpg, image1.jpg, image2.jpg ... image9.jpg) and one .mp3 and I'm trying to create a video but I can't get it to show more than the first 3 images in the output.
I played with the output -r option and for example if I change it to 30 it shows all of them but very fast so the whole video plays for under a second.
This is my code:
ffmpeg -i image%d.jpg -i audio.mp3 -r 1 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -r 1/5 -pix_fmt yuv420p -shortest out.mp4
What am I doing wrong ?
The image file demuxer by default uses a frame rate of 25 fps if you do not tell it otherwise. Since you used -r 1/5 as an output option the frame rate will be converted resulting in duplicated or, as in your case, dropped frames to compensate. To change this use -framerate as an input option (this is a private option of the image file demuxer):
ffmpeg -framerate 1/5 -i image%d.jpg output
Some crappy players may not like a "non-standard" frame rate, so you can add an output frame rate to change it while keeping the "timing" of the input:
ffmpeg -framerate 1/5 -i image%d.jpg -r 25 output

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