Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First ~2 seconds of audio cut off when encoding audio on Linux #537

Open
BronsonZ opened this issue Aug 14, 2024 · 0 comments
Open

First ~2 seconds of audio cut off when encoding audio on Linux #537

BronsonZ opened this issue Aug 14, 2024 · 0 comments

Comments

@BronsonZ
Copy link

BronsonZ commented Aug 14, 2024

This is mostly a duplicate of #532 but thought it deserved a more thorough write up.

EDIT: A stack overflow post reporting the same behavior: https://stackoverflow.com/questions/78543368/ffmpegcore-net-cuts-off-the-fist-few-1-5-seconds-of-audio

As the title suggests, when I encode a .wav file to a .mp3 on Linux (Ubuntu 22.04 on WSL) using a pipe input with .FromPipeInput() the first couple seconds (~2) of audio is cut off in the resulting mp3. This only appears to happen on Linux, I have not encountered it when running it on Windows. The following code is afflicted, where both inputWavStream and outputMp3Stream are of type MemoryStream:

await FFMpegArguments
    .FromPipeInput(new StreamPipeSource(inputWavStream))
    .OutputToPipe(
        new StreamPipeSink(outputMp3Stream),
        options => options
            .ForceFormat("mp3")
            .WithAudioCodec(AudioCodec.LibMp3Lame)
            .WithAudioBitrate(AudioQuality.Normal))
    .ProcessAsynchronously();

If I set the input to be a file with .FromFileInput(), no audio is cut off, regardless of what the output type is. So it seems the problem is narrowed down to something to do with using input pipes on Linux.

It could be that this is a problem with ffmpeg or libmp3lame on Linux, not necessarily an issue with FFMpegCore.

Also, it's not affected by the length of the input file, a 3 second clip is cut down to 1 second, and a 60 second clip is cut down to 58 seconds.

ffmpeg versions used:

  • Linux: 4.4.2-0ubuntu0.22.04.1 and 6.1
  • Windows: 7.0.2-full_build-www.gyan.dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant