Wednesday, January 27, 2016

Convert videos for twitter using ffmpeg on Mac

Okay, so you're pretty much done developing your new app or game, and you want to record a short demo or gameplay video. Or you just want to post your dev progress on Twitter with the #indiedev hashtag. But Twitter is really picky and throw errors if the video doesn't follow their parameters.

You can easily get around this by capturing your screen with QuickTime and converting the resulting video with ffmpeg via command line.

First fire up your android emulator, or desktop version of your Libgdx game.
Then start QuickTime Player. In the top menu go to File > New Screen Recording.
When you press the red record button, drag a rectangle to select a portion of the screen to record, and record your video. To stop recording, use the circle icon on the top right.
Save your video as video.mov on your desktop.

Now you need the conversion tool: ffmpeg. We'll install it using the terminal via Homebrew. If you are not familiar with it, homebrew is the famous 3rd party package manager for OSX, read about it here - http://brew.sh/

Open the terminal and use this command to install ffmpeg

 brew install ffmpeg --with-libvpx  

After installing, navigate to your desktop folder

 cd ~/Desktop  

and convert your video. The following command is for creating a h264 video for Twitter.

 ffmpeg -i video.mov -r 30 -c:v libx264 -b:v 1M -vf scale=640:-1 video.mp4  

Do you want to post your game progress to 4chan's /agdg/? The following command will create a webm with VP8 codec suitable for posting on 4chan.

 ffmpeg -i video.mov -c:v libvpx -crf 10 -b:v 1M -vf scale=640:-1 video.webm  

The video will be created in the same folder of your source video (your desktop). If you want to mess with ffmpeg parameters like scaling, bitrate, etc, refer to the ffmpeg wiki.

1 comment:

  1. Hello! This post couldn’t be written any better! Reading this post reminds me of my previous room mate! He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing!
    _____________________
    Total video downloader for Mac

    ReplyDelete