如何裁切ASP.NET + C#中的MP3? [英] How to crop a mp3 in ASP.NET + C#?

查看:148
本文介绍了如何裁切ASP.NET + C#中的MP3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用C#ASP.NET项目。用户可以上传自己的MP3(我有在编码没有控制),并指定一个样本量和样本的起点。保存时系统需要创建一个基于提供的信息,这款MP3的样本。

I am in an ASP.NET project using C#. The users can upload their MP3 (I have no control over the encoding) and specify a sample size and a sample starting point. On save, the system needs to create a sample of this MP3 based on the information provided.

所以,问题是:在ASP.NET + C#如何Icrop一个MP3 ??

So the question is: How can Icrop a mp3 in ASP.NET + C#??

推荐答案

虽然你可能使用.NET的音频库要做到这一点,我觉得这样做最简单的方法是运行像的 FFmpeg的 或的 的MPlayer 来为你做裁剪,然后发送文件背下来就行了。

While you could possibly use a .NET audio library to do this, I think the easiest way to do this would be to run a command like FFMpeg or MPlayer to do the cropping for you, then send the file back down the line.

例如,与FFmpeg的,你可以做这样的事情(从的这里作物达90秒):

For example, with FFMpeg, you can do something like this (from here crops up to the 90th second):


ffmpeg -ss 90 -i input.mp3 output.mp3

要启动FFmpeg的,使用这样的:

To start FFMpeg, use something like this:

System.Diagnostics.Process p = new System.Diagnostics.Process();
Response.Write("Cutting MP3...");
Response.Flush();
p.StartInfo = new System.Diagnostics.ProcessStartInfo("ffmpeg.exe", "-s 90 -i " + inputFile + " " + outputFile);
p.Start();
p.WaitForExit();
Response.Write("Done");

唯一的问题是,它需要相当一段时间,很难汇报进展返回给用户。

The only problem is that it takes quite a while and it's hard to report progress back to the user.

这篇关于如何裁切ASP.NET + C#中的MP3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