ffmpeg convert audio to ogg and keep album cover - ffmpeg

If I convert an audio file with an album cover thank's to:
ffmpeg -i sample1.flac -ar 48000 -vn -c:a libvorbis -b:a 320k sample1.ogg
My sample1.ogg file doesn't have any album cover. Is there a way to ask explicitly to ffmpeg to keep the cover ?

instead "-vn" write "-c:v libtheora -q:a 10".
-vn - means no video, picture is frame of video in ffmpeg

Sum up of answers I found: Remove the option -vn which means: no video, because thumbnail are frame of video. Use libtheora instead of libvorbis. If you get a bitrate error, remove option -b:a 320k. At the end we get:
ffmpeg -i file.flac -c:v libtheora -q:v 10 -c:a libvorbis file.ogg
This gives you a file with an audio and a video content.
If you prefer to extract thumbnail in a separate file (to re-add it later for example), use:
ffmpeg -i file.flac -an -vcodec copy thumbnail.jpg
Thank's to Баяр Гончикжапов for his help and answers!

Related

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 audio watermark at specific time

I'm looking for a way to add an audio watermark, on specific time, to a video file (with existing audio) . something like: ffmpeg -i mainAVfile.mov -i audioWM.wav -filter_complex "[0:a][1:a] amix=inputs=2:enable='between(t,9,10)' [aud]; [0:v][aud]" -c:v libx264 -vf "scale=1280:720:sws_dither=ed:flags=lanczos, setdar=16:9" -c:a libfdk_aac -ac 2 -ab 96k -ar 48000 -af "aformat=channel_layouts=stereo, aresample=async=1000" -threads 0 -y output.mp4
The above command gives me this error Timeline ('enable' option) not supported with filter 'amix'. amerge didn't work as well. I kind of get lost with filter_complex syntax, specifically with the following conditions
On the main AV file, both audio and video tracks are filtered
Watermark should be between the 9th and 10th second (I already
generated a 1 second, 10k tone file)
The watermark need to survive the proceeding audio transcode
Use
ffmpeg -i mainAVfile.mov -i audioWM.wav
-filter_complex
"[0:a]aformat=channel_layouts=stereo,aresample=async=1000[main];
[1:a]atrim=0:1,adelay=9000|9000[wm];[main][wm]amix=inputs=2"
-vf "scale=1280:720:sws_dither=ed:flags=lanczos,setdar=16:9" -c:v libx264
-c:a libfdk_aac -ac 2 -ar 48000 -b:a 96k
-threads 0 -y output.mp4
It's preferable to perform all filtering in a single filtergraph. But I've kept the video filter as-is.

Getting the original video quality while converting in ffmpeg

In my site, having upload video(only mp4 videos) functionality and then to combine. For the combining i used Mp4Box, If we want combine all the mp4 video, those videos have to same dimesions,bitrate,codecs,samplerate,etc, So while uploading the mp4 videos itself we set the constant dimension and other details like
ffmpeg -i test.mp4 -r 25 -s 640x360 -ar 48000 -acodec copy -f mp4 -vcodec libx264 -vpre default -async 1 -strict -2 -qscale 10 test.mp4
After using this command the video quality will loss fro the original video, Kindly suggest any solution?
Add
-qp 0
§ Lossless H.264

FFMpeg Batch Image + Multiple Audio to video

Im trying to do the following with FFMpeg I want to create multiple videos with one image and different audio files (music albums). These are my own albums so I have rights to do so before you ask. I have 100's of audio files to stick up on youtube.
Is there a way I can create this in batch so i can just load one image (album cover) and multiple audio files (the album tracks) and get videos to the tracks length automatically?
Appreciate any help
i use this portion of code to do the conversion for my YouTube video:
for %%a in ("*.*")
do
"C:\ffmpeg\bin\ffmpeg" -loop 1 -i "C:\ffmpg\bin\input.jpg" -i "%%a" -c:v libx264 -preset veryslow -tune stillimage -crf 18 -pix_fmt yuv420p -vf scale=854:480 -c:a aac -shortest -strict experimental -b:a 192k -shortest "C:\mp4\%%~na.mp4"
pause
"C:\ffmpeg\bin\ffmpeg" the folder of codec
"C:\ffmpg\bin\input.jpg" image path
"C:\mp4\%%~na.mp4" output folder
-vf scale=854:480 you can specify the resolution of your video 16:9 for youtube video
-c:a aac -shortest use aac codec, by specify -shortest the video length will match the audio length
if there an error use libvo_aacenc instead of aac codec like that:
-c:a libvo_aacenc -shortest -strict experimental
i hope that help
Im trying almost same thing, look how ive done:
#echo off
set /P format="Type the Video Format: "
for %i in (*.%format) <<<< geting not a reconiezed by CMD
do #echo file '%i' > Lista-%format%.txt
mylist=Lista-%format%.txt
ffmpeg.exe -i %mylist% -vf scale=480:320 output-%mylist%.%format%

Resources