Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: .3gp videos from Moto Krzr K1 into a .mpeg file
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 04 Jan 2006
Posts: 21

PostPosted: Thu Oct 04, 2007 6:17 am    Post subject: HOWTO: .3gp videos from Moto Krzr K1 into a .mpeg file Reply with quote

Howdy all,

This was quite a pain in the butt, and I hope to save some poor soul's my fun for the past day or so. This is how I managed to take the .3gp video files created with the video camera on the MOtorola Krazr K1 and convert them into low-drama, relatively universally supported mpeg-1 files.

Apparently, the Moto Krazr K1 uses amrnb (adaptive multi rate, narrowband) audio codecs for the audio of these, mono, sampling rate of 8kHz. Video is h.263 with a resolution of 176x144 and framerate of 29.97 frames/second. It may or may not have been necessary for conversion purposes, but I re-emerged mplayer amrnb USE flag and I think got mplayer happy with the source files.

ffmpeg remained unhappy with the .3gp files despite the fixing of mplayer, however giving the error:
"Unsupported codec (id=73728) for input stream #0.1"

referring to the audio stream portion of the file. Clearly I didn't have the codec it wanted for decoding the audio.

Re-emerging ffmpeg with the amr USE flag seemed to address that. The final happy command line which produced a vanilla mpeg-1 file that even was happy to upload:
ffmpeg  -y -i test.3gp  -sameq -f mpegvideo -s cif -r25 -ar 32000 -ac 1 mpegs/test.mpg
# improved/revised from original post

As a summary of helpful commands/tips:
This helped me figure out what use flags were available and which were not yet in use:
$ emerge -pv mplayer
$ emerge -pv ffmpeg

This is how my package.use ended up when success was reached. I'm pretty sure amr is an invalid flag for mplayer (armnb and amrwb were the magical ones I think), but I kept it there anyway and don't feel like re-emerging to test w/o it. amr is however the right keyword for ffmpeg.
$ cat /etc/portage/package.use
media-video/mplayer a52 amr mad win32codecs amrnb amrwb aac mp2
media-video/ffmpeg amr

After setting package.use as above, I performed the re-emerging with these commands:
$ sudo emerge mplayer --newuse
$ sudo emerge --newuse -uav ffmpeg

This was something I did as I searched around for packages relevant to the amr encoding, but I'm not sure it was necessary:
$ sudo emerge amrnb

And after all that fun, to actually convert a bunch of 3gp's in the current directory (caveat not a hardened script, beware of using this on interestingly named files) to mpeg-1 files in an mpegs sudirectory:

**EDIT** REVISED CODE (added file overwrite, reverted to mp2 audio, specified lowest allowable mp2 sampling rate, upsized to cif 352 x 288 and reduced framerate to 25 fps all in the chase of a more MPEG-1 compliant and supported datastream):
$ mkdir mpegs/
$for i in `ls -1 *.3gp | cut -d. -f1`; do ffmpeg  -y -i $i.3gp  -sameq -f mpegvideo -s cif -r25 -ar 32000 -ac 1 mpegs/$i.mpg; done

Which says "for all the .3gp files in the directory, lop off the base file name, run ffmpeg on it as input, let's overwrite output files, keep the same quality, set the output videoformat to mpegvideo, convert to CIF (352x288) resolution, use default mpeg mp2 audio, use an audio sampling rate of 32kHz (lowest allowed mp2) use 1 audio channel (mono), and dump it into the mpegs directory using the same basename, but with an mpg extension."

For posterity's sake my original code post is below. Problems with it included: mp3 strictly isn't part of mpeg-1, keeping the 176x144 source file resolution is not part of a MPEG-1 Constrained Parameters Bitstream. The resulting files here actually managed to crash: Firefox 7.2 under XP, Firefox under XP, Firefox under win2k. In addition, these didn't behave terribly consistently with Windows Media Player either.):
$ mkdir mpegs/
$ for i in `ls -1 *.3gp | cut -d. -f1`; do ffmpeg  -i $i.3gp  -sameq -f mpegvideo -ar 44100 -ac 1 -acodec mp3 mpegs/$i.mpg; done

Hope this helps someone. If you have any insights on what was and wasn't truly necessary for this conversion, feel free to add your experience.

Last edited by ToddH_ on Thu Oct 04, 2007 7:28 pm; edited 9 times in total
Back to top
View user's profile Send private message

Joined: 11 Sep 2004
Posts: 6066
Location: Melbourne, Australia

PostPosted: Thu Oct 04, 2007 7:06 am    Post subject: Reply with quote

Moved from Multimedia to Documentation, Tips & Tricks.
_________________ || #gentoo-au
Back to top
View user's profile Send private message

Joined: 03 Nov 2007
Posts: 5
Location: Ags, Mexico

PostPosted: Wed Nov 28, 2007 1:36 am    Post subject: Thanks I was looking for that Reply with quote

Thank you for posting this, it helped me to convert a file that I recorded with my Motorola phone. Now I can hear the sound. :D

Gentoo rules!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum