hudl / HudlFfmpeg

Hudl.Ffmpeg framework
Apache License 2.0
113 stars 32 forks source link

.MTS files #34

Closed jbraun27 closed 8 years ago

jbraun27 commented 9 years ago

I used the "getting started" documentation to write a simple method to encode a .MTS file to MP4, and it's failing with the exception: Cannot derive resource type from path provided. It appears as though the only files that it will process are those with a Resources class: Mov, MP4, TS, WMV etc. To process any other file format, do you have to create a class for each file type? If so, there are a bunch of types missing, and the list changes frequently. When I added a class for .MTS, I didn't get this error, but instead got this one: "FFmpeg encountered an exception while attempting to render the file." Any suggestions?

Casey-Bateman commented 9 years ago

Yes, currently you need a class for each type of resource that you will be encoding to. We haven't added MTS to our internal list of classes yet, I will be more than happy to get that support in there for you. Which version of Hudl.FFmpeg are you running?

As far as the exception goes, if you inspect the inner exception you should see the ffmpeg output. That should help you debug this further. Would you be willing to paste the code that you are trying to run? It would assist me in helping you debug this further.

jbraun27 commented 9 years ago
    public string Process480p(string videoInPath, string videoInFile, string videoOutPath)
    {
        string ffmpegPath = Path.Combine(GetAppPath(), "FFMpeg.exe");
        string ffprobePath = Path.Combine(GetAppPath(), "FFprobe.exe");
        string OutputPath = videoOutPath;

        ResourceManagement.CommandConfiguration = CommandConfiguration.Create(OutputPath, ffmpegPath, ffprobePath);

        string videoFileIn = Path.Combine(videoInPath, videoInFile);
        string videoOutFileName = Path.GetFileNameWithoutExtension(videoInFile) + "-480p.mp4";
        string videoOutFile = Path.Combine(videoOutPath, videoOutFileName);

        var filterchain = Filterchain.FilterTo<VideoStream>(new Concat());

        var settings = SettingsCollection.ForOutput(
            new CodecVideo("libx264"),
            new BitRateVideo(3000),
            new Size(852, 480),
            new OverwriteOutput()
            );
        var factory = CommandFactory.Create();

        factory.CreateOutputCommand()
            .WithInput<VideoStream>(videoFileIn)
            .Filter(filterchain)
            .MapTo<Mp4>(videoOutFile, settings);

        factory.Render();
        return (videoOutFileName);
    }

    private string GetAppPath()
    {
        string AppPath;
        AppPath = Assembly.GetExecutingAssembly().Location;
        AppPath = Path.GetDirectoryName(AppPath);
        return AppPath;
    }
jbraun27 commented 9 years ago

If I'm not mistaken, you need a class for each type that you will be encoding "from" also, which was my problem. Adding a MTS class got me past the first exception. To answer you other question, I just grabbed the most recent zip file yesterday to give this a try, so I assume it's v3.3?

Casey-Bateman commented 9 years ago

I notice you are trying to use the Concat filter with a single input. This is not needed if you are just transcoding to a new format. Remove the .Filter(filterchain) line and try again and i bet you will be fixed.

jbraun27 commented 9 years ago

I put this away for a while and wrote my own FFmpeg wrapper. It works fine, but then after working with FFmpeg in depth for a few weeks, I think I get where you're going with this. I was trying to format a command to encode to MP4, burn a timecode on the lower left, de-interlace if necessary and trim off x seconds from the end. It started to get messy quick, so I got this back out again.

The example above code comes from the wiki example, but there must be changes since it was written, because I don't see a method for AddCommandAsOutput() in the CommandFactory class. Can you help? I would love to see more examples, sample code, and FFProbe examples as well. Please, more examples!

Also, with the wrapper that I'm using now, I'm able to update a progress bar on the current encoding job. Tracing through the code, it looks like ProcessIt() is capturing output on the running process, but it looks like it's just using that to check for errors. Can you show progress?

Casey-Bateman commented 9 years ago

@jbraun27 good news for you on this front, I am actively working on a progress indication and updates engine for Hudl.FFmpeg. I would imagine having a new release in the next month or so with the update.

simonbuehler commented 8 years ago

it would be great to have some progress Events from the Framework, any news on this?

Casey-Bateman commented 8 years ago

@simonbuehler I have this prototyped in another application, Slated to go in version 4.0 with the .NET Core

Casey-Bateman commented 8 years ago

original issue released version 3.4.0, secondary issue was opened for progress events.