question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with sending voice through ffmpeg(spamming Sent Speaking)

See original GitHub issue

Im sending audio using ffmpeg(ffmpeg version N-93129-g9e1e521393) and Discord.Net(Discord.Net 2.0.2-dev-01059). I’m sending audio from local .mp3 using ffmpeg with methods like below. When i’m sending first time from connection to voice channel - it is all ok. For the next times bot spamming Sent Speaking and his “circle” in discord is blinking.

private Process CreateStream(string path)
{
	return Process.Start(new ProcessStartInfo
	{
		FileName = "ffmpeg",
		Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1",
		UseShellExecute = false,
		RedirectStandardOutput = true,
	});
}
using (var ffmpeg = CreateStream(path))
using (var output = ffmpeg.StandardOutput.BaseStream)
using (var discord = AudioClient.CreatePCMStream(AudioApplication.Mixed))
{
	try
	{
		IsSending = true;
		await AudioClient.SetSpeakingAsync(true);//just try to fix
		await output.CopyToAsync(discord, _token);//_token to stop sending audio
		return true;
	}
	catch (OperationCanceledException)
	{
		return true;
	}
	finally
	{
		await discord.FlushAsync();
		await AudioClient.SetSpeakingAsync(false);//just try to fix
		IsSending = false;
	}
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
alovegitcommented, Mar 18, 2019

I have this issue as well. To work around it, I had to create the PCM stream once and re-use it every time. That’s the only solution I’ve found until this gets resolved.

0reactions
jinwoo-lee-githubcommented, Mar 18, 2022

still have problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reduce background noise and optimize the speech from ...
Reduce background noise and optimize the speech from an audio clip using ffmpeg ... I extract audio clips from a video file for...
Read more >
In Praise of FFmpeg - Slashdot
It took a complex problem and solved it, with free software. The book is now closed on multimedia: ffmpeg is the solution to...
Read more >
Optimize audio files for Speech-to-Text
Play audio and video files using FFMPEG. Extract, transcode, and convert audio file properties using FFMPEG. Run Speech-to-Text on a variety of sample...
Read more >
20+ FFmpeg Commands For Beginners
This guide lists the most commonly and frequently used 20+ ffmpeg commands. These commands are just enough to getting started with FFmpeg.
Read more >
javascript - How to Play Audio File Into Channel?
Have Discord.js installed in VS. From there the steps are quite simple. After making your project index.js you will start typing some code ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found