コード例 #1
0
		public void ExtractStreams(bool extractAudio, bool extractVideo, bool extractTimeCodes, OverwriteDelegate overwrite) {
			uint dataOffset, flags, prevTagSize;

			_outputPathBase = Path.Combine(_outputDirectory, Path.GetFileNameWithoutExtension(_inputPath));
			_overwrite = overwrite;
			_extractAudio = extractAudio;
			_extractVideo = extractVideo;
			_extractTimeCodes = extractTimeCodes;
			_videoTimeStamps = new List<uint>();

			Seek(0);
			if (_fileLength < 4 || ReadUInt32() != 0x464C5601) {
				if (_fileLength >= 8 && ReadUInt32() == 0x66747970) {
					throw new Exception("This is a MP4 file. YAMB or MP4Box can be used to extract streams.");
				}
				else {
					throw new Exception("This isn't a FLV file.");
				}
			}

			if (Array.IndexOf(_outputExtensions, Path.GetExtension(_inputPath).ToLowerInvariant()) != -1) {
				// Can't have the same extension as files we output
				throw new Exception("Please change the extension of this FLV file.");
			}

			if (!Directory.Exists(_outputDirectory)) {
				throw new Exception("Output directory doesn't exist.");
			}

			flags = ReadUInt8();
			dataOffset = ReadUInt32();

			Seek(dataOffset);

			prevTagSize = ReadUInt32();
			while (_fileOffset < _fileLength) {
				if (!ReadTag()) break;
				if ((_fileLength - _fileOffset) < 4) break;
				prevTagSize = ReadUInt32();
			}

			_averageFrameRate = CalculateAverageFrameRate();
			_trueFrameRate = CalculateTrueFrameRate();

			CloseOutput(_averageFrameRate, false);
		}
コード例 #2
0
ファイル: toMpThree.cs プロジェクト: pixma/flvmp3Covey
        public void ExtractStreams(bool extractAudio, bool extractVideo, bool extractTimeCodes, OverwriteDelegate overwrite)
        {
            uint dataOffset, flags, prevTagSize;

            _outputPathBase = Path.Combine(_outputDirectory, Path.GetFileNameWithoutExtension(_inputPath));
            _overwrite = overwrite;
            _extractAudio = extractAudio;
            _extractVideo = extractVideo;
            _extractTimeCodes = extractTimeCodes;
            _videoTimeStamps = new List<uint>();

            Seek(0);
            if (_fileLength < 4 || ReadUInt32() != 0x464C5601)
            {
                if (_fileLength >= 8 && ReadUInt32() == 0x66747970)
                {
                    throw new Exception("This is a MP4 file. ");
                }
                else
                {
                    throw new Exception("This isn't a FLV file.");
                }
            }

            flags = ReadUInt8();
            dataOffset = ReadUInt32();

            Seek(dataOffset);

            prevTagSize = ReadUInt32();
            while (_fileOffset < _fileLength)
            {
                if (!ReadTag()) break;
                if ((_fileLength - _fileOffset) < 4) break;
                prevTagSize = ReadUInt32();
            }

            CloseOutput(false);
        }