I'm seeing an inconsistent (difficult to reproduce) crash while encoding audio that prints out the following error.
FFmpegException "Error while writing audio frame : Invalid argument"
This error seems to come from Codec.FFmpeg.Encode.hsc, just before a call to av_interleaved_write_frame.
This is in a program based off the audio demo that takes multiple filenames on the command-line and writes one after another into the same resampler (frame by frame, draining the resampler into the audioWriter after each frame). The program is used in a multithreaded context, but all the FFmpeg code is in this one "cat audio files" function. I have turned on debug logging and found the crash is sometimes preceded by this line:
[ipod @ 0x25ffb00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 19456 >= 18434
While it's possible the input data is invalid, these lines aren't consistently printed before a crash, and so it's not conclusive.
Based on google searches about av_interleaved_write_frame giving the error "invalid argument" I've tried certain mitigations:
One page mentioned this in the context of multithreading, and suggested mutex. I tried removing the -threaded compiler option and wrapping all FFmpeg code with a withMVar/MVar () based mutex. This hasn't eliminated the error.
Another page suggested that you check the layout/rate/format of each audio frame you read, before writing it to a resampler, to ensure the parameters match what the resampler expects. I've implemented this, but it hasn't eliminated the error.
I'll post the audio-cat function later if there's interest.
Closing this because the bug is not consistently reproducible. I've migrated to using System.Process and just calling the ffmpeg executable. Still using ffmpeg-light for other things though! Thank you :)
I'm seeing an inconsistent (difficult to reproduce) crash while encoding audio that prints out the following error.
This error seems to come from Codec.FFmpeg.Encode.hsc, just before a call to
av_interleaved_write_frame
.This is in a program based off the audio demo that takes multiple filenames on the command-line and writes one after another into the same resampler (frame by frame, draining the resampler into the audioWriter after each frame). The program is used in a multithreaded context, but all the FFmpeg code is in this one "cat audio files" function. I have turned on debug logging and found the crash is sometimes preceded by this line:
Or by this one:
While it's possible the input data is invalid, these lines aren't consistently printed before a crash, and so it's not conclusive.
Based on google searches about
av_interleaved_write_frame
giving the error "invalid argument" I've tried certain mitigations:-threaded
compiler option and wrapping all FFmpeg code with awithMVar
/MVar ()
based mutex. This hasn't eliminated the error.I'll post the audio-cat function later if there's interest.