-
Notifications
You must be signed in to change notification settings - Fork 247
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
Support Device and Named Pipes URLs as Source #48
Comments
What do you mean with byte[] video? Check the sample app FFME.Sample, it is all in there. |
Yeah, I don't know what @charrsId means either. If he means setting a byte[] as the media container source, I don't think this will be available (at least not soon). What I am planning on supporting later (3.0 maybe?) are dshow devices and named pipes so that the URLs look like device://dshow?video="My WebCam"&audio="My Microphone" or pipe://named_pipe_here |
Thank you for your reply. |
Thank you very much for your hard work on this project! |
yep. This is most likely the first item for the next version, 3.0. Still trying to get a final release of 2.0 |
That's great! Thanks so much! |
…inor fix in input format detection error message. Display Picture Number and Coded Picture number are now longs. Rounding is now done via System.Convert. It is now possible to open devices! see issue #48
* Better rounding and conversion (avoiding casting) * Bitrates are now longs (very high bitrates result in int overflows). * Minor fix in input format detection error message. * Display Picture Number and Coded Picture number are now longs. * Rounding is now done via System.Convert. * It is now possible to open devices! see issue #48
Latest Commit: It is now possible to open devices with URIs like the following:
|
Thanks for implementing this feature! Can you please advise how to do this ffplay example? (#128) |
Try this and let me know the results Media.OnMediaOpening(s, e) =>
{
e.Options.Input["framerate"] = "25";
e.Options.Input["video_size"] = "768x576";
e.Options.Input["pixel_format"] = "yuyv422";
};
Media.Source = new Uri("device://dshow/?video=Osprey-460e Video Device 1C"); |
sorry, I meant the MediaInitializing event, not the mediaopening. Try the MediaInitializing instead (i.e. before opeining the input that is) |
Thanks, it works! I have two more questions:
|
please examine the ffmeg.c code and tell me where list_devices takes effect so I can call the FFmpeg API that way |
Another way I have done this in the past is to use System.Diagnostics.Process to call ffmpeg.exe. You can also use the SWAN library: https://github.com/unosquare/swan#the-processrunner-class |
I confirm that the capture device works! Tested with the Osprey Card. It works exactly as in the above examples. I would like to try to test with a Blackmagic Decklink card. These cards are much prone to precise parameter settings. (This can be seen, for example, from discussions on the Blackmagic forum.) However, the current FFmpeg compilations from ZZeranoe for Windows no longer support the decklink parameter. Do you have archived ffmpeg version older than October 2016? In these builds support for DeckLink yet been compiled. If you have this old build in the archive, I can test it. (At this point I have no idea how complicated it is to make my own compilation ffmpeg and I guess it will not be that easy.) |
Sorry I don't keep older versions of ffmpeg |
@tenisak With this script you could compile your own FFmpeg to your needs (Thats what I did) |
@Mihaylov93 Thank you very much for the tip. There is a pile of parameters that he asks :-) I do not have much experience with it. Do you have a tip please which components are needed to compile? |
@mariodivece Hello Mario, thanks for this great piece of software :) I'm currently trying to use a webcam and it works but FFMediaElement automatically selects the lower resolution. Media.MediaInitializing += (s, e) => How can I achieve the same results in the current release? Thanks a lot. |
update: Media.MediaInitializing += (s, e) => Thanks and keep up the good project! |
Thanks for implementing this feature! Can you please advise how to do this ffplay example? ffplay.exe -f dshow -i video="HP 720p HD Monitor Webcam":audio="Microphone (HP 720p HD Monitor Webcam)" Thanks a lot. |
As in multiple examples above: Media.Source = new Uri("device://dshow/?video=\"HP 720p HD Monitor Webcam\":audio=\"Microphone (HP 720p HD Monitor Webcam)\""); Recommended: e.MediaOptions.IsTimeSyncDisabled = true; |
thank you very much! |
Sorry |
yeah... why would the first one work? I am surprised it's not giving you a compile-time error... Double quotes need to be escaped |
yeah... why would the first one work? |
this web site auto hide "\". |
I see the issue -- the Command Prompt is unescaping the double quotes as they are read as arguments. Media.Source = new Uri("device://dshow/?video=HP 720p HD Monitor Webcam:audio=Microphone (HP 720p HD Monitor Webcam)"); That should work fine. |
Hi |
There are plenty of examples of haw to do things in the sample project provided with the source code. |
Thank you so much for so fast reply! Let's me have a look now. |
Thanks, this is working really great! However I'm not able to select the vcodec via the PrivateOptions. I have a dshow source that supports mjpeg encoding but I always get rawvideo even though I specify mjpeg like this: All the other properties work great, like framerate and video_size. Is there special handling of the vcodec needed? |
vcodec is not a private option var streamIndex = e.Info.Streams.FirstOrDefault(s => s.Value.CodecType == AVMediaType.AVMEDIA_TYPE_VIDEO).Value.StreamIndex;
e.Options.DecoderCodec[streamIndex] = "mjpeg"; |
Thanks for the very quick reply! I tested your code, but I still get rawvideo as the codec of the incoming stream. The DecoderCodec is sent to ffmpeg as the codec main option, not vcodec main option, is that correct? I am able to get the correct codec when using ffmpeg on the command line with the vcodec main option set to mjpeg. BTW, I can trick it to mjpeg through FFME as well, by setting the PrivateOptions for frame rate and resolution combination to a higher number than what can be delivered as uncompressed video (bandwidth wise) but this doesn't seem like a proper solution. |
ffmpeg is a decoder/encoder. Could you provide the full commandline arguments for ffplay.exe instead please? |
I tried with ffplay, but I can't make it choose the codec from the dshow source. I could only show this with ffmpeg command lines. Here is the command I can use to get rawvideo from the source: I then see following input stream info:
If I add the -vcodec mjpeg or -codec:v mjpeg to the command line like this: then I get the expected result, using HW compression from the camera:
It's the same result I'd like to achieve with FFME, so that I can record directly the compressed stream to file (using your TransportStreamRecorder class) at the same time as showing it in the WPF client. If the camera provides rawvideo then the TransportStreamRecorder will copy invalid codec parameters, and also I want to avoid having to compress the stream on CPU for recording to file. Thanks again. |
The problem is that FFME is based off ffplay -- not ffmpeg. FFmpeg does stuff somewhat differently as it is a decoder/encoder application. Without ffplay arguments it's impossible for me to provide help with a workaround. |
Understood. I haven't been able to make the right ffplay command, unfortunately. I can make it interpret the incoming source as mjpeg but the actual stream is not affected and comes in as rawvideo. Thanks anyway for your support. |
You could modify the TransportStreamRecorder and manually specify output parameters... |
Yes, I did experiment with this, and was able to record with my own output parameters. But it's costing too much resources to encode the raw frames. That's why I'm trying to make the dshow device deliver the frames already compressed and just store those to file. |
Hi. I want to ask. Is it normal that for some reason when I use my webcam as output device the video is like 1,5 seconds delayed? |
Related to #420 |
How to get name of available video (or audio) devices? |
I had the same problem,is there a solution? @ssoreide @mariodivece if not set -codec:v,the result: |
how to do?tkx
The text was updated successfully, but these errors were encountered: