add mp4 output support to the api

pull/702/head
LukePulverenti 12 years ago
parent da89c337a8
commit 867076de61

@ -81,7 +81,7 @@ namespace MediaBrowser.Api.Playback.Progressive
var bytesRead = fsPosition - position; var bytesRead = fsPosition - position;
//Logger.LogInfo("Streamed {0} bytes from file {1}", bytesRead, path); Logger.Info("Streamed {0} bytes from file {1}", bytesRead, path);
if (bytesRead == 0) if (bytesRead == 0)
{ {

@ -1,4 +1,5 @@
using MediaBrowser.Common.IO; using System.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using System; using System;
@ -75,17 +76,25 @@ namespace MediaBrowser.Api.Playback.Progressive
} }
var format = string.Empty; var format = string.Empty;
var keyFrame = string.Empty;
if (string.Equals("wmv2", videoCodec, StringComparison.OrdinalIgnoreCase)) if (string.Equals(Path.GetExtension(outputPath), ".mp4", StringComparison.OrdinalIgnoreCase))
{ {
format = " -f asf "; format = " -f mp4 -movflags frag_keyframe+empty_moov";
var framerate = state.VideoRequest.Framerate ??
state.VideoStream.AverageFrameRate ?? state.VideoStream.RealFrameRate ?? 23.976;
framerate *= 2;
keyFrame = " -g " + Math.Round(framerate);
} }
return string.Format("{0} {1} -i {2}{3} -threads 0 {4} {5}{6} {7}{8} \"{9}\"", return string.Format("{0} {1} -i {2}{3}{4} -threads 0 {5} {6}{7} {8}{9} \"{10}\"",
probeSize, probeSize,
GetFastSeekCommandLineParameter(state.Request), GetFastSeekCommandLineParameter(state.Request),
GetInputArgument(video, state.IsoMount), GetInputArgument(video, state.IsoMount),
GetSlowSeekCommandLineParameter(state.Request), GetSlowSeekCommandLineParameter(state.Request),
keyFrame,
GetMapArgs(state), GetMapArgs(state),
GetVideoArguments(state, videoCodec), GetVideoArguments(state, videoCodec),
graphicalSubtitleParam, graphicalSubtitleParam,
@ -131,6 +140,7 @@ namespace MediaBrowser.Api.Playback.Progressive
} }
else if (IsH264(state.VideoStream)) else if (IsH264(state.VideoStream))
{ {
// FFmpeg will fail to convert and give h264 bitstream malformated error if it isn't used when converting mp4 to transport stream.
args += " -bsf h264_mp4toannexb"; args += " -bsf h264_mp4toannexb";
} }

Loading…
Cancel
Save