View previous topic :: View next topic |
Author |
Message |
ToddH_ n00b
Joined: 04 Jan 2006 Posts: 21
|
Posted: Thu Oct 04, 2007 6:17 am Post subject: HOWTO: .3gp videos from Moto Krzr K1 into a .mpeg file |
|
|
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:
Code: | "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 smugmug.com was happy to upload:
Code: | 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:
Code: | $ 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.
Code: | $ 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:
Code: | $ 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:
Code: | $ 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):
Code: | $ 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 2.0.0.7+Quicktime 7.2 under XP, Firefox 2.0.0.6+Quicktime7.1.3 under XP, Firefox 2.0.0.7+Quicktime6.5.1 under win2k. In addition, these didn't behave terribly consistently with Windows Media Player either.):
Code: | $ 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 |
|
|
mark_alec Bodhisattva
Joined: 11 Sep 2004 Posts: 6066 Location: Melbourne, Australia
|
Posted: Thu Oct 04, 2007 7:06 am Post subject: |
|
|
Moved from Multimedia to Documentation, Tips & Tricks. _________________ www.gentoo.org.au || #gentoo-au |
|
Back to top |
|
|
jackbyte n00b
Joined: 03 Nov 2007 Posts: 5 Location: Ags, Mexico
|
Posted: Wed Nov 28, 2007 1:36 am Post subject: Thanks I was looking for that |
|
|
Hi
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.
____
Jackbyte _________________ __________________
Gentoo rules! |
|
Back to top |
|
|
|
|
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
|
|