FFMPEG get stuck when transcoding too many FLAC audios

  Kiến thức lập trình

I’m currently using Editly for create some videos from code, but there are some bugs with ffmpeg(latest).

Nothing returns after hours processing(460 audios files during test), I already tried with flac, aac, libshine and libmp3lame encoders, already tried a different a ffmpeg version(static).

From the editly code, I already changed the ffmpeg query, slicing in chunks(75), the results were:

  • 0, 75 ok
  • 0, 80 stuck
  • 75, 150 ok
  • 150, 225 ok
  • 225, 300 stuck
  • 300, 375 ok
  • 375, 450 ok

Stuck screen(directly from terminal):

built with gcc 13 (Ubuntu 13.2.0-23ubuntu4)
  configuration: --pkg-config-flags=--static --prefix='~/ffmpeg/dyn' --extra-cflags='-I/~/ffmpeg/dyn/include' --extra-ldflags='-L/~/ffmpegffmpeg/dyn/lib' --bindir='~/ffmpeg/dyn/bin' --enable-debug=3 --enable-vaapi --enable-libvorbis --enable-libvpx --enable-gpl --cpu=native --enable-opengl --enable-libfdk-aac --enable-libx264 --enable-nonfree --enable-libmp3lame --enable-libshine
  libavutil      59. 21.100 / 59. 21.100
  libavcodec     61.  6.100 / 61.  6.100
  libavformat    61.  3.104 / 61.  3.104
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100

Input #n..., flac, from 'editly-tmp-.../clip...-audio.flac':
  Metadata:
    encoder         : Lavf61.3.104
  Duration: 00:01:53.62, start: 0.000000, bitrate: 1 kb/s
  Stream #458:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit)
Stream mapping:
  Stream #n1:0 (flac) -> acrossfade
  Stream #n2:0 (flac) -> acrossfade
  Stream #n3:0 (flac) -> acrossfade
  Stream #n...:0 (flac) -> acrossfade
  acrossfade:default -> Stream #0:0 (libshine)
  Press [q] to stop, [?] for help

if I quit then returns:

[fc#0 @] [ao0->#0:0 @] No filtered frames for output stream, trying to initialize anyway.
Output #0, mp3, to 'editly-tmp-.../audio-concat.mp3':
  Metadata:
    TSSE            : Lavf61.3.104
  Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16p, 128 kb/s
      Metadata:
        encoder         : Lavc61.6.100 libshine
[out#0/mp3 @ 0x60633b423480] video:0KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
[out#0/mp3 @ 0x60633b423480] Output file is empty, nothing was encoded(check -ss / -t / -frames parameters if used)
size=       0KiB time=N/A bitrate=N/A speed=N/A    

Editly code for generating FFMPEG query:

    let inStream = '[0:a]';
    const filterGraph = clipAudio.slice(0, -1).map(({ transition }, i) => {
      const outStream = `[concat${i}]`;

      const epsilon = 0.0001; // If duration is 0, ffmpeg seems to default to 1 sec instead, hence epsilon.
      let ret = `${inStream}[${i + 1}:a]acrossfade=d=${Math.max(epsilon, transition.duration)}:c1=${transition.audioOutCurve || 'tri'}:c2=${transition.audioInCurve || 'tri'}`;

      inStream = outStream;

      if (i < clipAudio.length - 2) ret += outStream;
      return ret;
    }).join(',');

    const args = [
      ...getFfmpegCommonArgs({ enableFfmpegLog }),
      ...(flatMap(clipAudio, ({ path }) => ['-i', path])),
      '-filter_complex',
      filterGraph,
      '-c', 'flac',
      '-y',
      outPath,
    ];
    await execa(ffmpegPath, args);

FFMPEG query structure:

ffmpeg -i /editly-tmp-.../clip000-audio.flac -i /editly-tmp-.../clip226-audio.flac -i ... -filter_complex [0:a][1:a]acrossfade=d=1:c1=tri:c2=tri[concat0],[concat0][2:a]acrossfade=d=0.425:c1=tri:c2=tri[concat1],[concat1][3:a]acrossfade=d=0.425:c1=tri:c2=tri[concat2],... -c flac -y /editly-tmp-.../audio-concat-3.mp3

My hardware:

Ubuntu 24.04 LTS
AMD Ryzen™ 5 5600G
Only 8gb(the other slot is broken)
AMD Radeon™ RX 580 2048SP

Sorry my poor english 😛

Change Codecs, FFMPEG version, node version, slice the files in chunks, change SO(worked in Windows).

New contributor

user25436721 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT