Como converter 3g2 para mp4 sem perder áudio?

2

Como faço para converter .3g2 para .mp4 com sucesso a partir da linha de comando? Estou usando comandos ffmpeg como:

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

Esses comandos produzem um vídeo, mas sem áudio. Aqui está a saída do 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

saída do ffprobe:

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
    
por PaulS 13.06.2012 / 15:35

1 resposta

1

A partir dos documentos da autoridade oficial de registro MP4 , parece que o QCELP não é suportado. AC-3, no entanto, é. O [45] in ac[45]3 é o código ASCII para um traço e seria ac-3 , que é um codec válido para o MP4. Então, parece que o arquivo em si é válido, caso contrário o FFmpeg teria reclamado.

Meu palpite é que o próprio QuickTime tem problemas para ler o arquivo como MP4. Você pode tentar alterar a extensão para M4V, como sugerido aqui ou aqui ou tente codificação para um contêiner MOV, que é um pouco mais nativo para o QuickTime.

Então, novamente, você obtém melhor compatibilidade com MP4 se codificar para o áudio h.264 / AAC, o que seria algo assim:

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

O codificador AAC aceita vários parâmetros, principalmente:

  • -ar 44100 como taxa de amostragem
  • -ac 2 como o número de canais de áudio (use 1 para mono)
  • -b:a
por 15.07.2012 / 19:14

Tags