Git Product home page Git Product logo

mediatoolkit's People

Contributors

aydinadn avatar blueint32 avatar darkag avatar doublej42 avatar echterago avatar factormystic avatar lutando avatar mzahor avatar nackermann avatar okazakov avatar olivierdagenais avatar olsh avatar randallarms avatar reidarsollid avatar steroberts89 avatar tcgv avatar xmenxwk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mediatoolkit's Issues

When I Change Video Resolution File Unresolved

When I change video resolution succeded saving output path. But i try to run file i get File Unresolved error. And this error get some files.

Code

int fps = Convert.ToInt32(input.Metadata.VideoData.Fps > 30 ? 30 : input.Metadata.VideoData.Fps);
int yHeight = 360;
int orjWidth = Convert.ToInt32(input.Metadata.VideoData.FrameSize.Split('x')[0]);
int orjHeight = Convert.ToInt32(input.Metadata.VideoData.FrameSize.Split('x')[1]);
double yuzde = orjHeight / yHeight;
int height = yHeight;
int width = (int)(orjWidth / yuzde);

MediaToolkit.Options.ConversionOptions o = new MediaToolkit.Options.ConversionOptions
       {
              VideoFps = fps,
              CustomHeight = height,
              CustomWidth = width,
              VideoSize = MediaToolkit.Options.VideoSize.Custom
       };

Access to the path '\MediaToolkit' is denied.

I used this libery file on my MVC Web application and uploaded on Dodaddy.
"Access to the path '\MediaToolkit' is denied." error occour and can't finish converting process.
The converting process is very work when I used at local.
So, somebody help how to fix this error. Thanks all.

Is it possible to run this on shared web hosting

hello

i have integrated the toolkit in my asp .net website. but when i run it on a shared hosting server, it gives me an error.

is it possible to convert files on shared hosting?

thanks
raxit

The specified executable is not a valid application for this OS platform

hi i use iis express and VS 2012 asp mvc
help me.
why at engine.GetMetadata(inputFile) exception error "The specified executable is not a valid application for this OS platform"?
my code

var inputFile = new MediaToolkit.Model.MediaFile { Filename = path };

            using (var engine = new MediaToolkit.Engine())
            {
                engine.GetMetadata(inputFile);
            }
            return inputFile;

webm files as source?

webm source files always produce a "System.FormatException" exception (they work fine fine with ffmpeg console).

Feature request: Raising OnErrorThrownEventArgs instead of an exception when an error occurs in FFmpeg

This is more like an suggestion than an issue:

I would like to be able to handle public Engine.OnError event if an error occurs from FFMpeg.

Currently it is privatly handled in the Engine.FFmpegProcess.ErrorDataReceived but AFAIK it does not notify user about it. Instead, it should invoke the OnError event handler. The user then could log the error and decide if the process should be canceled or ignored.

'ExtensionAttribute' is defined in multiple assemblies

Since Version=1.1.0.1, I'm receiving this warning while compilation

warning CS1685: The predefined type 'ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'MediaToolkit, Version=1.1.0.1, Culture=neutral, PublicKeyToken=null'

My project is Framework 4.5.2

Thumbnail export setting width and height

Hi, I,m suggest thumbnail export function when custom resolution.

follow code :

public class ConversionOptions
{
      ....
        /// <summary>
        ///     Thumbnailwidth when thumbnail width is set
        /// </summary>
        public int? thumbnailWidth { get; set; }

        /// <summary>
        ///     Thumbnailheight when thumbnail height is set
        /// </summary>
        public int? thumbnailHeight { get; set; }
}

and

internal class CommandBuilder
{
     ....
        private static string GetThumbnail(MediaFile inputFile, MediaFile outputFile, ConversionOptions conversionOptions)
        {
            var commandBuilder = new StringBuilder();

            commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0} ", conversionOptions.Seek.GetValueOrDefault(TimeSpan.FromSeconds(1)).TotalSeconds);

