Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
twitter ffmpeg
ffmpeg -i test.mov -vcodec libx264 -vf 'scale=640:trunc(ow/a/2)*2' -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -strict experimental -r 30 out.mp4
@pirmax

This comment has been minimized.

Copy link

@pirmax pirmax commented Jan 9, 2017

The media you tried to send was not valid.

@Platane

This comment has been minimized.

Copy link

@Platane Platane commented Mar 1, 2017

@pirmax https://twittercommunity.com/t/ffmpeg-mp4-upload-to-twitter-unsupported-error/68602/2
worked for me,
I guess the option missing is the one about pixel format, -pix_fmt yuv420p

@RichardBronosky

This comment has been minimized.

Copy link

@RichardBronosky RichardBronosky commented Nov 20, 2017

This worked for me on a screencast created via QuickTime Player

ffmpeg -i $input -vcodec libx264 -pix_fmt yuv420p -strict -2 -acodec aac ${input%.*}.mp4

https://twitter.com/RichardBronosky/status/932433069465899009

@foone

This comment has been minimized.

Copy link

@foone foone commented May 18, 2018

I use this variant. This fixes scaling on windows (which breaks with the single quotes), includes Platane's fix, and also downmixes to stereo so that surround sound videos don't break it:

ffmpeg -i in.mkv -pix_fmt yuv420p -vcodec libx264 -vf scale=640:-1 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100  -ac 2  -strict experimental -r 30  out.mp4
@RichardBronosky

This comment has been minimized.

Copy link

@RichardBronosky RichardBronosky commented Jul 5, 2018

If all you need to do is convert to mp4, this leaves everything else unchanged.

ffmpeg -i in.mov -c copy out.mp4
@brandonprry

This comment has been minimized.

Copy link

@brandonprry brandonprry commented Oct 1, 2019

Foone's command works for me.

@galaxy001

This comment has been minimized.

Copy link

@galaxy001 galaxy001 commented Oct 20, 2019

-t 2:20 is also needed.

@hertzsprung

This comment has been minimized.

Copy link

@hertzsprung hertzsprung commented Mar 30, 2020

It's also necessary to round to an even number of pixel dimensions:

ffmpeg -i test.mov -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p -strict experimental -r 30 -t 2:20 -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -ac 2 out.mp4

@Pomax

This comment has been minimized.

Copy link

@Pomax Pomax commented Oct 27, 2020

Also, based on Twitter's JSON response, the aspect ratio can only be 3:1 max

@nhed

This comment has been minimized.

Copy link

@nhed nhed commented Jul 3, 2021

I definitely needed a -t as I was trying to send a 5 second video (using the standard UI) and the screen error was generic ... had to examine the JSON in the response to know they thought it was too short.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment