Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I convert .3g2 to .mp4 successfully from the command line? I'm using ffmpeg commands like:

ffmpeg -i input.3g2 -acodec copy -vcodec libx264 output.mp4
ffmpeg -i input.3g2 -acodec ac3 -vcodec libx264 output.mp4

These commands produce a video but no audio. Here's the output from ffmpeg:

ffmpeg -i input.3g2 -acodec ac3 -vcodec libx264 input.mp4
ffmpeg version 0.10.2.git Copyright (c) 2000-2012 the FFmpeg developers
  built on Jun 13 2012 05:18:13 with gcc 4.4.5
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-nonfree --enable-version3
  libavutil      51. 58.100 / 51. 58.100
  libavcodec     54. 25.100 / 54. 25.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 78.101 /  2. 78.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.3g2':
  Metadata:
    major_brand     : 3g2a
    minor_version   : 0
    compatible_brands: 3g2a
    creation_time   : 2006-02-03 22:54:07
  Duration: 00:00:15.14, start: 0.000000, bitrate: 94 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 176x144 [SAR 1:1 DAR 11:9], 79 kb/s, SAR 12:11 DAR 4:3, 15 fps, 15 tbr, 15 tbn, 15 tbc
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: qcelp (mp4a / 0x6134706D), 8000 Hz, mono, flt, 14 kb/s
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : AudioHandler
[buffer @ 0xa820b40] w:176 h:144 pixfmt:yuv420p tb:1/15 fr:15/1 sar:12/11 sws_param:flags=2
[ffmpeg_buffersink @ 0xa820ea0] No opaque field provided
[libx264 @ 0xa81fb00] using SAR=12/11
[libx264 @ 0xa81fb00] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
[libx264 @ 0xa81fb00] profile High, level 1.0
[libx264 @ 0xa81fb00] 264 - core 118 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 Output #0, mp4, to 'output.mp4':
  Metadata:
    major_brand     : 3g2a
    minor_version   : 0
    compatible_brands: 3g2a
    creation_time   : 2006-02-03 22:54:07
    encoder         : Lavf54.6.101
    Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 176x144 [SAR 12:11 DAR 4:3], q=-1--1, 15 tbn, 15 tbc
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 ([165][0][0][0] / 0x00A5), 8000 Hz, mono, flt, 96 kb/s
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : AudioHandler
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> libx264)
  Stream #0:1 -> #0:1 (qcelp -> ac3)
