Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type SnapConfig =
- {
- programmeId: string
- carrierId: string
- outputSnapPath: string
- outputSnapName: string
- outputSnapTime: string
- }
- module PicturesEh =
- open System.Diagnostics
- open System
- open System.IO
- let GenerateSearchPaths (programmeId: string, carrierId: string) =
- [@"\\somePath\6\"; @"\\somePath\5\"; @"\\somePath\4\"; @"\\somePath\3\"; @"\\somePath\2\";]
- |> List.map(fun path -> System.String.Format("{0}{1}{2}{3}{4}", path
- , programmeId.Substring(0, 6) + "\\"
- , programmeId.Substring(6, 2) + "\\"
- , programmeId.Substring(0, 12) + "\\"
- , carrierId + "_ID180.mp4"))
- let FindFilePath searchPaths =
- searchPaths
- |> List.find(fun searchPath -> System.IO.File.Exists(searchPath))
- let GenerateFFmpegParameters time outputPath filePath =
- System.String.Format("{0}{1}{2}{3}{4}", @"-y -ss ", time, " -i ",
- filePath, @" -s 96x54 -f image2 -vframes 1 "
- + outputPath)
- let RunCommand parameters =
- let processInfo = new ProcessStartInfo(@"C:\test\ffmpeg\bin\ffmpeg.exe", parameters)
- processInfo.UseShellExecute <- false
- processInfo.CreateNoWindow <- true
- processInfo.RedirectStandardOutput <- true
- processInfo.RedirectStandardError <- true
- try
- let proc = System.Diagnostics.Process.Start(processInfo)
- let output = proc.StandardError.ReadToEnd() //writes to standard error not output, why?
- proc.WaitForExit()
- output
- with
- | :? Exception as ex ->
- ""
- let TakeSnap snapConfig =
- GenerateSearchPaths (snapConfig.programmeId, snapConfig.carrierId)
- |> FindFilePath
- |> GenerateFFmpegParameters snapConfig.outputSnapTime (snapConfig.outputSnapPath + snapConfig.outputSnapName)
- |> RunCommand
- |> printfn "output: %s"
- snapConfig.outputSnapPath + snapConfig.outputSnapName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement