How to convert the downloaded video and get a screenshot from this file?

I create cms and want users to be able to upload videos, but I am not familiar with downloading and converting videos. Is there an example or has someone encoded such a solution? I heard about ffmpeg, but I don't know how to integrate it with asp.net.

As a simple solution, I can get my clients to upload FLV files, but then I still need to take a snapshot of this fvl.

thanks

+4
source share
3 answers

Answering machine question:

Is ffmpeg server installation required or just exe enough?

ffmpeg.exe will be enough, installation is not required.

Below is a screenshot of the captureTime for the video specified by the videoFilename variable and saves it in the imageFilename path.

 Process ffmpeg = new Process(); ffmpeg.EnableRaisingEvents = true; ffmpeg.StartInfo = new ProcessStartInfo { FileName = this.ffmpegPath, Arguments = string.Format( "-i \"{0}\" -an -y -s 320x240 -ss {1} -vframes 1 -f image2 \"{2}\"", this.videoFilename, DateTime.MinValue.Add(this.captureTime).ToString("HH:mm:ss:ff", CultureInfo.InvariantCulture), this.imageFilename ), WorkingDirectory = this.workingDirectory, UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true, WindowStyle = ProcessWindowStyle.Hidden }; ffmpeg.Start(); ffmpeg.WaitForExit(this.timeout); 
+4
source

I used ffmpeg, but it was easier for me to just use the pre-compiled version of .exe. Therefore, in the backend, I just ran ffmpeg.exe with the necessary command line arguments to perform the conversion, let it run, and when it is finished, the completed file will be ready to work.

+2
source

Once upon a time, in my days of PHP4, I used the following method, calling ffmpeg on the shell and creating a screenshot.

 /** * Create a snapshot of a videofile and save it in jpeg format */ function snapshot($sourcefile,$destfile,$width=184,$height=138,$time=1){ $width=floor(($width)/2)*2; $height=floor(($height)/2)*2; exec("ffmpeg -i {$sourcefile} -s {$width}x{$height} -t 0.0001 -ss {$time} -f mjpeg {$destfile}"); } 

A supported video file is required as $ sourcefile. The desired file location for the screenshot can be set with the $ destfile parameter. Out of the course, make sure that this place can be recorded for the performing user.

Hope this can also be used for anyone looking for the right syntax.

0
source

Source: https://habr.com/ru/post/1300722/


All Articles