Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#3562 closed defect (fixed)

filter_complex aresample;format fails with some avi

Reported by: Christian Ebert Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

$ ffmpeg -i test.avi -filter_complex '[0:0]format=yuv420p;[0:1]aresample=osr=22050' test.webm
ffmpeg version N-62058-gfd2bcfc Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr  3 2014 09:02:28 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --disable-ffserver --enable-shared --enable-libfdk-aac --enable-libx265 --enable-libx264 --enable-libxvid --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --extra-cflags=-I/sw/include --extra-libs=-L/sw/lib
  libavutil      52. 71.100 / 52. 71.100
  libavcodec     55. 56.107 / 55. 56.107
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 0x7fc833021800] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'test.avi':
  Duration: 00:00:31.86, start: 0.000000, bitrate: 11205 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1280x720, 10851 kb/s, 29.95 tbr, 29.95 tbn, 29.95 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
[swscaler @ 0x7fc83380f400] deprecated pixel format used, make sure you did set range correctly
[libvpx @ 0x7fc833805200] v1.3.0-2130-g5c185a0
Output #0, webm, to 'test.webm':
  Metadata:
    encoder         : Lavf55.36.101
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 1280x720, q=-1--1, 200 kb/s, 1k tbn, 29.95 tbc (default)
    Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp (default)
Stream mapping:
  Stream #0:0 (mjpeg) -> format
  Stream #0:1 (pcm_s16le) -> aresample
  format -> Stream #0:0 (libvpx)
  aresample -> Stream #0:1 (libvorbis)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:yuvj420p
[swscaler @ 0x7fc834006200] deprecated pixel format used, make sure you did set range correctly
[libvorbis @ 0x7fc833805e00] nb_samples (1024) != frame_size (64) (avcodec_encode_audio2)
Audio encoding failed (avcodec_encode_audio2)

Similarly with aformat.

Using options to the same intended effect works:

$ ffmpeg -i test.avi -filter_complex '[0:0]format=yuv420p' -ar 22050 test.webm
ffmpeg version N-62058-gfd2bcfc Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr  3 2014 09:02:28 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --disable-ffserver --enable-shared --enable-libfdk-aac --enable-libx265 --enable-libx264 --enable-libxvid --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --extra-cflags=-I/sw/include --extra-libs=-L/sw/lib
  libavutil      52. 71.100 / 52. 71.100
  libavcodec     55. 56.107 / 55. 56.107
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 0x7fb47b021800] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'test.avi':
  Duration: 00:00:31.86, start: 0.000000, bitrate: 11205 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1280x720, 10851 kb/s, 29.95 tbr, 29.95 tbn, 29.95 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
[swscaler @ 0x7fb47b80ae00] deprecated pixel format used, make sure you did set range correctly
[libvpx @ 0x7fb47b800c00] v1.3.0-2130-g5c185a0
Output #0, webm, to 'test.webm':
  Metadata:
    encoder         : Lavf55.36.101
    Stream #0:0: Video: vp8 (libvpx), yuv420p, 1280x720, q=-1--1, 200 kb/s, 1k tbn, 29.95 tbc
    Stream #0:1: Audio: vorbis (libvorbis), 22050 Hz, mono, fltp
Stream mapping:
  Stream #0:0 (mjpeg) -> format (graph 0)
  format (graph 0) -> Stream #0:0 (libvpx)
  Stream #0:1 -> #0:1 (pcm_s16le -> libvorbis)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:yuvj420p
[swscaler @ 0x7fb47b0bd600] deprecated pixel format used, make sure you did set range correctly
frame=  623 fps= 17 q=0.0 Lsize=    1250kB time=00:00:31.69 bitrate= 323.0kbits/s
video:1076kB audio:156kB subtitle:0kB other streams:0kB global headers:3kB muxing overhead: 1.386226%

Attachments (1)

issue3562_cut.avi (2.4 MB ) - added by Carl Eugen Hoyos 11 years ago.

Change History (8)

comment:1 by Carl Eugen Hoyos, 11 years ago

Please provide the input sample.

in reply to:  1 comment:2 by Christian Ebert, 11 years ago

Replying to cehoyos:

Please provide the input sample.

Clipped sample, but both the failing filter command and the succeeding option command can be replicated with:
incoming/issue3562.avi

comment:3 by Carl Eugen Hoyos, 11 years ago

Reproduced by developer: set
Status: newopen
Summary: aresample, aformat fails with libvorbis and some avifilter_complex aresample;format fails with some avi

Works fine with -vf format=yuv420p -af aresample=osr=22050.

Remuxing does not fix the issue, reencoding video (or using an audio codec that is not pcm) does.

$ ffmpeg -i issue3562_cut.avi -filter_complex 'format=yuv420p;aresample=out_sample_rate=22050' out.avi
ffmpeg version N-62483-gcb53beb Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 16 2014 12:57:30 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      52. 76.100 / 52. 76.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'issue3562_cut.avi':
  Duration: 00:00:01.84, start: 0.000000, bitrate: 11150 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1280x720, 29.95 tbr, 29.95 tbn, 29.95 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
[swscaler @ 0x361c0c0] deprecated pixel format used, make sure you did set range correctly
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf55.37.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720, q=2-31, 200 kb/s, 29.95 tbn, 29.95 tbc (default)
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 22050 Hz, mono, fltp, 96 kb/s (default)
Stream mapping:
  Stream #0:0 (mjpeg) -> format
  Stream #0:1 (pcm_s16le) -> aresample
  format -> Stream #0:0 (mpeg4)
  aresample -> Stream #0:1 (ac3)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:yuvj420p
[swscaler @ 0x361c0c0] deprecated pixel format used, make sure you did set range correctly
[ac3 @ 0x36396e0] nb_samples (1024) != frame_size (1536) (avcodec_encode_audio2)
Audio encoding failed (avcodec_encode_audio2)

