4
A
回答
18
我沒有找到任何東西,所以我必須自己寫。它速度非常快,而且效果很好。以下是代碼:
protected byte[] ExtractAudio(Stream stream)
{
var reader = new BinaryReader(stream);
// Is stream a Flash Video stream
if (reader.ReadChar() != 'F' || reader.ReadChar() != 'L' || reader.ReadChar() != 'V')
throw new IOException("The file is not a FLV file.");
// Is audio stream exists in the video stream
var version = reader.ReadByte();
var exists = reader.ReadByte();
if ((exists != 5) && (exists != 4))
throw new IOException("No Audio Stream");
reader.ReadInt32(); // data offset of header. ignoring
var output = new List<byte>();
while (true)
{
try
{
reader.ReadInt32(); // PreviousTagSize0 skipping
var tagType = reader.ReadByte();
while (tagType != 8)
{
var skip = ReadNext3Bytes(reader) + 11;
reader.BaseStream.Position += skip;
tagType = reader.ReadByte();
}
var DataSize = ReadNext3Bytes(reader);
reader.ReadInt32(); //skip timestamps
ReadNext3Bytes(reader); // skip streamID
reader.ReadByte(); // skip audio header
for (int i = 0; i < DataSize - 1; i++)
output.Add(reader.ReadByte());
}
catch
{
break;
}
}
return output.ToArray();
}
private long ReadNext3Bytes(BinaryReader reader)
{
try
{
return Math.Abs((reader.ReadByte() & 0xFF) * 256 * 256 + (reader.ReadByte() & 0xFF)
* 256 + (reader.ReadByte() & 0xFF));
}
catch
{
return 0;
}
}
+0
我有一個flv視頻有音頻流,但它不適合它。 – greatmajestics 2014-05-11 17:47:34
+0
你可以讓我這個...阿隆Gubkin。上面提供的代碼不起作用。 – greatmajestics 2014-05-11 18:26:49
相關問題
- 1. 如何從FLV中提取音頻?
- 2. 從python視頻流中提取音頻
- 3. 從音頻流中提取元數據
- 4. 從FLV中提取音頻數據並注入MP3
- 5. 如何在Red5上從實況視頻流中提取音頻?
- 6. 如何在C++中使用ffmpeg從視頻中提取音頻?
- 7. 用於從音頻流中提取單詞(語音)的庫?
- 8. 使用javascript從視頻流中提取音頻
- 9. FFmpeg - 從傳輸流文件(.ts)中提取視頻和音頻
- 10. 從視頻中提取音頻
- 11. 從視頻中提取音頻幅度
- 12. PHP從視頻中提取音頻
- 13. 如何從視頻中提取音頻
- 14. 從C#中的youtube視頻中提取mp3音頻文件#
- 15. 從MP4/FLV中提取幀?
- 16. flv視頻流
- 17. 在iOS中從音頻中提取高音和低音
- 18. 在ActionScript中添加音頻到FLV
- 19. 從python的音頻文件中提取音頻頻譜
- 20. 流音頻C#
- 21. 使用ffmpeg從文件中提取音頻流
- 22. 從音頻文件中提取流派元數據
- 23. 從AVI文件中提取和分割MP3音頻流
- 24. 從音頻信號中提取二進制數據流
- 25. Java如何從電影中提取音頻流
- 26. 提取音頻對象-c
- 27. 從視頻中提取聲音
- 28. iOS從.mov文件中提取音頻
- 29. 從音頻文件中提取數據
- 30. 從音頻剪輯中提取單詞
音頻結果的格式是什麼? MP3? – Charles 2012-11-02 19:49:43