Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Last active November 19, 2019 21:12
Show Gist options
  • Save jstaursky/16fbb7d82eece3667f83b8d4e3aa2368 to your computer and use it in GitHub Desktop.
Save jstaursky/16fbb7d82eece3667f83b8d4e3aa2368 to your computer and use it in GitHub Desktop.
Use ffmpeg to convert mp3 to youtube format

ffmpeg can be used to convert mp3’s into a format suitable for uploading to youtube. The following works best for me when converting class mp3 recordings to youtube.

ffmpeg -loop 1 -framerate 2 -i pic.png -i audio.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a aac -shortest -movflags +faststart -pix_fmt yuv420 -threads 16 output.mp4

Notes:

  • Might run into issues with pic.png (not 100% sure necessary to add a picture to fool youtube into thinking upload is a video) The issue will probably warn you about not being a multiple of 2 or something to that effect.
    • I solved this hurdle by using 1) convert pic.png -resize 200x100 out-pic.png then 2) convert pic.png -resize 200% out-pic.png (convert is an imagemagick tool). You might get lucky after only (1) but I had to follow up with (2) to get it to work.
  • You may need to adjust -threads 16 to whatever you system can handle.
  • Can also alter Quality by playing with -preset options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment