ffmpeg audio conversion: encoder pcm_u8 working pcm_s8 not

ffmpeg audio formats
pcm_mulaw
ffmpeg ar
ffmpeg s16p
ffmpeg s161e
ffmpeg raw
pcm_s24be
pcm_s161e

I need to convert audio inside video to 8 Bit signed PCM. I try it like this:

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

output:

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 can not write a header for output file. I want to mention that if audio encoder is selected to pcm_u8 everything works fine.

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

output:

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%

What is the problem ? Why conversion does not work for signed pcm ?

Encoders for both unsigned and signed pcm are avaible:

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
 .
 .

Your error not about audio, it's about video:

[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

I think you can try to set pixel format as it asking. it could solve it.

I want to mention that if audio encoder is selected to pcm_u8 everything works fine.

Please, place the command for this convertion and the output (averything before 'stream mapping' including it) in your qustion by editing it.

audio types – FFmpeg, For example, you can read and write raw PCM audio into a WAV container. For instance, to convert a "raw" audio type to a ".wav" file: ffmpeg -f which will create a WAV file containing audio with that codec (not a raw file). I'm attempting to convert a voicemail audio file to another format. This stopped working some time last week (8/13-8/17). Actual behavior. Line 672 in audio_segment.py (acodec = 'pcm_s%dle' % bits_per_sample) uses 8 bits per sample, which then passes "-acodec pcm_s8le" to ffmpeg, which is an unsupported encoder per "ffmpeg -encoders".

The RIFF function called by the AVI muxer does not support writing a tag for PCM_S8 streams, so apparently that's why you can't write it to AVIs or WAVs.

You can use MOV or NUT formats.

If you need to use AVI, you are left with S16LE, S24LE, S32LE, F32LE, F64LE and U8 variants of LPCM.


To encode using IMA ADPCM, use

ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a adpcm_ima_wav -ac 1 out.avi

To encode using mu-law PCM, use

ffmpeg -i minions.mp4 -c:v mjpeg -s 800x480 -c:a pcm_mulaw -ac 1 out.avi

Change codec of WAV file, Change codec of WAV file · ffmpeg wav audio-conversion. Is there a way to change the codec/format of WAV file? Can I use  Hi is it possible to turn off dithering in ffmpeg while doing audio format conversion. I came across a switch called dither_scale, which can be set to 0 while resampling. But I don't know how to turn off dithering while converting to different file format (16 bit PCM)

My company is building a device using the FT810 and this is the conversion script I have come up with:

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

Notice that I am using pcm_s16le, because the documentation says "16 Bit PCM is partially supported by dropping off less significant 8 bits in each audio sample."

Convert mp3 to wav using FFmpeg for VBR, ffmpeg -i song.mp3 -acodec pcm_u8 -ar 22050 song.wav We can see that this audio file is a mp3 (this is not obvious, despite of the extension of the 44100 Hz​, stereo, s16, 1411 kb/s Metadata: encoder : Lavc56.1.100 pcm_s16le Stream  The RIFF function called by the AVI muxer does not support writing a tag for PCM_S8 streams, so apparently that's why you can't write it to AVIs or WAVs. You can use MOV or NUT formats. If you need to use AVI, you are left with S16LE, S24LE, S32LE, F32LE, F64LE and U8 variants of LPCM. To encode using IMA ADPCM, use.

FFmpeg - Community Help Wiki, To convert a video, simply run the command "ffmpeg" with four additional parts: pass to speed it up: "-an" specifies that there is no audio codec to be run. 32-bit little-endian DEA pcm_s8 PCM signed 8-bit DEA pcm_u16be PCM PCM unsigned 32-bit little-endian DEA pcm_u8 PCM unsigned 8-bit DEA  I am having the same issue as asmedrano Apparently it is an issue with ffmpeg?? I can't seem to get it to work. I should have DE capabilities for mp3, but it's not working ffmpeg -y -f wav -i ./mix.wav -f mp3 ./out.mp3FFmpeg version SVN-

How do I know which codec when encoding a new container format , r/ffmpeg: FFmpeg is the leading multimedia framework, able to decode, I have gotten conversion to work with a few combinations, but there doesn't seem AudioFormat(format).packed, layout=channel_layout, rate=frame_rate ) for frame in inp.decode(audio=0): ValueError: 'wav' format does not support 'pcm_s8' codec. 2.100 Input #0, lavfi, from 'anullsrc=cl=octagonal': Duration: N/A, start: 0.000000, bitrate: 2822 kb/s Stream #0:0: Audio: pcm_u8, 44100 Hz, octagonal, u8, 2822 kb/s Stream mapping: Stream #0:0 -> #0:0 (pcm_u8 (native) -> aac (aac_at)) Press [q] to stop, [?] for help [aac_at @ 0x7fce92800000] Specified channel layout '5.1' is not supported

Convert an AVCHD / MTS file to MP4 using ffmpeg, 27.1 most used video codecs that ffmpeg can encode; 27.2 all video codecs The commandline options -sameq and -vcodec copy don't seem to work here. Here, we assume that the video file does not contain any audio stream S pcm_u8 PCM unsigned 8-bit D.A.L. pcm_zork PCM Zork D.A.L. qcelp  When trying to convert a video from MJPEG to WebM (VP8/Vorbis), i get a '100 buffers queued in output stream 0:1' message. How to reproduce: % ffmpeg -y -i input.avi -codec:v libvpx -codec:a libvorbis output.webm

Comments
  • As you can see it works for unsigned pcm even though warnings (piexel format, and avstream.codec) are still there. I will try to set pixel format corretly, first I have to find out how to do it :P
  • Thank you. Do you have any ideas how can I achieve one of these formats: 4 Bit IMA ADPCM, 8 Bit signed PCM, 8 Bit u-Law in AVI mjpeg-encoded videos? I need it, because the chip I'm using for diplaying video (FT810) can not handle other ones.. "For the audio data encoded into MJPEG-encoded AVI video , three formats are supported: 4 Bit IMA ADPCM, 8 Bit signed PCM, 8 Bit u-Law" It only supports MJPEG AVI of course.