Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
EKostan
@EKostan

hello I got a problem with my conversion code when I subscribe OnProgress I got external error

System.FormatException
HResult=0x80131537
Message=String was not recognized as a valid TimeSpan.
Source=System.Private.CoreLib
StackTrace:
at System.Globalization.TimeSpanParse.TimeSpanResult.SetFailure(ParseFailureKind kind, String resourceKey, Object messageArgument, String argumentName)
at System.Globalization.TimeSpanParse.ProcessTerminal_HM(TimeSpanRawInfo& raw, TimeSpanStandardStyles style, TimeSpanResult& result)
at System.Globalization.TimeSpanParse.ProcessTerminalState(TimeSpanRawInfo& raw, TimeSpanStandardStyles style, TimeSpanResult& result)
at System.Globalization.TimeSpanParse.TryParseTimeSpan(ReadOnlySpan`1 input, TimeSpanStandardStyles style, IFormatProvider formatProvider, TimeSpanResult& result)
at Xabe.FFmpeg.FFmpegWrapper.GetDuration(DataReceivedEventArgs e, Regex regex, String args)
at Xabe.FFmpeg.FFmpegWrapper.CalculateTime(DataReceivedEventArgs e, String args, Int32 processId)
at System.Diagnostics.Process.ErrorReadNotifyUser(String data)
at System.Diagnostics.AsyncStreamReader.FlushMessageQueue(Boolean rethrowInNewThread)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Diagnostics.AsyncStreamReader.<>c.<FlushMessageQueue>b__17_0(Object edi)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

This exception was originally thrown at this call stack:
[External Code]

where I can post issue ?
Tomasz Żmuda
@tomaszzmuda
udgupta-stony
@udgupta-stony
Hi Folks, I am looking for a way to save live RTSP camera streams to disk using Xabe.FFmpeg. I would like to know if this is possible to do through this wrapper.
Tomasz Żmuda
@tomaszzmuda
Hey @udgupta-stony
Just create IMediaInfo from that stream (e.g. await FFmpeg.GetMediaInfo(@"rtsp://192.168.1.123:554/")) and operate on it like on local stream.
udgupta-stony
@udgupta-stony
Hi Tomasz, Thanks for the response. The suggested method worked and I can see an output file. But I am facing problem trying to end the recording (since its a continuous stream). I tried the cancellation token method to stop the recording but it yields a corrupted file (doesn't seem like the right way to end the recording). Could you please suggest any other methods possible ?
Tomasz Żmuda
@tomaszzmuda
image.png
Hey, have you tried add -t option or SetDuration?
udgupta-stony
@udgupta-stony
Yes, I have already explored the -t option however I am looking for a trigger option that I can call (like a method on a handler) that could stop the recording when I like. I have a stop button that user can use to stop the recording from UI, hence need the trigger
udgupta-stony
@udgupta-stony
Hi Tomasz, just to confirm, is it possible to stop a stream recording using the cancellationToken.Cancel() ? as per xabe.ffmpeg specification will it result in a valid file or a corrupted one ?
@tomaszzmuda
moorecj
@moorecj
Hi All, I have RTP Packets that I get from an event handler of a WebRTC session. Is there some way I can pass these to Xabe.FFmpeg for recording?
Tomasz Żmuda
@tomaszzmuda
Hey @udgupta-stony
I was searching about solution but as I see only way is to specify time at beginning. If you found how to do that in FFmpeg I can implement that in library
@moorecj Currently in memory processing is not implemented
udgupta-stony
@udgupta-stony
Hi @tomaszzmuda , In FFmpeg we send a ctrl + c command to the terminal in order to stop the recording on a stream. The output is a valid processed file in the directory. I believe you would need some method to send a similar sigint to the background ffmpeg process from the wrapper.
Tomasz Żmuda
@tomaszzmuda
@udgupta-stony do you have any public rtsp stream? I want to do some test but cannot reproduce this issue.
udgupta-stony
@udgupta-stony
Hi @tomaszzmuda you can use the below rtsp streams for testing :
rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen02.stream
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
Tomasz Żmuda
@tomaszzmuda
I created pull request with that:
tomaszzmuda/Xabe.FFmpeg#316
Can you please check if it works in your case?
udgupta-stony
@udgupta-stony
Thanks @tomaszzmuda I will try and let you know
udgupta-stony
@udgupta-stony
Hi @tomaszzmuda I just noticed that the Stop method is not returning any value. Shouldn't it return the object of type IConversionResult that has all the details about the processed recording ?
Tomasz Żmuda
@tomaszzmuda
I will take a look on that. But can you confirm that it works in your case?
udgupta-stony
@udgupta-stony
Hi @tomaszzmuda The new code didn't work.
however, I discovered that passing "q" to the input stream worked for me
After passing "q" to the process's input stream, I wait for the process to end and then return the exit code. The file generated works perfectly
arvindsouza
@arvindsouza

hello, I'm trying to initialize MediaInfo with an rtsp stream, but I keep receiving the message "Invalid file. Cannot load file rtsp://192.168.1.100:554/stream1". I've tested with the following streams as well:

rtsp://freja.hiof.no:1935/rtplive/definst/hessdalen02.stream
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

with the same result

Tomasz Żmuda
@tomaszzmuda
Hey, Can you paste screenshot from your code?
arvindsouza
@arvindsouza
codeScreen.PNG
Tomasz Żmuda
@tomaszzmuda
Can you check this code: var mediaInfo = await FFmpeg.GetMediaInfo("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
Or directly through console: ffprobe rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
arvindsouza
@arvindsouza
I'm getting a null reference exception with that link using await FFmpeg.getMediaInfo
Tomasz Żmuda
@tomaszzmuda
It's very strange because this the same link is used in tests. Does console version work?
arvindsouza
@arvindsouza

Could not find codec parameters for stream 1 (Video: h264, none, 240x160): unspecified pixel format
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, rtsp, from 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov':
Metadata:
title : BigBuckBunny_115k.mov
Duration: 00:09:56.48, start: 0.000000, bitrate: N/A
Stream #0:0: Audio: aac, 12000 Hz, stereo, fltp
Stream #0:1: Video: h264, none, 240x160, 90k tbr, 90k tbn, 180k tbc

this is the console response

Tomasz Żmuda
@tomaszzmuda
Okay... And what version of the ffmpeg do you use? It seems that ffmpeg is a problem
arvindsouza
@arvindsouza
ffmpeg 4.3.1, I found the download link on their website
if you have a link to a working version, could you share it? Or let me know which version is confirmed to be working
Tomasz Żmuda
@tomaszzmuda
Thats version used by me and tests. Maybe you don't have everything compiled? Download version from this link:
https://github.com/tomaszzmuda/Xabe.FFmpeg/releases/download/executables/ffmpeg-4.3.1-win64-shared-lgpl.zip
or release:
https://github.com/tomaszzmuda/Xabe.FFmpeg/releases
( don't know if you use win64)
arvindsouza
@arvindsouza

that works! thank you! Regarding the following method:
IConversionResult conversionResult = await FFmpeg.Conversions.New()
.AddStream(videoStream)
.ExtractEveryNthFrame(1, outputFileNameBuilder)
.Start();

Is there a way to retrieve this image as a bitmap instead of saving it to a folder?

If not, is there a way to overwrite the previously saved image instead of repeatedly writing to a new file?

Tomasz Żmuda
@tomaszzmuda
It depends what do you want to achive. If you want just one frame from that video you can take just one frame and save it to specific file. And later you can override that file.
arvindsouza
@arvindsouza
I want to continuously fetch images from the stream and convert them to bitmaps for the duration of the stream.
arvindsouza
@arvindsouza
Is that something that's possible? I'll also need to do this for multiple rtsp cameras simultaneously
Nikolas
@NapalmRain

Hello everyone! I need help with one question. I have task: get rtsp stream, and record it into file. I get code from documentation:

IMediaInfo mediaInfo = await FFmpeg.GetMediaInfo( url );
IStream videoStream = mediaInfo.VideoStreams.FirstOrDefault()?.SetCodec( VideoCodec.H264 );
IStream audioStream = mediaInfo.AudioStreams.FirstOrDefault()?.SetCodec( AudioCodec.Aac );

FFmpeg.Conversions.New().AddStream( audioStream, videoStream ).SetOutput( outputPath ).Start();

But... i have some errors in it: mediaInfo.VideoStreams don't have method FirstOrDefault, audioStream the same (the same about First() method). and codecs doesn't containt H264

version of xabe.ffmpeg 4.4.0 downloaded from nuget
Nikolas
@NapalmRain
@tomaszzmuda
Tomasz Żmuda
@tomaszzmuda
Hey, have you imported System.Linq namespace?
Nikolas
@NapalmRain

Hey, have you imported System.Linq namespace?

Yup, thank you! This is was my fault. Problem with FirstOrDefault() is disappear, but how i can fix error with codecs?

Tomasz Żmuda
@tomaszzmuda
Can you show full output from FFmpeg? You have it result
var result = await FFmpeg.Conversions.New().AddStream( audioStream, videoStream ).SetOutput( outputPath ).Start();
Nikolas
@NapalmRain

Well, i tryed to get result, but...

IMediaInfo mediaInfo = await FFmpeg.GetMediaInfo( url );

                IStream videoStream = mediaInfo.VideoStreams.FirstOrDefault()?.SetCodec(VideoCodec.h264) ;
                IStream audioStream = mediaInfo.AudioStreams.First()?.SetCodec( AudioCodec.aac );

                var result = await FFmpeg.Conversions.New().AddStream( audioStream, videoStream ).SetOutput( "d:\\out.mp4" ).Start();

FFmpeg.GetMediaInfo( url ); - don't return anything. May be i can see some logs for understanding my problem?
in url variable: rtsp://admin:admin@10.8.0.174:554/ch01/0

Tomasz Żmuda
@tomaszzmuda
Hey,
I'm trying right now to improve a bit working with RTSP but need some more time. If you find few minutes can you please fill this survey? https://docs.google.com/forms/d/1_3BvdpEkywhjWcDpLlve213mRL-eo-p7sGxaf5YJTSU/edit?gxids=7628
I want to make sure we will do something useful :)
vicelikedust
@vicelikedust
@arvindsouza Yes you can! add this to your conversion ".SetOverwriteOutput(true)". By default it is set to add -n to the command send to FFmpeg, setting .SetOverwriteOutput(true) changes it to -y.
Louis Yeoh
@louisyeoh
Hi all, is it possible to add new audio to video while keeping the original video audio? I tried with both AddAudio and Adding 2 streams of audio both are not working