Comments (4)
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.
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.
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.
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)
- Minimize delay on displaying local RTMP-Stream HOT 1
- How to use it ? HOT 6
- Authentication Sample HOT 2
- Upload the files to Azure Blob HOT 7
- HTTP-FLV not working without audio HOT 3
- Running On Docker HOT 1
- Delay on Streaming HOT 2
- Excessive use of IServiceProvider HOT 2
- Can not preview on Safari HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from live-streaming-server-net.