Convert video to 3GP format.

Now I expected this to be hard. Or at least take a lot of fiddling to get right. However, it seems to be quite easy. This site has all the goodness. It requires three steps. Now assume we have a file called movie.mpeg and we want to convert it to movie.3GP. The steps required would be

mencoder movie.mpeg -nosound -ovc lavc \
-lavcopts vcodec=mpeg4 \
-vop expand=176:144,scale=176:-2 \
-o movie.avi -ofps 12

This will extract the video, scale it and reduce the frame rate. Now we need to extract the sound.

mplayer -vo null -ao pcm -af \
resample=8000,volume=+4db:sc movie.mpeg

An output file called audiodump.wav will be created that has the audio that we require. Finally we need to combine these two files together.

ffmpeg -i movie.avi -i audiodump.wav \
-b 48 -ac 1 -ab 12 -map 0.0 -map 1.0 movie.3GP

And that is that. I suppose I should add this to the HantsLUG wiki. Next I need to bundle this lot up into a script so I can then forget all about how this works :-)

8 Responses to “Convert video to 3GP format.”

  1. ppip Says:

    thank you for share~~~

  2. peikfeng Says:

    You can directly use single command with ffmpeg:
    ffmpeg -i movie.mpeg -vcodec mpeg4 -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y output.3gp

  3. ppip: 流浪的天空 » 杂记:Linux的世界,每一天都在战斗 Says:

    [...]   比尔盖茨的梦想就是让每一个人的桌子上有一台PC,所以他设计了Windows,一个面向用户的,“易用”的操作系统。他们还取笑Google说,我们的产品黏性比你们的强,因为如果搜索引擎坏了,可以马上换一个;如果Windows坏了,用户不会换一个,他们只会很着急,想办法去修好它。然而,现在几乎每一个Windows用户都处在病毒和流氓软件的威胁之中——国内刚刚还出台了“流氓软件”的新定义——并因此养活了一大批的安全厂商。Windows下的每一天,都好像在和病毒之类的东西战斗。最近一两个月,南开的校园网络就深受arp病毒的影响,蒙楼的网络几乎每周都要瘫痪一两天。  但是Windows也有很多优点,比如说它的程序很多时候都是为着用户考虑的,使用起来很顺手。出了微软自己的Office系列,其他第三方软件也大都很好用,下载-安装-使用是通常的过程。而Linux的世界下,你要面对的就太多了。不管是Debian还是SuSE,或者是Ubuntu,要装什么软件,经常不能够一步到位(尽管有apt这样如此优秀的包管理系统),总是有些必要的东西会游离在系统之外,需要用户自己去处理。这也是caii原来在blog中提到的——其实满足用户的需求,至少能够把基本的字体之类的东西弄好了,就是国内Linux厂商的一种机会。  最近我在我的Ubuntu 6.10上重新装上了KDE,并转向KDE桌面。在SuSE下使用了一个多月KDE桌面之后,我的偏好总算更加倾向KDE了。相对于Gnome来说,KDE明显是一个更加成熟,拟合度更好的桌面系统。很多Gnome的程序,比如说tomboy,比如说最近很火热的F-spot,完全没有“帮助”,而只有一个“关于”,好像摸索是用户应该作做的事情,而大部分KDE程序会有知道简单的帮助——是否是因为整个KDE桌面的基础帮助系统比较完善?Gnome的主菜单用了三组文字作为菜单名,而不是用一个图标——不太清楚他们为什么这样设计,但是,为什么不节省用户的桌面空间呢?还有很多Gnome的桌面小程序都还处于发展的初级阶段,比如说我最近用到的bluetooth,Gnome下的bluetooth没有任何选项,在接收到任何一个文件的时候就弹出一个提示而已;相对来说,KDE的kbluetooth就好用多了。  最近终于找到把avi文件转成3gp格式的方法了,出了mencoder,还需要用到ffmpeg。 mencoder movie.mpeg -nosound -ovc lavc -lavcopts vcodec=mpeg4 -vop expand=176:144,scale=176:-2 -o movie.avi -ofps 12mplayer -vo null -ao pcm -afresample=8000,volume=+4db:sc movie.mpegffmpeg -i movie.avi -i audiodump.wav -b 48 -ac 1 -ab 12 -map 0.0 -map 1.0 movie.3GP [...]

  4. philip Says:

    Nope, I am note sure what that says. By using Google Language tools, it would appear that it is a comment about Microsoft and Linux. Unfortunately the Chinese to English translation of Google is not that great. All I am sure of is that the first line mentions Bill Gates.

  5. peikfeng Says:

    Let me help you, hope my translation could bring out the thought of the author precisely :)

    Bill Gates’ dream is to let everybody’s desk to have a PC, therefore he designed Windows, a user based, “easy to use” operating system. They teased Google, “our product is more sticky than yours, because if search engine damaged, it could be switched to another immediately; but if Windows damaged, user doesn’t know how to switch, they would be worried, trying to fix it.” However, almost every Windows user live in the threatening of virus and hoodlum software**, China has just having a new definition for “hoodlum software”, and this has created a bunch of security software companies. Live with Windows is like fighting with virus everyday. Since 1-2 months ago, “Nan Kai” school network is affected by arp virus, “Meng Lou” building’ s network down 1-2 days every week.
    However Windows has many advantages, for example its software is designed for user, easy to use. Beside MS Office series, other 3rd party software are easy to use too, download-install-use is the common steps. But you need to face a lot of problem with Linux. No matter Debian or SuSe or Ubuntu, software installation always require more effort (even though there is a good package management system like apt), there will always be something outside the system, that require user to handle by themselves. This is also mentioned by caii in his blog: to satisfy user’s need, at least to make a good work on fundamental stuff like font, is an opportunity to Linux software company in China.
    Recently I reinstall KDE on my Ubuntu 6.10, and switched to KDE desktop. After using KDE with SuSe for a month, my preference has gone to KDE. Compare to Gnome, KDE is more mature, well designed desktop system. Many Gnome software, e.g.: tomboy and F-spot, don’t have “Help” at all, there is only an “about”, assuming finding out how to use is the users job. Most KDE software would have a simple help, could it be due to the KDE ‘ fundamental system help is more complete? Gnome main menu uses 3 group of text as menu list, and not using icon, not really understand why they design in such a way, but why don’t they save the desktop space of user? There are also a lot of Gnome desktop application is still in experimental stage, for example bluetooth that I used recently, there is no options of bluetooth in Gnome, when receiving a file, there is only one message box pop up. In the other hand, KDE’s kbluetooth is much better.
    I finally found the method to convert avi to 3gp, beside mencoder, ffmpeg is also needed. mencoder movie.mpeg -nosound -ovc lavc -lavcopts vcodec=mpeg4 -vop expand=176:144,scale=176:-2 -o movie.avi -ofps 12mplayer -vo null -ao pcm -afresample=8000,volume=+4db:sc movie.mpegffmpeg -i movie.avi -i audiodump.wav -b 48 -ac 1 -ab 12 -map 0.0 -map 1.0 movie.3GP

    **I do not know this term, just direct translate, but it means software like adware, spyware, malicious software …

  6. Bluejacket Says:

    The vop expand=176:144,scale=176:-2 part sets the resolution. Shouldn’t you use 320 x 240 for SE k800i instead of 176 x 144 for better resolution?

  7. philip Says:

    I could be wrong, so don’t quote me, but I think that the 3gp specification sets the size and the bandwidth required. So although the K800i has a higher resolution screen, I am not sure you can create a higher resolution file and still be 3gp compliant.

    The thing to do is to give it a go. However, please don’t blame me if it turns your phone into a smouldering wreck :-) If it does work, a post here telling of your success would be appreciated.

  8. Bluejacket Says:

    Setting resolution to 320×240 works perfectly. It will make the filesize slightly bigger, so try yourself whether it’s worth it or not. You can use a single command to do everything, just like peikfeng already posted. Thanks for these instructions anyway!

Leave a Reply