Press [q] to stop, [?] for help
frame=  225 fps=214 q=-1.0 Lsize=     327kB time=00:00:14.86 bitrate= 180.4kbits/s
video:146kB audio:178kB global headers:0kB muxing overhead 0.950448%
[libx264 @ 0xa81fb00] frame I:1     Avg QP:23.26  size:  1021
[libx264 @ 0xa81fb00] frame P:218   Avg QP:23.35  size:   671
[libx264 @ 0xa81fb00] frame B:6     Avg QP:26.62  size:   356
[libx264 @ 0xa81fb00] consecutive B-frames: 95.1%  3.6%  1.3%  0.0%
[libx264 @ 0xa81fb00] mb I  I16..4: 11.1% 87.9%  1.0%
[libx264 @ 0xa81fb00] mb P  I16..4:  0.8%  7.4%  0.2%  P16..4: 64.1% 17.4%  6.0%  0.0%  0.0%    skip: 4.1%
[libx264 @ 0xa81fb00] mb B  I16..4:  0.8%  5.2%  0.2%  B16..8: 52.4% 10.4%  1.3%  direct: 2.7%  skip:26.9%  L0:68.5% L1:21.0% BI:10.5%
[libx264 @ 0xa81fb00] 8x8 transform intra:88.3% inter:83.3%
[libx264 @ 0xa81fb00] coded y,uvDC,uvAC intra: 78.7% 80.3% 16.7% inter: 36.2% 30.9% 0.7%
[libx264 @ 0xa81fb00] i16 v,h,dc,p: 16% 12% 55% 17%
[libx264 @ 0xa81fb00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 37%  3%  3%  3%  5%  4%  4%
[libx264 @ 0xa81fb00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 14% 18%  3%  8%  9%  6% 10%  2%
[libx264 @ 0xa81fb00] i8c dc,h,v,p: 58% 16% 19%  6%
[libx264 @ 0xa81fb00] Weighted P-Frames: Y:3.2% UV:0.0%
[libx264 @ 0xa81fb00] ref P L0: 78.6% 15.8%  4.3%  1.2%  0.1%
[libx264 @ 0xa81fb00] ref B L0: 93.0%  6.4%  0.6%
[libx264 @ 0xa81fb00] ref B L1: 98.4%  1.6%
[libx264 @ 0xa81fb00] kb/s:79.65

ffprobe output:

ffprobe version 0.10.2.git Copyright (c) 2007-2012 the FFmpeg developers
  built on Jun 13 2012 05:18:13 with gcc 4.4.5
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-nonfree --enable-version3
  libavutil      51. 58.100 / 51. 58.100
  libavcodec     54. 25.100 / 54. 25.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 78.101 /  2. 78.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2006-02-03 22:54:07
    encoder         : Lavf54.6.101
  Duration: 00:00:15.16, start: 0.000000, bitrate: 176 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 176x144 [SAR 12:11 DAR 4:3], 80 kb/s, 15 fps, 15 tbr, 15 tbn, 30 tbc
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 (ac[45]3 / 0x332D6361), 8000 Hz, mono, s16, 96 kb/s
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : SoundHandler

psimon@zebra:~/tmp/convert_video$
ffprobe version 0.10.2.git Copyright (c) 2007-2012 the FFmpeg developers
  built on Jun 13 2012 05:18:13 with gcc 4.4.5
  configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-nonfree --enable-version3
  libavutil      51. 58.100 / 51. 58.100
  libavcodec     54. 25.100 / 54. 25.100
  libavformat    54.  6.101 / 54.  6.101
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 78.101 /  2. 78.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2006-02-03 22:54:07
    encoder         : Lavf54.6.101
  Duration: 00:00:15.16, start: 0.000000, bitrate: 176 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 176x144 [SAR 12:11 DAR 4:3], 80 kb/s, 15 fps, 15 tbr, 15 tbn, 30 tbc
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 (ac[45]3 / 0x332D6361), 8000 Hz, mono, s16, 96 kb/s
    Metadata:
      creation_time   : 2006-02-03 22:54:07
      handler_name    : SoundHandler
share|improve this question
    
Interestingly, the mp4 doesn't play at all in my quicktime installation. The following error is thrown: Error -2041: an invalid sample description was found in the movie. –  PaulS Jun 13 '12 at 14:43
    
I found that using the audio codec libfaac and setting the audio sampling frequency converts the 3g2 to mp4 successfully with audio! ffmpeg -i input.3g2 -acodec libfaac -ar 44100 -vcodec libx264 output.mp4 –  PaulS Jun 13 '12 at 15:16
add comment

1 Answer

From the docs of the official MP4 registration authority, it seems like QCELP is not supported. AC-3 however is. The [45] in ac[45]3 is the ASCII code for a dash, and that would be ac-3, which is a valid codec for MP4. So, it seems that the file itself is valid, otherwise FFmpeg would have complained.

My guess is that QuickTime itself has problems reading the file as MP4. You could try changing the extension to M4V, as suggested here or here, or alternatively try encoding to a MOV container, which is somewhat more native to QuickTime.

Then again, you get best compatibility with MP4 if you encode to h.264 / AAC audio, which would be something like this:

ffmpeg -i input.3g2 -c:v libx264 -c:a libfaac out.mp4

The AAC encoder takes various parameters, most notably:

  • -ar 44100 as the sample rate
  • -ac 2 as the number of audio channels (use 1 for mono)
  • -b:a
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.