Come convertire 3g2 in mp4 senza perdere l'audio?


3

Come posso convertire correttamente .3g2 in .mp4 dalla riga di comando? Sto usando i comandi ffmpeg come:

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

Questi comandi producono un video ma nessun audio. Ecco l'output di 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

uscita 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

È interessante notare che mp4 non funziona affatto nella mia installazione quicktime. Viene generato il seguente errore: Errore -2041: è stata trovata una descrizione del campione non valida nel filmato.
Paul

Ho scoperto che l'uso del codec audio libfaac e l'impostazione della frequenza di campionamento audio converte correttamente 3g2 in mp4 con l'audio! ffmpeg -i input.3g2 -acodec libfaac -ar 44100 -vcodec libx264 output.mp4
PaulS

Risposte:


1

Dai documenti dell'autorità di registrazione ufficiale di MP4 , sembra che QCELP non sia supportato. AC-3 comunque lo è. L' [45]in ac[45]3 è il codice ASCII per un trattino, e che sarebbe stato ac-3, che è un codec valido per MP4. Quindi, sembra che il file stesso sia valido, altrimenti FFmpeg si sarebbe lamentato.

La mia ipotesi è che QuickTime stesso abbia problemi a leggere il file come MP4. Potresti provare a cambiare l'estensione in M4V, come suggerito qui o qui , o in alternativa provare a codificare in un contenitore MOV, che è in qualche modo più nativo di QuickTime.

Quindi, ottieni la migliore compatibilità con MP4 se codifichi l'audio h.264 / AAC, che sarebbe qualcosa del genere:

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

L'encoder AAC accetta vari parametri, in particolare:

  • -ar 44100 come frequenza di campionamento
  • -ac 2 come numero di canali audio (utilizzare 1 per mono)
  • -b:a

Una piccola modifica al tuo comando mi ha dato il risultato che speravo:ffmpeg -i input.3g2 -c:v libx264 -c:a aac out.mp4
Jeremy Cook,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.