            commandBuilder.AppendFormat(" -i \"{0}\" ", inputFile.Filename);
            commandBuilder.AppendFormat(" -vframes {0} ", 1);

                        // here my code :
            if (conversionOptions.thumbnailWidth.HasValue && conversionOptions.thumbnailHeight.HasValue)
                if(conversionOptions.thumbnailWidth.Value > 0 && conversionOptions.thumbnailHeight.Value > 0)
                    commandBuilder.AppendFormat(" -s {0}*{1} ", conversionOptions.thumbnailWidth.Value, conversionOptions.thumbnailHeight.Value);           

            return commandBuilder.AppendFormat(" \"{0}\" ", outputFile.Filename).ToString();
        }
}

thank you.

ffmpeg Video FPS parse exception

Hey there. I recently encountered an error when obtaining video metadata using the mediatoolkit. On occasion I'm getting a 'System.FormatException' (Input string was not in a correct format).

The FPS string ffmpeg is spitting out looks like ',1k tbr, 1k tbn....' (looks invalid; tough to deal with). The regex string doesn't like the string format it's being given. The error is happening around line 127 of RegexEngine.cs.

Thanks for the great project

Not able to see the actual command sent to the FFMpeg

This is more like an enhancment than an issue.

I would like to be able to see the final and actual FFMpeg command with parameters to pinpoint invalid commands and problems

The actual command could be sent to the output and/or read from the progress/completed event parameter.

This is especially important feature if I am not able to see errors from FFMpeg as all tasks are "completed succesfully" (if ever).

I had problem with the Engine.CustomCommand() not knowing what the method adds extra to my command.

Can't convert .AVI files

Actually files with ext .AVI after converting don't have video stream, there is only audio. Maybe it will help you to fix this issue - the parameter "-pix_fmt yuv420p" fixes the problem

nuget

could you update the library on NuGet?

Stream-to-Stream operations

Hello,

Thanks for such a great wrapper.

Is there any way to implement Stream-to-Stream operations? There are some cases where exporting/importing stuff to/from files is overkill.

For example, this could process data directly from request buffer and serves the thumbnail as it generated.

[HttpPut("video")]
public void video(CancellationToken ct) {
    Request.EnableRewind();

    Response.Headers["Content-Type"] = "image/png"; 

    using(var engine = new Engine()) {
        engine.GetThumbnail(Request.Body, Response.Body, ...);
    }
}

ffmpeg AudioBitRate

There is a Special AudiBitRate "ftlp" in ffmpeg.
RegexEngine.cs Line 155: FormatException of EmptyString To Int32

Any Example to use WebCam?

hi all
i wanted to open webcam and get image/video as bitmap using directShow.
i know its possible with ffmpeg
ffmpeg.exe -f dshow -i video="Webcam C110" out.mp4
Above code opens webcam and saves video to mp4 file.

i didn't find example method using MediaToolkit.
does anybody know how to make this happen?

Thanks

HD video splitting is very slow

Splitting process become very slow if there is a HD video file having size around 2 GB.
Convert method takes approx 30 seconds or more for one split of Timespan 15 sec.

Command line argument Support

Hey! First of all let me tell you that I found this wrapper SUPER useful :)

As per the README MaediaToolkit "supports custom FFmpeg command line arguments"
I've been trying to speed up the video (to create a timelapse like one) using this
but I can't find any example of a command line invocation. Having this'd be very useful

c sharp merging audio video

i try to merge a video merg audio
ffmpeg -i video.mp4 -i audio.mp3 -c copy merged_output.mp4
how can i do it with mediatoolkit c#

Converting MP4 to MP3 itunes song length doubled

when converting MP4 to MP3 itunes song length doubled but windows properties are correct. is this a bitrate issue? thoughts?

       `Dim inputFile = New MediaFile(tbOutputFolder.Text + VideoMP4)
        Dim outputFile = New MediaFile(tbOutputFolder.Text + AudioMP3)

        Using engine = New MediaToolkit.Engine()
            engine.Convert(inputFile, outputFile)
        End Using` 

