Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2011, 13:46
psebas
 
Fecha de Ingreso: febrero-2010
Mensajes: 4
Antigüedad: 14 años, 2 meses
Puntos: 0
Pregunta problema downmixing audio ffmpeg

Hola buenas a todos.
Tengo una web donde se suben videos (en cualquier formato), se recodifican automaticamente a flv mediante ffmpeg, y tambien les inyecto los metadatos necesarios con flvtool2, para poder hacer pseudostreaming (avance rapido sin tener que haber descargado todo el video)
La recodificacion me funciona ok con casi todos lo videos (casi cualquier formato de video y de audio stereo -> flv).
El problema viene cuando se suben videos con audio 5.1 (y creo que cualquier otro que no sea audio simplemente stereo)
La recodificacion que realizo con ffmpeg es:

Código:
/usr/local/bin/ffmpeg -y -i "%1" -f flv -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre slow -crf 22 -threads 0 "%2"
Donde %1 es una variable que contiene la ruta del fichero subido (el original a recodificar), y %2 es una variable con la ruta del fichero de salida (ya recodificado)
La idea es recodificar el video origen a:
codec de audio: aac 2 128K bitrate en stereo
codec de video: x264 (tamaño video original)1 pasada
Con este comando me da un error (en negrita al final)

Código:
root@server01:~# /usr/local/bin/ffmpeg -y -i 6channels.wmv -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre slow -crf 22 -threads 0 2ch.flv
FFmpeg version SVN-r26327, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jan 14 2011 14:55:51 with gcc 4.4.3
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libmp3lame --enable-libvpx
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 1 /  0.16. 1
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.92. 0 / 52.92. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.73. 1 /  1.73. 1
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0

Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 23.98 (24000/1001)
Input #0, asf, from '6channels.wmv':
  Metadata:
    WM/ParentalRating:
    WMFSDKVersion   : 9.00.00.2980
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    title           :
    artist          :
    copyright       :
    comment         :
  Duration: 00:02:31.98, start: 3.000000, bitrate: 6101 kb/s
    Stream #0.0(eng): Audio: wmapro, 48000 Hz, 5.1, flt, 384 kb/s
    Stream #0.1(eng): Video: wmv3, yuv420p, 1280x720, 6000 kb/s, 23.98 tbr, 1k tbn, 1k tbc
[buffer @ 0x2f5aaf0] w:1280 h:720 pixfmt:yuv420p
[libx264 @ 0x2f66ff0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x2f66ff0] profile High, level 3.1
[libx264 @ 0x2f66ff0] 264 - core 107 r1745 4785e8e - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 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=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=22.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
Output #0, flv, to '2ch.flv':
  Metadata:
    WM/ParentalRating:
    WMFSDKVersion   : 9.00.00.2980
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 0
    title           :
    artist          :
    copyright       :
    comment         :
    encoder         : Lavf52.92.0
    Stream #0.0(eng): Video: libx264, yuv420p, 1280x720, q=10-51, 200 kb/s, 1k tbn, 23.98 tbc
    Stream #0.1(eng): Audio: libfaac, 48000 Hz, 2 channels, s16, 128 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
Multiple frames in a packet from stream 0
Warning, using s16 intermediate sample format for resampling
Resampling with input channels greater than 2 unsupported.
Can not resample 6 channels @ 48000 Hz to 2 channels @ 48000 Hz
Como se puede ver no recodifica, por lo que pruebo quitando que obligue a poner en el destino solo a 2 canales de audio. (quitando el "-ac 2")

Código:
root@server01:~# /usr/local/bin/ffmpeg -y -i 6channels.wmv -acodec libfaac -ab 128k -vcodec libx264 -vpre slow -crf 22 -threads 0 6ch.flv
esto si me lo recodifica pero me lo deja en 6 canales de audio y despues al intentar usar el flvtool2 con ese fichero da error y se añaden las cabeceras para el pseudostreaming.

Código:
root@server01:~# flvtool2 -U 6ch.flv 6ch_ok.flv
ERROR: EOFError
ERROR: /usr/lib/ruby/1.8/flv/amf_string_buffer.rb:37:in `read'
ERROR: /usr/lib/ruby/1.8/flv/video_tag.rb:80:in `read_header'
ERROR: /usr/lib/ruby/1.8/flv/video_tag.rb:47:in `after_initialize'
ERROR: /usr/lib/ruby/1.8/flv/tag.rb:56:in `initialize'
ERROR: /usr/lib/ruby/1.8/flv/stream.rb:449:in `new'
ERROR: /usr/lib/ruby/1.8/flv/stream.rb:449:in `read_tags'
ERROR: /usr/lib/ruby/1.8/flv/stream.rb:58:in `initialize'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:272:in `new'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:272:in `open_stream'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:238:in `process_files'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:225:in `each'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:225:in `process_files'
ERROR: /usr/lib/ruby/1.8/flvtool2/base.rb:44:in `execute!'
ERROR: /usr/lib/ruby/1.8/flvtool2.rb:168:in `execute!'
ERROR: /usr/lib/ruby/1.8/flvtool2.rb:228
ERROR: /usr/bin/flvtool2:2:in `require'
ERROR: /usr/bin/flvtool2:2
Creo que este error sale al tener 6 canales de audio el flv. :(
Sin embargo los que solo se recodifican con 2 canales (que el original tambien solo tiene 2 canales), el flvtool2 funciona perfectamente.
Alguien sabe como:
¿recodificar "casi" cualquier tipo de video/audio (incluido audio 5.1, 2.1, etc...) a flv (audio aac 2 canales - video h264) y despues usar flvtool2 para meter los indices?
¿U otra solucion?

Gracias y Salu2.