Access WPF MediaElement Sound Stream form NAudio - naudio

I am new to using NAudio so sorry if my question sounds naive.
My project is to play a video file using WPF MediaElement control then access the audio stream of the played video (using NAudio) to represent the audio track of the video while being played (waveform, etc.).
I looked into how to let the NAudio access the audio track of a video file in MediaElement control but could not find a resource..
Any suggestion will be appreciated

If you are willing to try the preview release of NAudio 1.7 (available on NuGet) it can now read soundtracks out of video files using Media Foundation. Use the MediaFoundationReader class. Here's how you would save the soundtrack to a WAV file:
using (var reader = new MediaFoundationReader("mymovie.m4v"))
{
WaveFileWriter.CreateWaveFile(reader, "soundtrack.wav");
}
Obviously for waveform drawing you would not need to make a WAV file. Just look at the sample values to get peaks for a waveform renderer.
Note that Media Foundation is only supported on Windows Vista and above.

Related

how to listen to markers/cue points on videos

I would like to ask if it is possible for visual studio (c#), to listen to markers/cue points embedded into video files (flv or Mpeg4)?
Currently, I'm playing flv video using the QuartzTypeLib dll. I am able to play the video successfully. Is it possible for c# to observe a marker on the video so that I can trigger an event if that marker is reached?
Thank you very much.

recording a remote webrtc stream with RecordRTC

I am using Opentok JavaScript WebRTC library to host a 1-to-1 video chat (peer-to-peer).
I can see my peer's video and hear the audio flawlessly.
My wish is to record audio / video of other chat party (remote). For this purpose, I'm using RecordRTC.
I was able to record the video of other chat participant (video is outputted to HTML video element), but, so far, I have not succeeded in recording audio (a dead-silence .wav file is as far as I could get). Using Chrome Canary (30.0.1554.0). This is my method:
var clientVideo = $('#peerdiv video')[0];//peer's video (html element)
var serverVideo = $('#myselfdiv video')[0];//my video (html element)
var context = new webkitAudioContext();
var clientStream = context.createMediaStreamSource(clientVideo.webRTCStream);
var serverStream = context.createMediaStreamSource(serverVideo.webRTCStream);
webRTCStream is a custom property i assigned to HTMLVideoElement object by modifying source of opentok js library. It contains MediaStream object linked to respective < video > element.
var recorder = RecordRTC({
video: clientVideo,
stream: clientStream
});
recorder.recordAudio();
recorder.recordVideo();
Video is recorded. Audio file is also created, it has a length that is close to video's length, however, it's completely silent (and yes, there was a lot of noise making on the other side during recording)
I've tested this with video element which displays my webcam's video stream (and audio), and it worked: both audio and video were recorded:
...
var recorder = RecordRTC({
video: serverVideo,
stream: serverStream
});
...
Is there something special about streams originating from a remote location? Any guidance on this issue would be very helpful.
This is the same issue occurs in following situations...
If not a stereo audio (dual channel audio)...i.e. it is mono audio
If audio input channels are not equal to audio output channels
If audio input device is not the default device selected on chrome
I'm still trying to find the actual issue.
I added this experiment for testing purpose... see console...
https://webrtc-experiment.appspot.com/demos/remote-stream-recording.html
Updated at: Saturday, 1 February 2014, 09:22:04 PKT
Remote audio recording is not supported; and this issue is considered as low-priority wontfix:
Support feeding remote WebRTC MediaStreamTrack output to WebAudio
Connect WebRTC MediaStreamTrack output to Web Audio API
Updated at March 28, 2016
Remote audio+video recording is now supported in RecordRTC, since Chrome version 49+.
Firefox, on the other hand, can merely record remote-audio.
If Chrome/WebRTC/Opus outputs mono audio by default and if that is the problem here, I see two options in that case:
By making opus output stereo - not sure how.
By making the RecordRTC/Recorderjs code work with mono
Or does anyone know any other recording library that works?
This actually now works fine in Firefox. I am using FireFox 29.0.1 and the AudioAPI can now work with audio streams sources grabbed from remote parties from a peer connection.
To test go to Muaz Khan's experiment page. I am not sure with what version of Firefox this rolled out but I would like to thank the team for cranking it out!
The chrome bug was moved to the AudioAPI team cr bug to track progress

Code to play AVI file in xcode

I am creating an iPhone application, which can play many media formats. I am not able to play AVI file format, where as I am able to play other formats (for e.g. MP3, MP4, MOV etc). When I try to play AVI, it shows black screen and display is hidden. Any suggestions on what I can do to fix this issue?
Take a look at this tutorial on playing video with ffmpeg and SDL, both available for the iPhone.
An ffmpeg and SDL Tutorial or How to Write a Video Player in Less Than 1000 Lines
It's written in C, but consider it pseudocode, and adapt it in Objective C accordingly.
.avi is a container format, not a specific audio/video codec. Depending on the contents of the .avi container, it may or may not be possible to decode the video on an iOS device (due to hardware limitations). If it is possible to decode the video in real time, you may have some luck using the libav (aka ffmpeg) library to decode it.

Can I play flash video file on iPad?

I want to make simple project which play flash video file from online.
I've searched some articles and read carefully.
But I can't understand, how to play flash video files on iPad by Code.
So I need help from you.
Please.
Simply put, without being jailbroken, No you cannot.
The closest thing to being able to view flash in iOS is Frash, and I am not even sure if it is actively being developed or supported any more.
You can always check out the open source project for Frash. by Comex.
All IOS devices don´t support Flash player, but is be possible to use a Javascript or HTML5 player for video.
No, iWhatever's currently do not and to the best of my surfing knowledge, have no intention of supporting flash format due to some argument between apple and adobe.
At the end of the day, the Flash video format is a container for a movie that’s been compressed by some codec. If you can get to the source file, you know the format of the container, you know the codec that was used to encode the video, and you know how to write code to convert that into audio streams and video frames, then yes, you can play Flash videos on the iPad.
So, to recap:
Get the Flash video file.
Get to the encoded video data in the Flash file.
Decode the video and convert it, either into raw audio and video or to another format that the iPad can play.
Play the result of #3.
Needless to say, this is quite the endeavor. It’s better to download the movies to your desktop and convert them there before loading them into your application.
Yes you can! The question is whether or not you can play the video itself not whether or not ipads support flash player.
the answer is this.. new versions of "flash video" have a f4v file extension. These videos are basically a h.264 mp4 files. You "may" be able to play it in an ipad simply by renaming it to .mp4
If that doesn't work then use a utility like Miro to convert your "flash video" to a format that your ipad will accept. http://www.mirovideoconverter.com/

Any possibility to add subtitl in AxWindowsMediaPlayer control?

I am using axWindowsMediaPlayer control in my windows mobile application with using .net CF 2.0,
I want to play the video with subtitle.(SRT file type)
Any one know how to add the SRT file in AxWindowMediaPlaye ,It is possible ?
Pl. give me some suggestions
Thank you in advance.
Yes, write or find a DirectShow filter that displays the subtitle. You can also write your own player.
For ASF playback (e.g. wmv, wma) on PC you need to add a script stream to the file. Not sure if the mobile version of WMP supports captioning.
As I know the Windows Media Player doesn't suuport the SubRip SRT-Files, but the smi (SAMI-Files, closed captions). I use the smi-file to show the multi-language subtitles. You can covert very easy your srt to the smi, or create your own smi subtitles, using a free "Subtitle Workshop" tool.
You can also add another language to the smi, here is some samples: Captioning for Windows Media.
You can also change the language of the subtitles using the closedCaption properties, like
AxWindowsMediaPlayer.closedCaption.SAMILang = "German";
or set the smi-file direclty
AxWindowsMediaPlayer.closedCaption.SAMIFileName = "subtitles.smi";