예제 #1
0
        /// <exception cref="AudioExtractionException">The input file is not an FLV file.</exception>
        public async Task <Stream> ExtractStreams()
        {
            return(await Task.Run(() =>
            {
                Seek(0);

                if (ReadUInt32() != 0x464C5601)
                {
                    // not a FLV file
                    throw new AudioExtractionException("Invalid input file. Impossible to extract audio track.");
                }

                ReadUInt8();
                uint dataOffset = ReadUInt32();

                Seek(dataOffset);

                ReadUInt32();

                while (_fileOffset < _fileLength)
                {
                    if (!ReadTag())
                    {
                        break;
                    }

                    if (_fileLength - _fileOffset < 4)
                    {
                        break;
                    }

                    ReadUInt32();

                    double progress = (_fileOffset * 1.0 / _fileLength) * 100;

                    ConversionProgressChanged?.Invoke(this, new ProgressChangedEventArgs((int)progress, Guid.NewGuid()));
                }

                return _audioExtractor.Save();
            }));
        }
예제 #2
0
 public void OnProgessChanged(int percent)
 {
     ConversionProgressChanged?.Invoke(this, percent);
 }