Code Monkey home page Code Monkey logo

Comments (4)

josephnhtam avatar josephnhtam commented on May 26, 2024 1

Hi @kasirajansfm

You can do something like this to create a ffmpeg process to convert the rtmp stream into mp4

private static ILiveStreamingServer CreateLiveStreamingServer()
{
    return LiveStreamingServerBuilder.Create()
        .ConfigureRtmpServer(options => options
            .AddTransmuxer()
            .AddFFmpeg(options =>
            {
                options.Name = "mp4-convertor";
                options.FFmpegPath = ExecutableFinder.FindExecutableFromPATH("ffmpeg")!;
                options.FFmpegTransmuxerArguments = "-i {inputPath} -c:v libx264 -c:a aac -preset ultrafast -f mp4 {outputPath}";
                options.OutputPathResolver = (contextIdentifier, streamPath, streamArguments) =>
                {
                    var entryDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!;
                    return Task.FromResult(Path.Combine(entryDirectory, streamPath.Trim('/'), "output.mp4"));
                };
            })
        )
        .ConfigureLogging(options => options.AddConsole())
        .Build();
}

Note: if you can ensure that the input codec is h264+aac, you can skip the transcoding with -i {inputPath} -codec copy -preset ultrafast -f mp4 {outputPath} to save some cpu usage.

from live-streaming-server-net.

kasirajansfm avatar kasirajansfm commented on May 26, 2024

its working. thanks for the response. is there any way to upload the mp4 file to blob as small chunks, like 1 min video.?

from live-streaming-server-net.

josephnhtam avatar josephnhtam commented on May 26, 2024

You can try this instead

private static ILiveStreamingServer CreateLiveStreamingServer()
{
    return LiveStreamingServerBuilder.Create()
        .ConfigureRtmpServer(options => options
            .AddTransmuxer()
            .AddFFmpeg(options =>
            {
                options.Name = "mp4-convertor";
                options.FFmpegPath = ExecutableFinder.FindExecutableFromPATH("ffmpeg")!;
                options.FFmpegTransmuxerArguments = "-i {inputPath} -c:v libx264 -c:a aac -preset ultrafast -segment_time 60 -f segment {outputPath}";
                options.OutputPathResolver = (contextIdentifier, streamPath, streamArguments) =>
                {
                    var entryDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!;
                    return Task.FromResult(Path.Combine(entryDirectory, streamPath.Trim('/'), "output%d.mp4"));
                };
            })
        )
        .ConfigureLogging(options => options.AddConsole())
        .Build();
}

If you want to upload the mp4, you may need to implement ITransmuxerEventHandler and add the uploading logic. The Hls uploader is also implemented on top of ITransmuxerEventHandler.

from live-streaming-server-net.

deepx avatar deepx commented on May 26, 2024

its working. thanks for the response. is there any way to upload the mp4 file to blob as small chunks, like 1 min video.?

You can do a lot of stuff with ffmpg, for example:

ffmpeg -i input.mp4 -c copy -map 0 -segment_time 00:20:00 -f segment output%03d.mp4
or
ffmpeg -i source-file.foo -ss 0 -t 600 first-10-min.m4v

from live-streaming-server-net.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.