Opened 5 months ago

Last modified 5 months ago

#7288 new defect

The amix filter is truncating a channel on merge

Reported by: veryflatcat Owned by:
Priority: normal Component: avfilter
Version: unspecified Keywords: amix
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When merging 3 opus encoded audio channels in a mkv formatted container, the primary issue is that the first channel is incorrectly truncated. As a separate issue, the 3rd channel is incorrectly positioned in time.

We have the following from ffprobe of the input file:

    Stream #0:0: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.023000000
    Stream #0:1: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.048000000
    Stream #0:2: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.038000000
  • Stream #0.0 is 2 seconds long, starts at 0 seconds and contains a 1kHz sine wave that was opus encoded
  • Stream #0.1 is 2 seconds long, starts at 0 seconds and contains a 1.5kHz sine wave that was opus encoded
  • Strea2 #0.2 is 1 second long, with the first packet apearing at 1 second and contains a 2kHz sine wave that was opus encoded

How to reproduce:
The ffmpeg version is 4.0.1-0york0~16.04 (Ubuntu)

ffmpeg --i test.mkv -filter_complex amix=inputs=3:duration=longest -ar 8000 test.wav

This produces the expected wav file with the input stream #0:0 truncated at 1 second. The stream #0:2 starts at 0 seconds even though the first packet appears 1 second into the mkv stream.

This can be established by viewing a spectrogram of test.wav (Audacity has such a tool). Attached is the input file (test.mkv) as well as an annotated output from Audacity's spectrogram view.

Attachments (3)

test.mkv (6.8 KB) - added by veryflatcat 5 months ago.
Input file for the test
test.wav (32.0 KB) - added by veryflatcat 5 months ago.
The file produced by ffmpeg with the defects noted
Spectrogram-annotated.png (180.1 KB) - added by veryflatcat 5 months ago.
Annotated spectrogram produced by Audacity

Download all attachments as: .zip

Change History (8)

Changed 5 months ago by veryflatcat

Input file for the test

Changed 5 months ago by veryflatcat

The file produced by ffmpeg with the defects noted

Changed 5 months ago by veryflatcat

Annotated spectrogram produced by Audacity

comment:1 Changed 5 months ago by cehoyos

  • Keywords amix added

Please test current FFmpeg git head and please provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 Changed 5 months ago by veryflatcat

Full ffmpeg output:

ffmpeg version 4.0.1-0york0~16.04 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --prefix=/usr --extra-version='0york0~16.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --target-os=linux --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, matroska,webm, from 'test.mkv':
  Metadata:
    ENCODER         : Lavf57.83.100
  Duration: 00:00:02.05, start: 0.008000, bitrate: 27 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.023000000
    Stream #0:1: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.048000000
    Stream #0:2: Audio: opus, 48000 Hz, mono, fltp (default)
    Metadata:
      DURATION        : 00:00:02.038000000
File 'test.wav' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 (opus) -> amix:input0
  Stream #0:1 (opus) -> amix:input1
  Stream #0:2 (opus) -> amix:input2
  amix -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
Output #0, wav, to 'test.wav':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.18.100 pcm_s16le
size=      32kB time=00:00:02.05 bitrate= 127.4kbits/s speed= 169x    
video:0kB audio:32kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.238971%

comment:3 Changed 5 months ago by richardpl

The amix filter does not care about packet pts, so reported bug is invalid.

comment:4 Changed 5 months ago by veryflatcat

The primary bug is stream 0:0 is being incorrectly truncated, not the incorrect start time for stream 0:2

comment:5 Changed 5 months ago by veryflatcat

I can confirm that the git HEAD from github (ffmpeg version N-91396-g27662ed) exhibits the same error

Note: See TracTickets for help on using tickets.