Closed blackholeearth closed 2 months ago
sorry I don't think your request is a problem for the library. I would try changing the streaming resolution of the camera.
ipcam encoding is: 704x576p, h265 , 10 fps , BRC_CBR , 512kbps , i interval 20 (keyframe, i think?)
İ wanted to do face detection with captured photo. İf i go lower than this it's unusable.
then you have to separate your logic and put the images in a queue first and do the processing in another thread
ipcam is: 704x576p, stream is h265 , 10 fps , BRC_CBR , 512kbps bitsream , i interval 20,(i think this is keyframe)
i did seperate it to different thread via taskRun,
i am cool with constant delay lets say 5 seconds. thats acceptable for me. but that 5 second delay becomes. 40 seconds after the 2 minutes. gets bigger.
here code if you want to see:
CancellationTokenSource last_ct;
private void bt_rtspSTART_Click(object sender, EventArgs e)
{
last_ct?.Cancel();
var rtsp_url = @"rtsp://admin:pass@192.168.1.51:554/cam/realmonitor?channel=1&subtype=1";
var inputSource = new StreamInputSource(rtsp_url);
var cancellationTS = new CancellationTokenSource();
last_ct = cancellationTS;
var client = new VideoStreamClient();
client.NewImageReceived += NewImageReceived;
var task = client.StartFrameReaderAsync(inputSource, OutputImageFormat.Bmp, cancellationTokenSource.Token);
//client.NewImageReceived -= NewImageReceived;
}
/// <summary>
/// to show in picturebox.
/// </summary>
public static Bitmap ByteToImage(byte[] blob)
{
MemoryStream mStream = new MemoryStream();
byte[] pData = blob;
mStream.Write(pData, 0, Convert.ToInt32(pData.Length));
Bitmap bm = new Bitmap(mStream, false);
mStream.Dispose();
return bm;
}
DateTime lastCopied = DateTime.Now;
byte[] last_imageData = null;
private void NewImageReceived(byte[] imageData)
{
if (DateTime.Now.Subtract(lastCopied).TotalMilliseconds < 2_000) // taking photo every to 2second.
return;
lastCopied = DateTime.Now;
last_imageData = imageData;
Task.Run(()=> {
if (last_imageData == null)
return;
var bitmapx = ByteToImage(last_imageData); //90ms on my computer ,debug.
this.Invoke(new Action(() => {
pbx_vidframe.Image = bitmapx;
tbx_tarihsaat.Text = $"DataReceived_TarihSaat: {lastCopied}";
}));
});
//File.WriteAllBytes($@"{DateTime.Now}.bmp", imageData);
}
cant we add custom ffmpeg parameters to fix that.
current default way its unsuable. please help.
please keep the issue open. its not fixed. maybe someone sees and send a pr.
It's definitely not a problem with the library it's a problem with the implementation of it. The way the code from your example processes the data cannot work properly. This GitHub project is also not a free support that fixes your code I hope you can understand that.
However, I can offer you professional support with your problem. I have already given you the correct solution in my previous answer.
the code is copied from readme page ??
that means the same problem happens with the basic example on readme page. when you are writing frame on a disk.??
Thank you for the nice conversation please look for help on stackoverflow or in another forum
tested the test.console app on this repo. same thing happens there. 👀👀
so the problem is not my code.
thanks for ur concern . can close for real this time.
Edit: found some message on console app.
Framerate is not specified . 25fps will be used.
İ know ipcam fps is 10. So i appended " -r 10 " to customstreamsource.
After running code for 60 seconds. delay is 20 sec now.
Halfway there..✨✨
Also At the console app output, i see fps Value is changing between 9.111 - 9.999
This will definitely be solved by finding right flags for ffmpeg .
early observations: tested it for 2 minutes. delay is 2 sec. it looks constant. 👍 tested it for 30 minutes. delay is 2 to 3 sec. it looks constant. 👍
code
var rtsp_url = @"rtsp://admin:pass@192.168.1.12:554/cam/realmonitor?channel=1&subtype=1";
var inputSource = new CustomInputSource($"-flags low_delay -rtsp_transport tcp -i {rtsp_url} -r 4 ");
solution:
set fps in c# code to a lower value than actual ipcam stream
solution - step by step:
1) download and run the test.console app.
2) see if there is fps not detected meesage`in console app: Framerate is not specified . 25fps will be used.
Delay between time on the wallclock vs time on captured frame gets bigger amd bigger each passing second.
can i do frame skip?
or just take 1 photo?
Edit: SOLVED go th the end