How can i add cover image on mp3 file using ffmpeg? - audio

I'm trying to convert audio file to mp3 and I want to add cover image into mp3 file.
I tried this:
ffmpeg.exe -i "input audio file" -i image.png out.mp3
When conversion completes there is no cover image into mp3.
I tried and this which is from the official documentation of ffmpeg. The result is the same mp3 file without cover image.
ffmpeg -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"-metadata:s:v comment="Cover (Front)" out.mp3
Thank you in advance!

Related

ffmpeg equivalent for sox -t ima

I am trying to use ffmpeg to combine 1 audio file (ADPCM) and 1 video file (h264) into single mp4. Video by file conversion works fine but ffmpeg chokes on guessing audio input. I can't figure out how to tell ffmpeg which params to use to decode raw audio file.
Currently I first run sox to convert raw audio to wav:
sox -t ima -r 8000 audio.raw audio.wav
... then feed audio.wav from sox as ffmpeg input
ffmpeg -i video.raw -i audio.wav movie.mp4
I am trying to avoid sox step and use audio.raw in ffmpeg.
Thank you
Since you have headless audio, you should tell ffmpeg about the sample format and (optionally) sample rate, audio channels, e.g.:
ffmpeg -i video.raw -f s16le -ar 22050 -ac 1 -i audio.raw movie.mp4
To check supported PCM formats you may use this command:
ffmpeg -formats 2>&1 | grep -i pcm

FFMPEG join multiple video lost audio

I am trying to join 2-3 videos it's working when all video has audio or without audio...
Command= "-f concat -i files.txt -codec copy output.mp4"
File.txt
file '0.mp4'
file '1.mp4'
file '2.mp4'
Now the issue is when 0.mp4 is without audio and 1.mp4 is with audio and when i join these videos full audio lost in output.. output will be without audio.
I want this join with all as it is like if 0.mp4 without audio then audio will not play for this and 1.mp4 play audio should play...
Finally got the answer.. need to first add silent audio in video files that don't have audio
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i 0.mp4 -shortest -c:v copy -c:a aac new_0.mp4
From here I concatenate as I did before, but replacing "0.mp4" in
File.txt with "new_0.mp4"
File.txt
file 'new_0.mp4'
file '1.mp4'
file '2.mp4'
Command= "-f concat -i files.txt -codec copy output.mp4"

Create Slideshow video by merge png and jpeg images and audio files using ffmpeg on linux

