Open bobbydog opened 6 months ago
我想用代码 执行 如下推流命令, 代码需要怎么写? .\ffmpeg -i "rtsp://admin:@192.168.58.89:554/channel=1_stream=0" -pix_fmt yuv420p -vcodec libx264 -an -f flv "rtmp://192.168.99.100:1935/live/stream0"
看完例子还是不太会写, 是一定要从inputContext每帧读取再写到outputContext吗? FFmpegLogger.LogWriter = (level, msg) => Debug.WriteLine(msg);
using FormatContext inFc = FormatContext.OpenInputUrl("rtsp://admin:@192.168.58.89:554/channel=1_stream=0"); inFc.LoadStreamInfo();
MediaStream inVideoStream = inFc.GetVideoStream();
using FormatContext outFc = FormatContext.AllocOutput(formatName: "flv"); IOContext io = IOContext.OpenWrite("rtmp://192.168.99.100:1935/live/stream0"); outFc.Pb = io;
MediaStream videoStream = outFc.NewStream(Codec.FindDecoderByName("h264_cuvid")); videoStream.TimeBase = inVideoStream.RFrameRate.Inverse(); videoStream.SampleAspectRatio = inVideoStream.SampleAspectRatio;
我想用代码 执行 如下推流命令, 代码需要怎么写? .\ffmpeg -i "rtsp://admin:@192.168.58.89:554/channel=1_stream=0" -pix_fmt yuv420p -vcodec libx264 -an -f flv "rtmp://192.168.99.100:1935/live/stream0"
看完例子还是不太会写, 是一定要从inputContext每帧读取再写到outputContext吗? FFmpegLogger.LogWriter = (level, msg) => Debug.WriteLine(msg);
using FormatContext inFc = FormatContext.OpenInputUrl("rtsp://admin:@192.168.58.89:554/channel=1_stream=0"); inFc.LoadStreamInfo();
MediaStream inVideoStream = inFc.GetVideoStream();
using FormatContext outFc = FormatContext.AllocOutput(formatName: "flv"); IOContext io = IOContext.OpenWrite("rtmp://192.168.99.100:1935/live/stream0"); outFc.Pb = io;
MediaStream videoStream = outFc.NewStream(Codec.FindDecoderByName("h264_cuvid")); videoStream.TimeBase = inVideoStream.RFrameRate.Inverse(); videoStream.SampleAspectRatio = inVideoStream.SampleAspectRatio;