生成视频缩略图时,图像自动旋转为横向

时间:2018-07-11 14:50:37

标签: c# video video-thumbnails video-conversion nreco

从c#生成视频缩略图时,当视频处于纵向模式时,该视频缩略图会自动转换为横向模式。

我正在使用 NReco.VideoConverter.FFMpegConverter 库 以下是我的代码段

var firstName, lastName;
if (window.navigator.userAgent.indexOf("MSIE") > 0) {
    // they are using I.E.
    firstName = self.firstName().replace(/\'/g, "%27");
    lastName = self.lastName().replace(/\'/g, "%27");
}
else {
    // every other browser, just set them normally
    firstName = self.firstName();
    lastName = self.lastName();
}
$.getJSON(
    "https://fqdn.to.server:8888/pdqm/endpoint",
    {
       firstName: firstName,
       lastName: lastName
    },
    function (data) { 
        //here is some stuff to do with UI
    }
);

1 个答案:

答案 0 :(得分:0)

ffmpeg(在调用GetVideoThumbnail时内部使用)会根据视频元数据自动旋转视频帧。如果要按原样获取框架,则需要指定-noautorotate选项:

ffMpeg.ConvertMedia(filePath, null, SnippetsVideoThumbUploadPath + guid + ".jpeg", "mjpeg",
  new ConvertSettings() {
    VideoFrameCount = 1,
    Seek = 1,  // this is 3rd param of GetVideoThumbnail
    MaxDuration = 1,
    CustomInputArgs = "-noautorotate"
  });

(此调用等效于“ GetVideoThumbnail”功能,但允许您指定其他任何ffmpeg选项)