Converting video shot with on an Android phone to a more portable format using FFMPEG (specifically for YouTube)

  1. What is .3GP? (reference Wikipedia)

    1. Multimedia container format defined by the Third Generation Partnership Project (3GPP) for 3G mobile phones

      1. Derived from MPEG-4

      2. .3GP for GSM, .3G2 for CDMA (I'm assuming all smartphones, or at very least HTC Android use this format)

    2. Windows Media Player knows it's a video file, won't play. VLC (Windows) would play video w/o audio (new version VLC fixed it)

    3. On Linux, MPlayer needed a plugin (AMR – Adaptive Multi Rate decoder), VLC would play it

    4. FFMPEG to the rescue

  2. How I transferred video files to a PC

      1. Camera album support has support for Flickr and Facebook. Even if I used those services, I have BINO (Broadband in Name Only) Internet. Needed to transfer files across my network (WiFi). ES (EStrong) File Explorer lets you browse all the folders on the phone, including internal storage (w/o rooting). Connects to Samba (Windows) and FTP servers, root access if you log in as an admin. Static IP on your servers recommended.

      2. Under “Local” tab, “/” button gets you to root. On HTC Android, navigate to /emmc/DCIM/100MEDIA/

        1. “Click” filesnames to preview

        2. To select files for copying

          • “Multi-Select” icon has a plus sign on it, you may confuse it for a new folder icon (new folder is <Menu Key> > New

            • Now you can select multiple files by touching each one, deselect the same way (like a Control click with the mouse)

            • Press <Menu Key>, select Operations, then Copy

        3. To Paste on a workststion

          • LAN (Samba, i.e. Windows, Mac(?))

            • Add, set up your target workstation by IP address, username and password

              • Note, you will have access to the full contents of every drive, not just the shared folders, just like you were logged in locally

          • FTP

            • Kevin Wisher prepared an excellent tutorial for Russ Wenner about enabling SAMBA shares in Linux {} that I never completed. It is easy however to install an FTP server in Linux (I use proftpd). FTP services can easily be started from a terminal, so if you have physical access to the machine, you should configure the FTP server not to start up on bootup.

            • Add, set up your target workstation by IP address, username and password

              • If the user's privileges can be elevated to root (Debian), again you will have access to every folder (but isn't that dangerous?)

                • As ROOT, edit /etc/proftpd/proftpd.conf (location may vary by distro)

                • Uncomment “DefaultRoot” to segregate user to their own “home” folder

                • Uncomment “Port” and set it to something uncommon

                • Install rcconf "Debian Runlevel Configuration Tool", (like services.msc in Windows). Run and uncheck proftpd

                  • Run “service proftpd start” to start server

            • Browse to remote folder, <Menu Key> > Operations > Paste

  1. FFMPEG is a scary powerful command line utility for converting media formats

    1. I've always been intimidated looking at the MAN page, FFMPEG has more switches than a 747

    2. Many of the graphical media tools in Linux make calls to FFMPEG

    3. I hit Google to find some examples

      1. Meantime, I opened a .3GP file in the Kino movie editor

        1. First thing it said the file wasn't a digital (raw) video file. Expanded a 200Mb .3Gp file to a 1.5Gb .dv file

          • Kino is great for editing video from my digital tape camera, which has to be captured in real time over Firewire, cut and edited. I just wanted to convert the clips from my phone straight to YouTube compatible format with no editing

      2. I had also tried the file converter in VLC, but never came up with usable output. I'm probably doing something wrong

    4. Along the way I learned a trick, ffmpeg expects, at minimum, arguments for the input and output files, i.e. “ffmpeg -i input.container output.container” . If you want to see the particulars of a video file (video codec, resolution, and framerate, audio codec, frequency, and bitrate) you can issue “ffmpeg -i MyVideo.container_extension”. ffmpeg will give you an error, but still show you what is in the file:

      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'VIDEO0002.3gp':

      Duration: 00:07:21.46, start: 0.000000, bitrate: 3015 kb/s

      Stream #0.0(eng): Video: mpeg4, yuv420p, 800x480 [PAR 1:1 DAR 5:3], 60 tbr, 1k tbn, 60 tbc

      Stream #0.1(eng): Audio: libamr_nb, 8000 Hz, mono, s16

      At least one output file must be specified

      1. The parts of this I can interpret are, file VIDEO0002.3gp has a duration of seven minutes, twenty-one seconds, is video encoded in MPEG-4 at 800x480 (at little better than my camcorder actually) at 3015 kilobits per second. The audio codec is AMR, mono, at 8000Hz (same as a telephone, my Sony does do better on audio).

      2. Don't forget the “-i”. If you do, ffmpeg will assume the file name is output and ask “Are you sure?”. If you absent mindedly say Yes, I think ffmpeg will happily overwrite the video file with the input you specified, which is nil!

    5. With the help of various examples I found with Google (see links below), I was able to come up with a set of arguments for ffmpeg which transformed my phone video into something suitable for YouTube. There may well be a more optimal set of parameters and I invite comment and criticism so I may learn myself what I could have done more effectively. Now that YouTube accepts HiDef, I couldn't find anything on the site about their preferences on upload parameters, except under 15 minutes and 2 gig! With my slow Internet, < 40Mb for a ten minute clip is more my speed and is more considerate of the viewer (Except for true HiDef, does YouTube render the stream the same regardless of the input? I'd like to know. Everything comes back the same when I download it via I found some basic recommendations on, and adapted them for my own situation.

    6. I'll start with the ffmpeg command I used and deconstruct each argument.

    ffmpeg -i VIDEO0002.3gp -b 564kb -s 320x240 -vcodec mpeg4 -r 30000/1001 -ar 22050 YouTube1.avi

      1. I'll start at the end with the output file, YouTube1.avi. The format of the file container is determined by extension of the output file (i.e., .mp4, .avi, .mov etc). Many people confuse this with the video codec, but as I understand it is more closely related to a compression format (i.e., choosing .tar vs. .zip or GZip). I suspect some codecs are more compatible with certain containers and it may be possible to choose a combination that degrades video quality. Klaatu made an excellent and comprehensive presentation on codecs in the early days of Hacker Public Radio and recently discussed the effect of frequency and bitrate on GNU World Order (, so I refer further inquires to those podcasts.

      2. -i VIDEO0002.3gp Designates the input file. I believe you can specify parameters like codec on the input side but I doubt overriding what ffmpeg detects will produce the best output.

      3. -b 564kb Video bitrate. Shahid Hussain recommends 700-1000 kilobits for YouTube. [He also ommits the “kb” in his example. Without it, ffmpeg interprets the parameter as 800 bits per second and refuses to process the video. You either need to include “kb” or add zeroes.] In my case, at 800kb the file came out three or four times the size of what I had been getting for a similar length clip from Kino. Comparing output parameters, I found Kino exports video “for broadband” at 564kb. Good enough for me, and I had my <40Mb file. Back to Klaatu's recent podcast, bitrate determines how many pixels can change from one frame to the next. Set it too low, and the video looks pixelated.

      4. -s 320x240 Resolution, self explanatory. In the past, this was the traditional format for YouTube video, again I'm not sure submitting in high resolution will improve quality.

      5. -vcodec mpeg4 I selected MPEG-4 for the video codec. I've had success with uploading clips encoded in MPEG-4 via Kino to YouTube, the original video was MPEG-4 and I suspect re-encoding an unrelated codec introduces loss, and I've not tried YouTube with Theora.

      6. -r 30000/1001 Audio bitrate. Represents the rate of change over time in the audio. Again, there are people who can speak to this better than I can. Shahid Hussain recommends doing the math inline because it comes out approximately 29.97003 fps, the rated for NTSC (American standard def) video. Other online references recommended discrete values between 27and 30. Default is 64, which is odd because ffmpeg would throw an error if I did not specify an audio bitrate (artifact of the codec selection, perhaps?)

      7. -ar 22050 Audio frequency, represents the range of discrete audio frequencies that can be reproduced. Higher numbers produce higher fidelity, in other words, 22050 is good enough for speech, not good enough for music. Note that the input frequency was only 8000hz. I can't magically improve it by selecting a higher output frequency, so why did I? Simply put, the selected output codec wouldn't accept a lower number, which brings us to the next parameter....

      8. -acodec not_specified I went with the default, MP2. You could use MP3, but the codecs ffmpeg supports are determined by the distribution, and even in Mint, the default ffmpeg does not support MP3. Some of the references I found stated ffmpeg has to be re-compiled with extra libraries to include support for additional codecs. I'm not sure if that only applies to the Gentoo/Arch/Slackware camp or to all of us. I tried Vorbis, but it won't take mono input. I suppose I could have tried AMR, but I think MP2 was as good as anything for the audio I had.

      9. -ac not_specificed Audio channel, ergo mono=1, stereo=2

    1. On my second video, I found the above settings were fine for large objects (I was doing owner interviews at a truck show), but facial features were washed out when my subjects moved. Again, I not sure uploading a higher quality video has any effect, but when my friend asks what happened to his face, I can blame it on YouTube.

    ffmpeg -i VIDEO0003.3gp -b 800kb -s 800x480 -vcodec libx264 -r 30000/1001 -ar 22050 YouTube2.avi

      1. As you can see, I increased video bitrate to 800kb, left the resolution at 800x480, the same as the input file, and used the freedom hating H.264 video codec. My file size increased to a still manageable 120Mb. I think the video looks a little better on YouTube, I'll need to look again on a faster broadband connection.

      2. libx264: A lot of codecs seem to be referenced as lib_something (for library), but apparently, the parameter was once just x264. You may have to Google around to see what is appropriate for your kernel, distro, and ffmpeg version. If there is a MAN page for codecs, I didn't find it.


What the heck is .3gp?

Formatting for YouTube with FFMPEG

by Shahid Hussain

Convert AVI to 3gp using ffmpeg (this is going the other way, converting video to the native format to play on the phone, but I found some pointers on codecs and formatting.)

by Shrinivasan

A big reference on ffmpeg and codecs by Howard Prichett

(audio) Sampling Rate – Wikipedia

This document is released Creative Commons and may be reproduced by anyone who has need of the information. Online materials referenced herein remain the property of their creators under whatever agreements they deem appropriate. Mistakes and unintentional misrepresentations are the responsibility of the author. Please reference such errors to so I may be instructed from my misstatements.