Eu tenho um arquivo - sample.mkv
=========================================================
File: sample.mkv
Width: 854 pixels
Height: 480 pixels
Aspect ratio: 1.77:1
Frames: 0
Duration: 00:00:33 hours/mins/secs
Framerate: 25.000 frames per second
Video format: H264
Video bitrate: 0 bits per second
---------------------------
Audio track 1 (Stream 0.1, AID 0):
---------------------------
Codec: pcm_s16le
Bitrate: 4233000 bits per second
Sampling rate: 44100 Hz
=========================================================
Quero recodificá-lo no contêiner FLV via ffmpeg:
$ ffmpeg -i sample.mkv -b:a 4233k -c:v h264 -c:a pcm_s16le sample.flv
mas recebi:
=========================================================
File: sample.flv
Width: 854 pixels
Height: 480 pixels
Aspect ratio: 1.77:1
Frames: 0
Duration: 00:00:33 hours/mins/secs
Framerate: 25.000 frames per second
Video format: H264
Video bitrate: 0 bits per second
---------------------------
Audio track 1 (Stream 0.1, AID 0):
---------------------------
Codec: pcm_s16le
Bitrate: 1411000 bits per second
Sampling rate: 44100 Hz
=========================================================
Por que a taxa de bits vai para 4233000 -> 1411000?
Nesse quesito o som fica muito ruim :(
ATUALIZAR registro completo
ffmpeg -i sample.mkv -b:a 4233k -c:v h264 -c:a pcm_s16le sample.flv
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/opt/ffmpeg --libdir=/opt/ffmpeg/lib/ --enable-shared --enable-avresample --disable-stripping --enable-gpl --enable-version3 --enable-nonfree --enable-runtime-cpudetect --build-suffix=.ffmpeg --enable-postproc --enable-x11grab --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-libfdk_aac --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-openal --enable-opengl --enable-pthreads --enable-vaapi --enable-vdpau --enable-zlib --enable-debug=3
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, matroska,webm, from 'sample.mkv':
Metadata:
MINOR_VERSION : 512
COMPATIBLE_BRANDS: qt
MAJOR_BRAND : qt
ENCODER : Lavf56.25.101
Duration: 00:00:33.08, start: 0.080000, bitrate: 4691 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 libx264
Stream #0:1(eng): Audio: pcm_s16le, 44100 Hz, 6 channels, s16, 4233 kb/s (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 pcm_s16le
[libx264 @ 0x914de0] using SAR=1/1
[libx264 @ 0x914de0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x914de0] profile High, level 3.0
[libx264 @ 0x914de0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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 lookahead_threads=1 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=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'sample.flv':
Metadata:
MINOR_VERSION : 512
COMPATIBLE_BRANDS: qt
MAJOR_BRAND : qt
encoder : Lavf56.25.101
Stream #0:0(eng): Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 854x480 [SAR 1:1 DAR 427:240], q=-1--1, 25 fps, 1k tbn, 25 tbc (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
encoder : Lavc56.26.100 libx264
Stream #0:1(eng): Audio: pcm_s16le ([3][0][0][0] / 0x0003), 44100 Hz, 5.1, s16, 4233 kb/s (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
encoder : Lavc56.26.100 pcm_s16le
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
frame= 812 fps= 93 q=-1.0 Lsize= 18938kB time=00:00:33.00 bitrate=4700.7kbits/s
video:1841kB audio:17056kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.214361%
[libx264 @ 0x914de0] frame I:23 Avg QP:16.97 size: 20207
[libx264 @ 0x914de0] frame P:294 Avg QP:20.61 size: 3904
[libx264 @ 0x914de0] frame B:495 Avg QP:23.24 size: 550
[libx264 @ 0x914de0] consecutive B-frames: 15.0% 7.9% 9.6% 67.5%
[libx264 @ 0x914de0] mb I I16..4: 34.6% 45.1% 20.3%
[libx264 @ 0x914de0] mb P I16..4: 3.5% 12.4% 0.8% P16..4: 19.1% 5.7% 2.4% 0.0% 0.0% skip:56.0%
[libx264 @ 0x914de0] mb B I16..4: 0.4% 0.4% 0.1% B16..8: 12.5% 1.0% 0.1% direct: 0.5% skip:85.1% L0:43.1% L1:50.9% BI: 5.9%
[libx264 @ 0x914de0] 8x8 transform intra:64.0% inter:75.7%
[libx264 @ 0x914de0] coded y,uvDC,uvAC intra: 33.0% 43.7% 13.4% inter: 4.1% 6.8% 1.0%
[libx264 @ 0x914de0] i16 v,h,dc,p: 53% 22% 9% 16%
[libx264 @ 0x914de0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 21% 27% 3% 5% 4% 5% 4% 4%
[libx264 @ 0x914de0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 20% 12% 5% 7% 9% 6% 8% 5%
[libx264 @ 0x914de0] i8c dc,h,v,p: 62% 20% 14% 5%
[libx264 @ 0x914de0] Weighted P-Frames: Y:32.0% UV:30.6%
[libx264 @ 0x914de0] ref P L0: 72.5% 16.1% 8.0% 3.3% 0.1%
[libx264 @ 0x914de0] ref B L0: 86.4% 11.6% 2.0%
[libx264 @ 0x914de0] ref B L1: 95.1% 4.9%
[libx264 @ 0x914de0] kb/s:464.26
ATUALIZAÇÃO 2:
ffmpeg -i sample.mkv -ac 6 -c copy sample.flv
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --prefix=/opt/ffmpeg --libdir=/opt/ffmpeg/lib/ --enable-shared --enable-avresample --disable-stripping --enable-gpl --enable-version3 --enable-nonfree --enable-runtime-cpudetect --build-suffix=.ffmpeg --enable-postproc --enable-x11grab --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-libfdk_aac --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-openal --enable-opengl --enable-pthreads --enable-vaapi --enable-vdpau --enable-zlib --enable-debug=3
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Guessed Channel Layout for Input Stream #0.1 : 5.1
Input #0, matroska,webm, from 'sample.mkv':
Metadata:
MINOR_VERSION : 512
COMPATIBLE_BRANDS: qt
MAJOR_BRAND : qt
ENCODER : Lavf56.25.101
Duration: 00:00:33.08, start: 0.080000, bitrate: 4691 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 854x480 [SAR 1:1 DAR 427:240], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 libx264
Stream #0:1(eng): Audio: pcm_s16le, 44100 Hz, 6 channels, s16, 4233 kb/s (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 pcm_s16le
Output #0, flv, to 'sample.flv':
Metadata:
MINOR_VERSION : 512
COMPATIBLE_BRANDS: qt
MAJOR_BRAND : qt
encoder : Lavf56.25.101
Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 854x480 [SAR 1:1 DAR 427:240], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 libx264
Stream #0:1(eng): Audio: pcm_s16le ([3][0][0][0] / 0x0003), 44100 Hz, 5.1, 4233 kb/s (default)
Metadata:
LANGUAGE : eng
HANDLER_NAME : DataHandler
ENCODER : Lavc56.26.100 pcm_s16le
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 812 fps=0.0 q=-1.0 Lsize= 18968kB time=00:00:33.00 bitrate=4708.2kbits/s
video:1872kB audio:17056kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.214011%
Responder1
Pelo que sei, o formato FLV não suporta oficialmente áudio descompactado no formato PCM (veja oespecificação). No entanto, você ainda pode multiplexar áudio PCM em FLV com ffmpeg. Parece haver um bug ou incompatibilidade em ffplay
não reproduzir o áudio corretamente, mas funciona para mim no VLC:
ffmpeg -i sample.mkv -c copy sample.flv
Se quiser ser mais compatível com outros players, você pode restringir o áudio a dois canais. Fazer isso:
ffmpeg -i sample.mkv -c:v copy -c:a pcm_s16le -ac 2 sample.flv
Isso reduzirá o número de canais de áudio, mas eles não perderão qualidade. A taxa de bits parecerá mais baixa, mas são menos canais.
Suas outras opções são áudio AAC ou áudio MP3:
ffmpeg -i sample.mkv -c:v copy -c:a aac -strict experimental -b:a 128k sample.flv
ffmpeg -i sample.mkv -c:v copy -c:a libmp3lame sample.flv
Isso converterá automaticamente o áudio multicanal em estéreo.
Observe que se estiver usando MP3 em FLV você estará restrito às seguintes taxas de amostragem de áudio: 44100, 22050, 11025. Isso pode ser definido com a -ar
opção ouaresample
filtro.