private Audio() : base(EffectType.Audio) { try { _cFile = null; ePlaybackMode = ffmpeg.net.File.Input.PlaybackMode.RealTime; } catch { Fail(); throw; } }
public Audio(XmlNode cXmlNode) : this() { try { LoadXML(cXmlNode); ePlaybackMode = cXmlNode.AttributeOrDefaultGet <ffmpeg.net.File.Input.PlaybackMode>("playback_mode", ffmpeg.net.File.Input.PlaybackMode.RealTime); Init(cXmlNode.AttributeValueGet("file")); } catch { Fail(); throw; } }
public void Open(MergingMethod stMergingMethod, ffmpeg.net.File.Input.PlaybackMode ePlaybackMode) { // TODO нужно выцеплять размеры кадра из видео. _bClosed = false; if (null == _cFile) { _cFile = new ffmpeg.net.File.Input(_sFile, nFrameStart); } (new Logger()).WriteDebug("[video_file open " + GetHashCode() + "][ffmpeg_file " + _cFile.GetHashCode() + "]"); //Area stDeviceArea = Baetylus.Helper.stCurrentBTLArea; _cFormatVideo = new ffmpeg.net.Format.Video(stArea.nWidth, stArea.nHeight, ffmpeg.net.PixelFormat.AV_PIX_FMT_BGRA, ffmpeg.net.AVFieldOrder.AV_FIELD_TT); short nTop = stArea.nTop; ushort nHei = stArea.nHeight; if (stArea.nTop < 0) // если верх выше границы, то не будем копировать лишние строки в пиксельсмэп { nTop = 0; } if (nTop < stContainerArea.nHeight && stArea.nHeight + stArea.nTop > stContainerArea.nHeight) // если низ ниже, то не будем копировать лишние строки в пиксельсмэп { nHei = (ushort)(stContainerArea.nHeight - (ushort)nTop); } stPixelArea = new Area(stArea.nLeft, nTop, stArea.nWidth, nHei); _cPMDuo = new PixelsMap.Triple(stMergingMethod, stPixelArea, PixelsMap.Format.BGRA32, true, Baetylus.PixelsMapDispose); ffmpeg.net.AVSampleFormat eAVSampleFormat; switch (Preferences.nAudioBitDepth) { case 32: eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S32; break; case 16: default: eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S16; break; } int nAudioChannelsQty = Preferences.nAudioChannelsQtyFfmpeg; _cFormatAudio = new ffmpeg.net.Format.Audio((int)Preferences.nAudioSamplesRate, nAudioChannelsQty, eAVSampleFormat); nFramesTotal = _cFile.nFramesQty; //_cFile.Prepare(nDuration); _cFile.Prepare(_cFormatVideo, _cFormatAudio, ePlaybackMode); }
public Video(XmlNode cXmlNode) : this() { try { ePlaybackMode = cXmlNode.AttributeOrDefaultGet <ffmpeg.net.File.Input.PlaybackMode>("pb_mode", ffmpeg.net.File.Input.PlaybackMode.RealTime); string sFile = cXmlNode.AttributeValueGet("file"); Init(sFile); LoadXML(cXmlNode); _cFile.aAudioChannels = aChannelsAudio; _cFile.stContainerArea = stArea; short nCropHorizontal = cXmlNode.AttributeGet <short>("crop_horizontal"); short nCropVertical = cXmlNode.AttributeGet <short>("crop_vertical"); float nAspect_Ratio = cXmlNode.AttributeGet <float>("aspect_ratio"); float nW = nWidthOriginal; float nH = nHeightOriginal; nH = nAspectRatio_divider == 0 ? nH : nH * nAspectRatio_dividend / nAspectRatio_divider; // приведение к 1:1 nW = nW * nAspect_Ratio; // учёт аспекта пикселя результата float nWnewPre = stArea.nWidth + 2 * nCropHorizontal; float nHnewPre = stArea.nHeight + 2 * nCropVertical; float nK = Math.Min(nW / nWnewPre, nH / nHnewPre); float nWnew = nW / nK; float nHnew = nH / nK; int nCropHoriz = (int)((nWnew - nWnewPre) / 2 + nCropHorizontal); int nCropVert = (int)((nHnew - nHnewPre) / 2 + nCropVertical); stArea = new Area((short)(stArea.nLeft - nCropHoriz), (short)(stArea.nTop - nCropVert), (ushort)nWnew, (ushort)nHnew); } catch { Fail(); throw; } }
public void Open(ffmpeg.net.File.Input.PlaybackMode ePlaybackMode) { _cFile = new ffmpeg.net.File.Input(_sFile, nFrameStart); ffmpeg.net.AVSampleFormat eAVSampleFormat; switch (Preferences.nAudioBitDepth) { case 32: eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S32; break; case 16: default: eAVSampleFormat = ffmpeg.net.AVSampleFormat.AV_SAMPLE_FMT_S16; break; } int nAudioChannelsQty = Preferences.nAudioChannelsQtyFfmpeg; _cFormat = new ffmpeg.net.Format.Audio((int)Preferences.nAudioSamplesRate, nAudioChannelsQty, eAVSampleFormat); nFramesTotal = _cFile.nFramesQty; //_cFile.Prepare(nDuration); _cFile.Prepare(null, _cFormat, ePlaybackMode); }