public override void Initialize(MovieRecorder recorder) { m_numVideoFrames = 0; m_config = recorder.gifConfig; fcAPI.fcGifConfig gifconf = fcAPI.fcGifConfig.default_value; gifconf.width = recorder.scratchBuffer.width; gifconf.height = recorder.scratchBuffer.height; gifconf.num_colors = Mathf.Clamp(m_config.numColors, 1, 256); gifconf.max_active_tasks = 0; m_ctx = fcAPI.fcGifCreateContext(ref gifconf); var path = recorder.outputDir.GetFullPath() + "/" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".gif"; m_ostream = fcAPI.fcCreateFileStream(path); fcAPI.fcGifAddOutputStream(m_ctx, m_ostream); }
public override void Initialize(MovieRecorder recorder) { m_config = recorder.mp4Config; fcAPI.fcMP4Config mp4conf = fcAPI.fcMP4Config.default_value; mp4conf = fcAPI.fcMP4Config.default_value; mp4conf.video = m_config.captureVideo; mp4conf.audio = m_config.captureAudio; mp4conf.video_width = recorder.scratchBuffer.width; mp4conf.video_height = recorder.scratchBuffer.height; mp4conf.video_target_framerate = 60; mp4conf.video_target_bitrate = m_config.videoBitrate; mp4conf.audio_target_bitrate = m_config.audioBitrate; mp4conf.audio_sample_rate = AudioSettings.outputSampleRate; mp4conf.audio_num_channels = fcAPI.fcGetNumAudioChannels(); var path = recorder.outputDir.GetFullPath() + "/" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".mp4"; m_ctx = fcAPI.fcMP4OSCreateContext(ref mp4conf, path); }
public override void Initialize(MovieRecorder recorder) { m_config = recorder.webmConfig; fcAPI.fcWebMConfig webmconf = fcAPI.fcWebMConfig.default_value; webmconf = fcAPI.fcWebMConfig.default_value; webmconf.video = m_config.captureVideo; webmconf.audio = m_config.captureAudio; webmconf.video_width = recorder.scratchBuffer.width; webmconf.video_height = recorder.scratchBuffer.height; webmconf.video_target_framerate = 60; webmconf.video_target_bitrate = m_config.videoBitrate; webmconf.audio_target_bitrate = m_config.audioBitrate; webmconf.audio_sample_rate = AudioSettings.outputSampleRate; webmconf.audio_num_channels = fcAPI.fcGetNumAudioChannels(); m_ctx = fcAPI.fcWebMCreateContext(ref webmconf); var path = recorder.outputDir.GetFullPath() + "/" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".webm"; m_ostream = fcAPI.fcCreateFileStream(path); fcAPI.fcWebMAddOutputStream(m_ctx, m_ostream); }
public int Open(EncoderSetup setup) { lock (s_lock) { if (_handle != IntPtr.Zero) { EncoderConfig config = new EncoderConfig(); var res = EncoderContextQsvDx_Open(_handle, Core.StringToBytes(setup.Options), ref setup.EncoderSpec, ref setup.EncoderBitrate, setup.DirectXContext.Device.NativePointer, setup.DirectXContext.CtxNativePointer, ref config.CodecProps); _opened = res >= 0; _currentBitrate = setup.EncoderBitrate; _dx = setup.DirectXContext; config.EncoderProps.pix_fmt = Core.PIX_FMT_INTERNAL_DIRECTX; Config = config; return(res); } else { return((int)ErrorCodes.ContextIsNotOpened); } } }
protected void Page_Load(object sender, EventArgs e) { string filename = ""; List <EncoderConfig> cfgs = Utils.LoadConfig(); EncoderConfig cfg = cfgs[Int32.Parse(Request.QueryString["idProfile"])]; ServiceInterface server = new ServiceInterface(); if (Request.QueryString["idChannel"] != null) { if (server.GetChannel(Int32.Parse(Request.QueryString["idChannel"])).isRadio) { bufferSize = 2560; } WebTvResult res = server.StartTimeShifting(Int32.Parse(Request.QueryString["idChannel"])); if (res.result != 0) { Utils.Log("Streamer.aspx: ERROR: StartTimeShifting failed with error: " + res.result.ToString()); Response.Output.WriteLine("ERROR: StartTimeShifting failed with error: " + res.result.ToString()); Response.End(); return; } usedCard = res.user.idCard; usedChannel = res.user.idChannel; tvServerUsername = res.user.name; if (cfg.inputMethod == TransportMethod.Filename) { filename = res.rtspURL; } else { filename = res.timeshiftFile; } } else if (Request.QueryString["idRecording"] != null) { WebRecording rec = server.GetRecording(Int32.Parse(Request.QueryString["idRecording"])); filename = rec.fileName; } else if (Request.QueryString["idMovie"] != null) { WebMovie movie = server.GetMovie(Int32.Parse(Request.QueryString["idMovie"])); filename = movie.file; } else if (Request.QueryString["idMusicTrack"] != null) { WebMusicTrack track = server.GetMusicTrack(Int32.Parse(Request.QueryString["idMusicTrack"])); filename = track.file; } else if (Request.QueryString["idTvSeries"] != null) { WebSeries series = server.GetTvSeries(Request.QueryString["idTvSeries"]); filename = series.filename; } else if (Request.QueryString["idMovingPicture"] != null) { WebMovingPicture pic = server.GetMovingPicture(Int32.Parse(Request.QueryString["idMovingPicture"])); filename = pic.filename; } if (!File.Exists(filename) && !filename.StartsWith("rtsp://")) { Utils.Log("Streamer.aspx: Requested file " + filename + " does not exist."); return; } Response.Clear(); Response.Buffer = false; Response.BufferOutput = false; Response.AppendHeader("Connection", "Keep-Alive"); Response.ContentType = "video/x-msvideo"; Response.StatusCode = 200; Stream mediaStream = null; EncoderWrapper encoder = null; Stream outStream = null; if (cfg.inputMethod != TransportMethod.Filename) { if (Request.QueryString["idChannel"] != null) { mediaStream = new TsBuffer(filename); } else { mediaStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } encoder = new EncoderWrapper(mediaStream, cfg); } else { encoder = new EncoderWrapper(filename, cfg); } if (cfg.useTranscoding) { outStream = encoder; } else { outStream = mediaStream; } byte[] buffer = new byte[bufferSize]; int read; try { while ((read = outStream.Read(buffer, 0, buffer.Length)) > 0) { try { Response.OutputStream.Write(buffer, 0, read); } catch (Exception) { break; // stream is closed } if (Request.QueryString["idChannel"] != null) { server.SendHeartBeat(usedChannel, usedCard, tvServerUsername); } } } catch (Exception ex) { Utils.Log("Streamer.aspx: Exception raised=" + ex.Message + Environment.NewLine + ex.StackTrace); } if (mediaStream != null) { mediaStream.Close(); } if (Request.QueryString["idChannel"] != null) { server.StopTimeShifting(usedChannel, usedCard, tvServerUsername); } encoder.StopProcess(); Response.End(); }