I am creating slideshow video using png,jpeg and audio files the issue i am getting is the at a time only either i have to use png or jpeg but i want to used both so how can i do this here are my list of commands which i am trying. Please help me regards this.
/usr/bin/ffmpeg '-framerate' '1/27' '-pattern_type' 'glob' '-i' '/var/www/html/phpvideotoolkit-v2-master/examples/media/images/*.jpg' '-i' '/var/www/html/phpvideotoolkit-v2-master/examples/media/1.mp3' '-pix_fmt' 'yuv420p' '-shortest' '-y' '-q' '4' '-strict' 'experimental' '-threads' '1' '-acodec' 'aac' '-ar' '22050' '-vcodec' 'mpeg4' '-s' '320x240' '/var/www/html/ffmpe/1.mp4'
By doing this i am only able to create jpg images video but i want to both.
i have used concat command also but not getting any output i have read about some filter but how to used with images i dont know so could you please help me with this.
FFmpeg supports piping of image sequences, so if you enable extended globbing it's simple enough to get all files ending in either .jpg or .png. However, FFmpeg seems to get confused if you pass it a mix of formats, so it's better to convert (using ImageMagick in this case) all images to PNG and then pass them on.
As you can see, all the images, even those already being PNG, will get converted. This is a bit inefficient, but unless you have lots of large images it shouldn't be too bad.
-quality 01 in the IM command makes sure the images are only minimally compressed. It makes little sense to spend a lot of time and effort on compression when FFmpeg will decompress immediately afterwards.
shopt -s extglob
convert \
/var/www/html/phpvideotoolkit-v2-master\
/examples/media/images/*+(.jpg|.png) -quality 01 png:- |\
/usr/bin/ffmpeg -y -framerate 1/27 \
-f image2pipe -i - \
-i /var/www/html/phpvideotoolkit-v2-master/examples/media/1.mp3 \
-pix_fmt yuv420p \
-shortest -q 4 -strict experimental -threads 1 \
-acodec aac -ar 22050 \
-vcodec mpeg4 -s 320x240 /var/www/html/ffmpe/1.mp4

Combining an image sequence with audio and make a video

I am trying to take a video extract the frames and the audio.Then i do some compression on the frames and then i want to combine the image frames with the audio to create the video.
1.Create frames from video based on fps (lossless)
ffmpeg -i big_buck_bunny_480p_surround-fix.avi -q:v 1 ./vidtest/out%d.jpg
The problem here is that the quality of the image is 94 based on graphicsmagick , how can i extract the frames at original quality.
2.Getting the audio
ffmpeg -i big_buck_bunny_480p_surround-fix.avi -vn -acodec copy big_buck_bunny_480p_surround-fix.ac3
3.How do i combine the audio with the image sequences
It seems like you already understand how to extract the audio stream from a video, so we'll skip that step.
Let's assume you have a video file named video.mp4 and an audio file named audio.mp3. You want to take stills from the video and create a slideshow with audio.mp3 as the audio track.
First we'll extract the stills. fps=1/10 means that frames will be extracted every tenth second. -ss 00:00:5 means that we'll begin five seconds from the start. The first bit of a video is often a fade-in containing mostly black, so it might be desirable to skip that.
ffmpeg -ss 00:00:5 -i video.mp4 -vf fps=1/10 image%03d.png
Next we'll count how many images that resulted in. This will be handy to know when we're specifying the frame rate of the slideshow.
imgcount=$(find . -maxdepth 1 -name "image*" | wc -l)
echo $imgcount
The duration of the audio track would also be nice to know. With MP3 and similar formats, especially when encoded with a variable bit rate, estimation of duration can be fraught. To get around this the audio file can be converted into a WAV file, f.ex, and then the duration estimated.
adur=$(ffprobe -v error -select_streams a:0 -show_entries stream=duration \
-of default=noprint_wrappers=1:nokey=1 audio.mp3)
echo $adur
Now we'll recombine the images into a slideshow. $imgcount/$adur specifies the display rate of the stills so the duration matches that of the audio file reasonably well. -r 25 specifies the actual frame-rate of the video. Not all formats and video players accept unusual frame-rates.
ffmpeg -framerate $imgcount/$adur -i image%03d.png -c:v libx264 -r 25 \
-pix_fmt yuv422p slideshow.mp4
This will mux the audio file and the slideshow file and trim to the duration of the shortest of the two. This works if the container format supports the codec of the audio file, if not either the audio file has to be re-converted, or another container format chosen. I find Matroska (.mkv) very useful. In the case of .avi and .ac3 or .mp4 and .mp3 there should be no problem.
ffmpeg -i slideshow.mp4 -i audio.mp3 -codec copy -shortest slideshow-sound.mp4

How to generate video screencaps of video files via linux commandline

Is there a command line program for linux (ubuntu) which can generate a large image containing say 6 caps from a given video (e.g. WMV) laid out storyboard style (I know on Windows media player classic can do this)? I need this for part of a script I am writing.
I pulled the answer from this site: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
Where -4 is the number of seconds into the file to grab the screenshot, 320x240 is the screenshot size, and test.jpg is the output file.
Hope this helps.
Use SlickSlice
./slickslice.sh -x video.avi -s 5x3 -e
I've used MPlayer to save frames as images and ImageMagick to combine them:
mplayer -nosound -sstep 15 -vo png video.mkv
montage *.png -tile 3x3 -geometry 300x+0+0 screencaps.png
vcsi can do this. It is a command-line tool written in Python. Example:
vcsi video.mkv -o output.jpg

Resources