FFmpeg and DirectSound/XAudio2 in C# - c#

I have been attempting to get this working for a while and am a bit stuck.
I am attempting to be able to play a video in C# using libavcodec outputting to DirectX and either DirectSound or XAudio2. I have managed to get it to play a video, but am stuck on getting it to output sound.
It doesn't help that I have had no experience with either of DirectSound or XAudio2, or that libavcodec has little documentation. I have managed to get the audio codec, but am stuck trying to decode it or output it through DirectSound/XAudio2.
If anyone is able to either point me in the right direction, or just tell me how to do it I would be grateful.

I am currently doing approximately the same thing as you and am also stuck at the same point! All I can tell you for now is, if you haven't found it, there's a good tutorial showing how to do it with SDL at An ffmpeg and SDL Tutorial, using SDL_Audio for audio playback.
I am looking to see how to adapt this for XAudio2 or DirectSound and if I find anything more I'll let you know. Am currently reading through the official XAudio2 documentation at MSDN.
Good luck!

Related

Get system audio stream buffer for visualization

I tried getting the system output device stream buffer using NAudio but I had this problem:
C# Unity 3D NAudio throws NullPointerException while checking for default audio endpoint
The same exact code mentioned in that question works just fine in my windows forms projects(outside Unity).
NAudio would be the perfect solution for me, but it just doesn't want to cooperate with Unity for some reason. So is there any free alternative to NAudio or any other free possible solution for this problem?
I personally have used FMOD to great success, for help on how to integrate into unity you can look at an open source project that utilises it to great effect :) here: https://github.com/OrderOfThePorcupine/ProjectPorcupine.

Extract Frames of Video at Runtime

I can find plenty of methods for extracting all frames of a video when it is not playing. However what I want to achieve is extracting frames at runtime while the video plays. I want to be able to scan the video for qrcodes at runtime, but my blocker is extracting the frames while the video plays.
My platform for building this in is Windows and C#.
Looking for any library or strategy to achieve this. The best idea I have so far is have the video playing and extract and scan frames for each N second that the player progress hits. But there must be something better than that.
Maybe this tutorial made by Microsoft can help you a little bit.
https://msdn.microsoft.com/en-us/windows/uwp/audio-video-camera/get-a-preview-frame
Hope that my answer was helpful for you! :)

Creating audio visualizer using libvlc

I am trying to create a audio wave visualizer using libvlc. Have searched the net thoroughly but was unable to find any help. It would be really great if anyonce can help me out here.
Thanks in advance :)
I think, you can get waveform with the help of Stream to memory module (smem)
https://wiki.videolan.org/Stream_to_memory_(smem)_tutorial/
Have a look at MediaPlayer Class.
MSDN:
http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.aspx
It is a wrapper around Windows Media Player which will let you do in code most of what WMP can do.
If you are using .NET 2.0 you will have to look at Windows Media Player SDK.
In that case, this answer might be helpful for you.

FFPlay interface in C#?

I recently found a way to convert video's through the FFMpeg converter through command line, but ive recently been interested in making a video player! and i heard that VLC player and various other systems use FFPlay, and i dont know anything about it! so i have some main points of interest..
Questions:
What exactly does the ffplay.exe do?
If it allows me to stream videos, how would i create an interface to C# to use that
How would i display the video on a windows forms app.
If one of those is not possible, im welcome to other alternatives.. or even perhaps writing my own. Suggestions welcome! :)
Edit: im looking for possible solutions with a framework requirement of 3 or below, and also would perfer to not make them install anything additional to my program.
I am not expert but based on what I know,
You can perhaps look at DirectShow technology for developing your video player as there are managed lib such as directshow.net available for it.
To my knowledge, FFPlay is GUI on top of FFmpeg libraries - the main part of FFmpeg is audio/video codec library supporting many formats including MPEG-4 implementation.
To use FFmpeg via DirectShow, you need another component known as ffdshow.

C# tutorial for "listening" to the line in device

I know the obvious answer is "try google..." but i have and I either end up with graphics or cmd-line tutorials, so...
Can anyone point I in the direction of a c# tutorial for "listening" to the audio line-in? Or is it straight forward with the right namespace included? Is it even possible without using directx or some such.
I want to detect external audio activity and report it on screen.
Cheers,
This code sample looks like it has everything that you need: VolumeMeter
Presumably you just need to change the code so that instead of rendering the current volume levels you could return a flag indicating whether "something" is going on.
It's using the Managed DirectX library, which is a managed code wrapper for the native DirectX APIs.
You need an external library to do that. These have .NET bindings:
FMOD is widely used in games, and has an opensource license (and a paid one).
BASS Audio Library is another choice. It's a bit more lightweight.
IrrKlang I haven't use this one, but I was told it is worth the money
NAudio I found just now, because I forgot the IrrKlang's name, and had to google for it. This one looks promising.
OR MDX can do this I think.
check out the VoiceRecorder sample application on Codeplex which shows how to do this using NAudio. This Coding4Fun article explains it in more detail.

Categories