by Carl Eugen Hoyos, 11 years ago

Attachment: issue3562_cut.avi added

in reply to:  3 ; comment:4 by Christian Ebert, 11 years ago

Replying to cehoyos:

Works fine with -vf format=yuv420p -af aresample=osr=22050.

Note that it also depends on the output format or codecs, when encoding to mp4 with libfaac or libfdk_aac -filter_complex does not bark (that's why I had libvorbis in the bug title):

$ ffmpeg -i test.avi -filter_complex '[0:0]format=yuv420p;[0:1]aresample=osr=22050' test.mp4
ffmpeg version N-62462-g2b58c9c Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr 15 2014 11:25:24 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --disable-ffserver --enable-shared --enable-libfdk-aac --enable-libx265 --enable-libx264 --enable-libxvid --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --extra-cflags=-I/sw/include --extra-libs=-L/sw/lib
  libavutil      52. 76.100 / 52. 76.100
  libavcodec     55. 58.103 / 55. 58.103
  libavformat    55. 37.100 / 55. 37.100
  libavdevice    55. 13.100 / 55. 13.100
  libavfilter     4.  4.100 /  4.  4.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 0x7fdd33821800] non-interleaved AVI
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, avi, from 'test.avi':
  Duration: 00:00:31.86, start: 0.000000, bitrate: 11205 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc), 1280x720, 10851 kb/s, 29.95 tbr, 29.95 tbn, 29.95 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
[swscaler @ 0x7fdd3400fa00] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7fdd34005200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fdd34005200] profile High, level 3.1
[libx264 @ 0x7fdd34005200] 264 - core 142 r2409M d6b4e63 - 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=12 lookahead_threads=2 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, mp4, to 'test.mp4':
  Metadata:
    encoder         : Lavf55.37.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=-1--1, 318k tbn, 29.95 tbc (default)
    Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 22050 Hz, mono, s16, 128 kb/s (default)
Stream mapping:
  Stream #0:0 (mjpeg) -> format
  Stream #0:1 (pcm_s16le) -> aresample
  format -> Stream #0:0 (libx264)
  aresample -> Stream #0:1 (libfaac)
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:1280x720 fmt:yuvj422p to size:1280x720 fmt:yuvj420p
[swscaler @ 0x7fdd34897800] deprecated pixel format used, make sure you did set range correctly
frame=  948 fps= 56 q=-1.0 Lsize=   12501kB time=00:00:31.67 bitrate=3233.5kbits/s dup=325 drop=0
video:12334kB audio:147kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.168717%
[libx264 @ 0x7fdd34005200] frame I:60    Avg QP:20.34  size: 41679
[libx264 @ 0x7fdd34005200] frame P:794   Avg QP:23.99  size: 12073
[libx264 @ 0x7fdd34005200] frame B:94    Avg QP:25.94  size:  5773
[libx264 @ 0x7fdd34005200] consecutive B-frames: 82.6% 10.8%  5.4%  1.3%
[libx264 @ 0x7fdd34005200] mb I  I16..4:  4.9% 93.9%  1.2%
[libx264 @ 0x7fdd34005200] mb P  I16..4:  3.1% 14.6%  0.2%  P16..4: 35.5%  4.3%  2.0%  0.0%  0.0%    skip:40.1%
[libx264 @ 0x7fdd34005200] mb B  I16..4:  0.3%  1.3%  0.0%  B16..8: 35.0%  2.6%  0.3%  direct: 4.9%  skip:55.5%  L0:39.0% L1:56.6% BI: 4.4%
[libx264 @ 0x7fdd34005200] 8x8 transform intra:84.9% inter:89.9%
[libx264 @ 0x7fdd34005200] coded y,uvDC,uvAC intra: 65.1% 93.8% 47.7% inter: 18.3% 40.4% 3.7%
[libx264 @ 0x7fdd34005200] i16 v,h,dc,p: 13% 20%  9% 57%
[libx264 @ 0x7fdd34005200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 18% 37%  4%  4%  4%  5%  5%  5%
[libx264 @ 0x7fdd34005200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 27% 14%  5%  9%  6% 10%  5%  3%
[libx264 @ 0x7fdd34005200] i8c dc,h,v,p: 59% 20% 16%  5%
[libx264 @ 0x7fdd34005200] Weighted P-Frames: Y:1.1% UV:0.5%
[libx264 @ 0x7fdd34005200] ref P L0: 65.1%  9.1% 12.7% 13.0%  0.1%
[libx264 @ 0x7fdd34005200] ref B L0: 86.9% 12.3%  0.8%
[libx264 @ 0x7fdd34005200] ref B L1: 94.8%  5.2%
[libx264 @ 0x7fdd34005200] kb/s:3191.54
Last edited 11 years ago by Christian Ebert (previous) (diff)

in reply to:  4 comment:5 by Carl Eugen Hoyos, 11 years ago

Replying to blacktrash:

Replying to cehoyos:

Works fine with -vf format=yuv420p -af aresample=osr=22050.

Note that it also depends on the output format

I don't think it depends on the output format.

or codecs, when encoding to mp4 with libfaac or libfdk_aac -filter_complex does not bark

(that's why I had libvorbis in the bug title):

Mentioning an optional external library for an issue that is reproducible with most internal default encoders is hardly a good idea.

comment:6 by Michael Niedermayer, 10 years ago

Resolution: fixed
Status: openclosed

in reply to:  6 comment:7 by Christian Ebert, 10 years ago

Replying to michael:

Fixed in 16de4d927e8bd1308694217af6027265700b3694

First tests confirm that the fix does its job. Thank you.

Note: See TracTickets for help on using tickets.