2

I have potentially millions of HLS streaming videos to create from cover art and mp3s. Obviously, I'd like to keep the resulting bandwidth to a minimum. I tried various ffmpeg flags specifically suggested for this task and even some on the apple media segmenter that claimed to put a cover art in each segment(meta-file/meta-type). I had a lot of problems getting chrome to display the cover art when playing back using HTML5 despite it working in VLC. I ended up with a working command line like this.

ffmpeg -loop 1 -i 1k_image.jpg -i song_219kbs.mp3 -c:v libx264 -pix_fmt yuv420p  -profile:v baseline -c:a aac -strict experimental -b:a 64k -r 1 -shortest song_64k_2fps_baseline.mp4

The -pix_fmt and baseline profile seemed to be key. Can you see anything I am doing that is unnecessary? Is there a better way of achieving my goal?

Also, I look at several of the commercial cloud transcoding solutions and didn't see how to configure one to do this. Did I miss the options?

2
  • 1
    Please include the complete console output from your command.
    – llogan
    Jun 20, 2015 at 17:02
  • Use libfdk_aac. It has better quality per bitrate than ffmpeg's built-in AAC encoder. Also, don't forget -movflags +faststart to put the MOOV atom at the front of the file (essential for streaming). Jun 26, 2015 at 5:27

1 Answer 1

3

If you just want to embed a cover you might consider keeping the result as mp3, for example:

ffmpeg -i original.mp3 -i cover.png -map 0:0 -map 1:0 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" -id3v2_version 3 -write_id3v1 1 result.mp3

If you are creating mp4's, e.g. for YouTube, then I suggest to split the process to two steps - first create the video movie with no audio track, duration somewhat longer than that of the audio. Then mux the video and audio together with the -shortest option which will truncate the video to the exact duration of audio. In terms of time these two steps will take a tidbit longer than a single pass but your whole workflow will be much simpler and more manageable.

1
  • Wow that really worked. Isn't that shorter with ffmpeg?
    – BabyBoy
    Apr 18, 2022 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.