4

Resize a video with FFmpeg for Mastodon

 1 year ago
source link: https://www.paulox.net/2022/11/17/resize-a-video-with-ffmpeg-for-mastodon/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Resize a video with FFmpeg for Mastodon

How to resize a video with FFmpeg before uploading it to Mastodon to comply its resolution and size restrictions.

© 2022 Paolo Melchiorre CC BY-SA “Noah Alorwu warming up the audience (with Mauro Gaspari) at Ubuntu Summit 2022 in Prague (Czech Republic)”

© 2022 Paolo Melchiorre CC BY-SA “Noah Alorwu warming up the audience (with Mauro Gaspari) at Ubuntu Summit 2022 in Prague (Czech Republic)”

TL;DR

$ ffmpeg -i input.mp4 -vf scale=1920:-1 -vcodec libx265 -crf 24 output.mp4

Premise

Last week I attended the Ubuntu Summit 2022 in Prague (Czech Republic) and as for other conferences I shared some moments live on Mastodon.

At the start of day three Noah Alorwu animated the audience with a fun little dance which I filmed, but when I tried to upload the file to a post, Mastodon gave me an error message.

Media restrictions

Although not well documented I have found the restrictions that Mastodon applies to videos which I try to summarize below:

  • maximum size: 40 megabytes
  • maximum resolution: 1920 x 1200 px
  • maximum frame rate: 60 fps
  • allowed extensions: .webm .mp4 .m4v .mov

FFmpeg command

The video in mp4 format I recorded was only 12 seconds long but had a size of 65 megabytes and a resolution of 3840 x 2160 pixels.

To be able to upload it to Mastodon I had to reduce the last two parameters using FFmpeg as follows:

$ ffmpeg -i input.mp4 -vf scale=1920:-1 -vcodec libx265 -crf 24 output.mp4

Mastodon toot

The resulting file from the conversion had a size of 12 megabytes and a resolution of 1920 x 1080 pixels which I was able to upload to Mastodon.

Your browser doesn’t support video. Here is a link to the video instead. https://fosstodon.org/@paulox/109313241179228985

References

To learn more, you can read:

Meta


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK