We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
请问如何把图片连续帧转成视频推流出去,完全不知道要怎么弄
The text was updated successfully, but these errors were encountered:
我用如下代码已实现推流,但是仍有几个问题 1、无法推送rtsp的流,提示Protocol not found 协议不存在 2、推出去的流使用vlc播放时播放读秒每次增加3-4秒,画面也不更新
private static void MakeMp4(Codec codec, int width, int height, int frameCount = 30)
{ using FormatContext infc = FormatContext.OpenInputUrl("rtsp://admin:[email protected]"); infc.LoadStreamInfo(); MediaStream videoStream = infc.GetVideoStream(); using CodecContext videoDecoder = new(Codec.FindDecoderById(videoStream.Codecpar!.CodecId)); videoDecoder.FillParameters(videoStream.Codecpar!); videoDecoder.Open(); using FormatContext fc = FormatContext.AllocOutput(formatName: "flv"); fc.VideoCodec = codec; MediaStream vstream = fc.NewStream(fc.VideoCodec); using CodecContext vcodec = new CodecContext(fc.VideoCodec) { Width = width, Height = height, TimeBase = new AVRational(1, 1000), PixelFormat = AVPixelFormat.Yuv420p, Flags = AV_CODEC_FLAG.GlobalHeader, }; vcodec.Open(fc.VideoCodec, new MediaDictionary { ["preset"] = "ultrafast" }); vstream.Codecpar!.CopyFrom(vcodec); using IOContext io = IOContext.OpenWrite("rtmp://127.0.0.1:1935/live/1"); fc.Pb = io; fc.WriteHeader(); foreach (Packet packet in infc.ReadPackets(videoStream.Index)) { try { packet.RescaleTimestamp(vcodec.TimeBase, vstream.TimeBase); packet.StreamIndex = vstream.Index; fc.InterleavedWritePacket(packet); } finally { packet.Unref(); } } fc.WriteTrailer(); }
Sorry, something went wrong.
No branches or pull requests
请问如何把图片连续帧转成视频推流出去,完全不知道要怎么弄
The text was updated successfully, but these errors were encountered: