Skip to content
New issue

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

请问代码怎样实现摄像头推流的操作? #14

Open
bobbydog opened this issue Mar 8, 2024 · 0 comments
Open

请问代码怎样实现摄像头推流的操作? #14

bobbydog opened this issue Mar 8, 2024 · 0 comments

Comments

@bobbydog
Copy link

bobbydog commented Mar 8, 2024

我想用代码 执行 如下推流命令, 代码需要怎么写?
.\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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant