Skip to content

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

Description

@bobbydog

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions