Opened 9 years ago

Closed 6 years ago

#4590 closed defect (fixed)

concat filter does not work to loop audio

Reported by: Carl Eugen Hoyos Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: concat
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Elon Musk)

As reported by irc user chama
The following works as expected:

$ ffmpeg -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -filter_complex [0:a][1:a][2:a]concat=n=3:v=0:a=1 out.wav

The output file has a correct length of 2:10

The following claims to encode 2:10 but the output file is much shorter:

$ ffmpeg -i fate-suite/svq3/Vertical400kbit.sorenson3.mov -filter_complex [0:a][0:a][0:a]concat=n=3:v=0:a=1 out.wav
ffmpeg version N-72624-g196b885 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      54. 26.101 / 54. 26.101
  libavcodec     56. 41.101 / 56. 41.101
  libavformat    56. 34.100 / 56. 34.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  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 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fate-suite/svq3/Vertical400kbit.sorenson3.mov':
  Metadata:
    creation_time   : 2001-03-20 16:17:18
    title           : Vertical Online SV3 Demo
    title-eng       : Vertical Online SV3 Demo
    artist          : Logan Kelsey
    artist-eng      : Logan Kelsey
    copyright       : (c) Vertical Online 2001
    copyright-eng   : (c) Vertical Online 2001
    encoder         : Sorenson Video 3
    encoder-eng     : Sorenson Video 3
  Duration: 00:00:43.58, start: 0.000000, bitrate: 580 kb/s
    Stream #0:0(eng): Video: svq3 (SVQ3 / 0x33515653), yuvj420p(pc), 320x240, 391 kb/s, 30.02 fps, 30 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
      encoder         : Sorenson Video 3
    Stream #0:1(eng): Audio: adpcm_ima_qt (ima4 / 0x34616D69), 44100 Hz, 1 channels, s16p, 176 kb/s (default)
    Metadata:
      creation_time   : 2001-03-20 16:17:18
      handler_name    : Apple Alias Data Handler
Output #0, wav, to 'out.wav':
  Metadata:
    ISFT            : Lavf56.34.100
    INAM            : Vertical Online SV3 Demo
    title-eng       : Vertical Online SV3 Demo
    IART            : Logan Kelsey
    artist-eng      : Logan Kelsey
    ICOP            : (c) Vertical Online 2001
    copyright-eng   : (c) Vertical Online 2001
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s (default)
    Metadata:
      encoder         : Lavc56.41.101 pcm_s16le
Stream mapping:
  Stream #0:1 (adpcm_ima_qt) -> concat:in0:a0
  Stream #0:1 (adpcm_ima_qt) -> concat:in1:a0
  Stream #0:1 (adpcm_ima_qt) -> concat:in2:a0
  concat -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
Multiple frames in a packet from stream 1
[Parsed_concat_0 @ 0x26bed40] Buffer queue overflow, dropping.
    Last message repeated 59539 times
[output stream 0:0 @ 0x26bf600] 100 buffers queued in output stream 0:0, something may be wrong.
size=    3817kB time=00:02:10.72 bitrate= 239.2kbits/s
video:0kB audio:3817kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.004247%
$ ffmpeg -i out.wav
ffmpeg version N-72624-g196b885 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      54. 26.101 / 54. 26.101
  libavcodec     56. 41.101 / 56. 41.101
  libavformat    56. 34.100 / 56. 34.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  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.0 : mono
Input #0, wav, from 'out.wav':
  Metadata:
    artist          : Logan Kelsey
    copyright       : (c) Vertical Online 2001
    title           : Vertical Online SV3 Demo
    encoder         : Lavf56.34.100
  Duration: 00:00:44.32, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
At least one output file must be specified

Change History (5)

comment:1 by Cigaes, 9 years ago

This is more or less unavoidable: the decoded frames need to be stored for the second and third segment while they are encoded for the first segment. Storing unlimited amounts of decoded data can almost-crash users' hosts, and since it is usually sign that something is wrong in the graph, lavfi has fairly low limits.
I have started reworking lavfi's scheduling, the final result would give more fine grained on the size of the buffers, but it is far from done yet and I have other more urgent projects.
In the meantime, you can use the fifo filter to add an unlimited buffer, but only do so if it is really necessary.
For now, unless there is a genuinely useful use case for this, I suggest to close this ticket as WONTFIX.

in reply to:  1 comment:2 by Carl Eugen Hoyos, 9 years ago

Replying to Cigaes:

In the meantime, you can use the fifo filter to add an unlimited buffer, but only do so if it is really necessary.

Could you provide a sample command?

comment:3 by Cigaes, 9 years ago

[0:a]afifo[a1];[0:a]afifo[a2];[0:a][a1][a2]concat=n=3:v=0:a=1

in the filter graph is enough.

comment:4 by Elon Musk, 8 years ago

Component: undeterminedavfilter
Description: modified (diff)
Status: newopen

comment:5 by Elon Musk, 6 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.