nager / nager.videostream Goto Github PK
View Code? Open in Web Editor NEWGet images from a network camera stream or webcam
License: MIT License
Get images from a network camera stream or webcam
License: MIT License
The process of the FFmpeg is not closed automatically
It seems like it continues running.
how can I use it without the exe
in case of docker or linux
Very useful project! thx.
quastion:
In case of user and password in the RTSP string cause problems, for example when the password contains @ char
so the string could not handle that
Can I pass it as an argument?
"rtsp://user:[email protected]...."
"rtsp://root:example@2345@#353@192....."
Hey,
I'm trying to run a dotnet program on Raspberry Pi (running Pi OS) using this package.
I connect a USB camera to the RPi and trying to record a video from it.
It works perfect on windows.
How can I make it work on Linux?
I tried setting the ffmpeg path to the path on the machine and it still not working.
Thanks
I tried to get the images from the NewImageReceived event each X seconds and it looks like there is a bug.
it takes 30 images each time and continues.
I'm using Nager.VideoStream for getting frames from a security camera on a Windows 10 PC with a .NET framework 4.8 application.
When the source is offline/not reachable, it is not possible to stop StartFrameReaderAsync.
Even when you cancel the provided CancellationToken, StartFrameReaderAsync won't stop.
The only way to then stop it, is by closing my entire application.
I reproduced this issue in the Nager.VideoStream.TestConsole by only changing:
var inputSource = new StreamInputSource("my_secret_rtsp_url");
var client = new VideoStreamClient(@"my_secret_folder\ffmpeg.exe");
The console application clearly cancels the cancellation token:
Console.WriteLine("Press any key for stop");
Console.ReadKey();
cancellationTokenSource.Cancel();
Console.WriteLine("Press any key for quit");
Console.ReadKey();
But this console writeline is never executed:
Console.WriteLine("End Stream Processing");
In my application I need to call StartFrameReaderAsync quite frequently.
That means without proper cancellation, multiple StartFrameReaderAsync threads will be active at the same time.
This is a major performance issue for my application when the camera is offline/not reachable.
I see the CPU is high
can this folder work on GPU?
Hi, thanks for sharing your experinces with us . I need guidance on linux deployment. In surce code, tou are checking ffmpeg.exe file as I can see. So i think there should be some modifications. If you guide me to the right points, I can make this work on linux also.
Thank you again.
Running on Windows 10 and .NET framework 4.8
This is how I start the video stream:
stopTokenSource = new CancellationTokenSource();
Client = new VideoStreamClient();
Client.NewImageReceived += Client_NewImageReceived;
var inputSource = new StreamInputSource(streamUrl);
streamReadingTask = Client.StartFrameReaderAsync(inputSource, OutputImageFormat.Bmp, stopTokenSource.Token);
And this is how it is stopped and disposed:
stopTokenSource?.Cancel();
stopTokenSource?.Dispose();
stopTokenSource = null;
if (Client != null)
Client.NewImageReceived -= Client_NewImageReceived;
When closing my application normally, the videostream is stopped and dealt with accordingly.
However, when an unexpected exception occurs and the application crashes, ffmpeg.exe will still be running.
This is causing a lot of issues for me, mainly because the TCP ports used by my application will remain open until ffmpeg.exe is shut down manually through the Task Manager.
The problem can be solved by either:
Need to add custom video source (needed for additional parameters - certain RTSP for example)
I'd be happy to add it
Hello:
I have one video MP4 file (C:\Videos\VLCPlayer\testVideo0.mp4), it has size of 4.2MB.
I want to extract all frames in this video file to one folder: C:\Videos\VideoFrames.
I created one C# console project, target .Net 5.0.
The following is my code:
using Nager.VideoStream;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace NagerVideoStreamFrames
{
class Program
{
public const string Video_MP4_File = @"C:\Videos\VLCPlayer\testVideo0.mp4";
public const string Frame_Folder = @"C:\Videos\VideoFrames";
private static async Task StartStreamProcessingAsync(InputSource inputSource, CancellationToken cancellationToken = default)
{
Console.WriteLine("Start Stream Processing");
var client = new VideoStreamClient();
client.NewImageReceived += NewImageReceived;
await client.StartFrameReaderAsync(inputSource, OutputImageFormat.Png, cancellationToken);
client.NewImageReceived -= NewImageReceived;
Console.WriteLine("End Stream Processing");
}
private static void NewImageReceived(byte[] imageData)
{
Console.WriteLine($"New image received, bytes:{imageData.Length}");
File.WriteAllBytes($@"C:\Videos\VideoFrames\{DateTime.Now.Ticks}.png", imageData);
}
static void Main()
{
var inputSource = new FileInputSource(Video_MP4_File);
var cancellationTokenSource = new CancellationTokenSource();
_ = Task.Run(async () => await StartStreamProcessingAsync(inputSource, cancellationTokenSource.Token));
Console.WriteLine("Press any key for stop");
Console.ReadKey();
cancellationTokenSource.Cancel();
Console.WriteLine("Press any key for quit");
Console.ReadKey();
}
}
}
However, my code did NOT work, and I can’t debug it. There is no output frames in the target folder.
Please advise on how to fix this?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.