我需要将视频内的音频转换为8位有符号PCM。我这样试试:
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -i minions.mp4 -vcodec mjpeg -s 800x480 -acodec pcm_s8 -ac 1 out.avi
输出:
ffmpeg version N-81192-g04da20e Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.100 / 57. 51.100
libavformat 57. 44.100 / 57. 44.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 49.100 / 6. 49.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'minions.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-03-17 10:06:57
Duration: 00:03:18.72, start: 0.000000, bitrate: 1869 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1675 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default
)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
[swscaler @ 04821880] deprecated pixel format used, make sure you did set range correctly
[avi @ 048c0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'out.avi':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf57.44.100
Stream #0:0(und): Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 800x480 [SAR 16:15 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.51.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: pcm_s8, 44100 Hz, mono, u8, 352 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
encoder : Lavc57.51.100 pcm_s8
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Stream #0:1 -> #0:1 (aac (native) -> pcm_s8 (native))
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
ffmpeg无法为输出文件写入标头。我想提一下,如果选择音频编码器到pcm_u8,一切正常。
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -i minions.mp4 -vcodec mjpeg -s 800x480 -acodec pcm_u8 -ac 1 out.avi
输出:
ffmpeg version N-81192-g04da20e Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
openjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 51.100 / 57. 51.100
libavformat 57. 44.100 / 57. 44.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 49.100 / 6. 49.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'minions.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-03-17 10:06:57
Duration: 00:03:18.72, start: 0.000000, bitrate: 1869 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1675 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default
)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
File 'out.avi' already exists. Overwrite ? [y/N] y
[swscaler @ 030a1880] deprecated pixel format used, make sure you did set range correctly
[avi @ 04a10460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, avi, to 'out.avi':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
ISFT : Lavf57.44.100
Stream #0:0(und): Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 800x480 [SAR 16:15 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.51.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1(und): Audio: pcm_u8 ([1][0][0][0] / 0x0001), 44100 Hz, mono, u8, 352 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:06:58
handler_name : IsoMedia File Produced by Google, 5-11-2011
encoder : Lavc57.51.100 pcm_u8
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Stream #0:1 -> #0:1 (aac (native) -> pcm_u8 (native))
Press [q] to stop, [?] for help
frame= 4764 fps=250 q=24.8 Lsize= 74247kB time=00:03:18.71 bitrate=3060.8kbits/s speed=10.4x
video:65364kB audio:8558kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.438745%
有什么问题?为什么转换对签名的pcm不起作用?
可以使用无符号和有符号pcm的编码器:
C:\Users\E\Desktop\ffmpeg-20160731-04da20e-win32-static\bin>ffmpeg -encoders
.
.
A..... pcm_f32be PCM 32-bit floating point big-endian
A..... pcm_f32le PCM 32-bit floating point little-endian
A..... pcm_f64be PCM 64-bit floating point big-endian
A..... pcm_f64le PCM 64-bit floating point little-endian
A..... pcm_mulaw PCM mu-law / G.711 mu-law
A..... pcm_s16be PCM signed 16-bit big-endian
A..... pcm_s16be_planar PCM signed 16-bit big-endian planar
A..... pcm_s16le PCM signed 16-bit little-endian
A..... pcm_s16le_planar PCM signed 16-bit little-endian planar
A..... pcm_s24be PCM signed 24-bit big-endian
A..... pcm_s24daud PCM D-Cinema audio signed 24-bit
A..... pcm_s24le PCM signed 24-bit little-endian
A..... pcm_s24le_planar PCM signed 24-bit little-endian planar
A..... pcm_s32be PCM signed 32-bit big-endian
A..... pcm_s32le PCM signed 32-bit little-endian
A..... pcm_s32le_planar PCM signed 32-bit little-endian planar
A..... pcm_s8 PCM signed 8-bit
A..... pcm_s8_planar PCM signed 8-bit planar
A..... pcm_u16be PCM unsigned 16-bit big-endian
A..... pcm_u16le PCM unsigned 16-bit little-endian
A..... pcm_u24be PCM unsigned 24-bit big-endian
A..... pcm_u24le PCM unsigned 24-bit little-endian
A..... pcm_u32be PCM unsigned 32-bit big-endian
A..... pcm_u32le PCM unsigned 32-bit little-endian
A..... pcm_u8 PCM unsigned 8-bit
.
.
答案 0 :(得分:0)
您的错误不是关于音频,而是关于视频:
[swscaler @ 04821880] deprecated pixel format used, make sure you did set range correctly
[avi @ 048c0460] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
我认为您可以尝试设置像素格式。它可以解决它。
我想提一下,如果选择音频编码器到pcm_u8,一切正常。
请通过编辑,在qustion中放置此转换的命令和输出(包括它的'stream mapping'之前的所有内容)。
答案 1 :(得分:0)
AVI复用器调用的RIFF函数不支持为PCM_S8流写入标记,因此显然这就是为什么你不能将它写入AVI或WAV。
您可以使用MOV或NUT格式。
如果您需要使用AVI,您将获得LPCM的S16LE,S24LE,S32LE,F32LE,F64LE和U8变体。
要使用IMA ADPCM进行编码,请使用
ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a adpcm_ima_wav -ac 1 out.avi
要使用mu-law PCM进行编码,请使用
ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a pcm_mulaw -ac 1 out.avi
答案 2 :(得分:0)
我的公司正在使用FT810构建设备,这是我想出的转换脚本:
AUDIO_SAMPLE_RATE=8000
VIDEO_FRAME_RATE=8
VIDEO_Y_POS=266 # Place video in 2/3rds up from bottom of screen
ffmpeg -i source/audio.mp3 -r 65535/2733 -vn -c:a libmp3lame -ar $AUDIO_SAMPLE_RATE -ac 1 -ab 128k -y /tmp/resampled.mp3
ffmpeg -i source/video.gif \
-i /tmp/resampled.mp3 \
-filter:v scale=420:-2,pad=420:270+ih/2:0:270-ih/2:black \
-pix_fmt yuvj420p -vcodec mjpeg -acodec pcm_s16le -r:v $VIDEO_FRAME_RATE -b:v 0.1M -ac 1 -shortest -y output/startup.avi
请注意,我正在使用pcm_s16le,因为文档说:“通过在每个位中分别放低8位,部分支持16位PCM 音频样本。”