Stop .Convert proccess

Thank you very much, the library is very intuitive and easy to use. Is there a way to kill the process once it has been invoked method (engine) .Convert? I tried with .Dispose but the process continues working in background. Thank You

Update Nuget package

Update Nuget package with last release for correct numbers parsing on different locales.

sample code for cutting doesnt do anything

var inputFile = new MediaFile {Filename = @"C:\Path\To_Video.flv"};
var outputFile = new MediaFile {Filename = @"C:\Path\To_Save_ExtractedVideo.flv"};

using (var engine = new Engine())
{
    engine.GetMetadata(inputFile);

    var options = new ConversionOptions();

    // This example will create a 25 second video, starting from the 
    // 30th second of the original video.
    //// First parameter requests the starting frame to cut the media from.
    //// Second parameter requests how long to cut the video.
    options.CutMedia(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(25));

    engine.Convert(inputFile, outputFile, options);
}

Engine.Dispose() does not end or kill FFMpeg process

The Engine.Dispose() should end or kill the FFMpeg process.

Currently if I close the application by stopping the debugger in the VS the FFMpeg process keeps running. Opening the application and starting a new task will create another FFMPeg process.

Okay maybe it did not had a chance to dispose the Engine but running the program again should kill the previous priocess:

    private void EnsureFFmpegIsNotUsed()
    {
      if (!Document.IsLocked(this.FFmpegFilePath))
        return;
      try
      {
        this.Mutex.WaitOne();
        EngineBase.KillFFmpegProcesses();
      }
      finally
      {
        this.Mutex.ReleaseMutex();
      }
    }

What if the "Document" is not locked? Then it just create a new instance of the FFMpeg.

I having problem when cut the video

Hi,

I'm trying to cut media files, especially ts extension media files.

But there is a problem, when I use the example code sample with 30 and 25 parameters there isn' t any problem, when I change parameters; for example, first parameter 120 and second one is 100 parameters, in this case it create output file with wrong start and end time.

Especially this problem occruing when I write first parameter greater than 55-59

Thank you.

Not able to cancel currently running long task

Suggestion:

I would like to be able to cancel currently running task.

Conversions and video file processing could take a long time and in that case it is crusial to be able to cancel current task by a click of a button.

Stop and pause.

Any way to stop or pause the encode proccess an resume later.

Thumbnail from video with wrong orientation

Hello,
when i make thumbnail from video (made by Android or IPhone) in portrait orientation, thumbnail is rotated by 90 degrees.
Is there any posybility to take thumbnail in orientation of video?

Not Thread Safe?

Great, Simple, Library. Much appreciated for all your work.

So, I'm not sure this is properly thread safe since, in the constructor for Engine object, it kills any running processes of ffmpeg. If you're currently running a transcoding process and you initiate another instance of Engine in a separate thread, it will kill any existing processes.

Am I missing something?

Setting VideoFps in ConversionOptions does nothing

Hey , i am trying to reduce fps of a video with this code :

    var conversionOpt = new ConversionOptions
    {
        VideoSize = VideoSize.Qvga,
        VideoFps = 2,
    };

     engine.Convert(videoIn, videoOut, conversionOpt);

Changing VideoFps does not not affect the video .

MP4 to MP3 Converting

Can I convert mp3 to mp4? If possible, would you disclose it with a small sample?

Is there a way to get thumbnail of swf?

Hello,
I notice swf is not in your supported formats - but it is supported by ffmpeg.

I wonder if there is a way to use this to get a thumbnail from swf?

Thanks for your help

In memory conversion

Simple suggestion, could it be possible to expose some methods to convert audio files with MemoryStreams or byte arrays ?

Convert without re-encoding?

Great work on the library, thank you.

How can I convert without re-encoding? (similar to ffmpeg console " -vcodec copy -acodec copy")

Don't check that input file exists

Here: https://github.com/AydinAdn/MediaToolkit/blob/master/MediaToolkit%20src/MediaToolkit/Engine.cs#L126

Howebver, ffmpeg supports wildcards, so the input string may not represent 1 file. You could get clever and skip the file exists check if /%[^%]/ or something, but why bother? Just let ffmpeg tell you there was a problem..

But unfortunately, exit code 1, which would inform that, gets treated equal to success, here: https://github.com/AydinAdn/MediaToolkit/blob/master/MediaToolkit%20src/MediaToolkit/Engine.cs#L297

Why not let error code 1 throw an exception?

Access is denied

Hi,

I started to use your library in and it looks great
only one question,
on production the engine create the file "ffmpeg.exe" in "'C:\Windows\TEMP\MediaToolkit", and from security reasons that could be a problem
is there a way to define a specific directory for this file ?

I also tried to copy "ffmpeg.exe" to bin directory, but it didn't work

Engine.CustomCommand() will execute for the second time using same instance

Suggestion for improvement:

As an user I want to be able to formalise a full FFMpeg command and expect the method to accept everything as it is without adding any additional parameter or conversion.

2nd suggestion:

As an user I would expect the Engine.CustomCommand() to be executed right away or to be added to the task queue for later execution.

It all started when I wanted to cut and merge my video without re-encoding. I have the following commands what I know work well:

ffmpeg -ss 30 -t 60 -i D:\VideoCutting\Sample.avi -c copy -avoid_negative_ts make_zero -fflags +genpts D:\VideoCutting\Segment1.ts
ffmpeg -ss 3600 -t 60 -i D:\VideoCutting\Sample.avi -c copy -avoid_negative_ts make_zero -fflags +genpts D:\VideoCutting\Segment2.ts
ffmpeg -i "concat:D:\VideoCutting\Segment1.ts|D:\VideoCutting\Segment2.ts" -c copy -flags +global_header -fflags +genpts D:\VideoCutting\Merged.mp4

Converted them into two separate CustomCommand. I learned the following:

  • I had to remote the 'ffmpeg' at the start. Fine with that.
  • The CustomCommand is not executed right away.
  • Had to call the Engine.Convert() method.
  • The Engine.Convert() method did something which took so long time I had to kill the FFMPeg process from the Task Manager.
  • The Engine.CustomCommand() and Engine.Convert() did something to my commands which caused the video to be re-encoded. I was NOT able to execute my commands as they were to avoid the fr34king re-encoding the 6GB file!
  • I was not able to batch the custom commands for "conversion".
  • I was not able to cancel currently running task.
  • The Engine.Dispose() did not end or kill the FFMpeg background task!

Did I misunderstood or do something wrong? I apologise if I did.

Licensing Query

Having a great time learning more about Media Toolkit! Nice work!

I did have a question regarding the licensing of this library and packaging. The FFMPEG licensing checklist (https://www.ffmpeg.org/legal.html) specifies that the GPL libraries shouldn't be compiled if building a version under the LGPL. But the ffmpeg source readme has the following: "This FFmpeg build was configured with:
--enable-gpl"

There were some other stipulations from the FFMPEG checklist, of course, but does the Media Toolkit library work around this somehow? Software licensing has been kinda an odd thing to me to wrap my head around. Any explanation would be most helpful.

Thank you.

PS

Not sure how many would find this useful but I've found the following helpful in simplifying software licensing: https://tldrlegal.com/

MediaToolKit folder containing ffmpeg, not on application folder

Hi, just one question. why the folder MediaToolkit was not leave on Application StartUp path.
This is my sample code:

Dim engine As MediaToolkit.Engine
engine = New MediaToolkit.Engine
 Dim file As New MediaToolkit.Model.MediaFile
 file.Filename = "D:\Utils\big_buck_bunny_1080p_surround.mov"
 engine.GetMetadata(file)

When i'm use it a folder MediaToolkit was created on my D: drive within it, ffmpeg.

Thanks for your work.

Regards.
Romain.

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.