mirror of
https://github.com/acgnhiki/blrec.git
synced 2024-12-27 17:10:18 +08:00
release: v1.2.1
This commit is contained in:
parent
3e71c39e0d
commit
62c1abfd24
@ -1,5 +1,9 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
## 1.2.1
|
||||||
|
|
||||||
|
- 兼容 flv 头不正确的直播流
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
|
|
||||||
- 改进文件处理方式,文件录制完成后就进行处理。
|
- 改进文件处理方式,文件录制完成后就进行处理。
|
||||||
|
@ -146,8 +146,14 @@
|
|||||||
|
|
||||||
[CHANGELOG](CHANGELOG.md)
|
[CHANGELOG](CHANGELOG.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 赞助 & 支持
|
## 赞助 & 支持
|
||||||
|
|
||||||
如果觉得这个工具好用,对你有所帮助,可以投喂支持亿下哦~
|
如果觉得这个工具好用,对你有所帮助,可以投喂支持亿下哦~
|
||||||
|
|
||||||
投喂赞助 ☞ <https://afdian.net/@acgnhiki>
|
投喂赞助 ☞ <https://afdian.net/@acgnhiki>
|
||||||
|
|
||||||
|
## Thanks
|
||||||
|
|
||||||
|
[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSource)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
__prog__ = 'blrec'
|
__prog__ = 'blrec'
|
||||||
__version__ = '1.2.0'
|
__version__ = '1.2.1'
|
||||||
__github__ = 'https://github.com/acgnhiki/blrec'
|
__github__ = 'https://github.com/acgnhiki/blrec'
|
||||||
|
@ -75,6 +75,8 @@ class DataAnalyser:
|
|||||||
self._keyframe_filepositions: List[int] = []
|
self._keyframe_filepositions: List[int] = []
|
||||||
self._resolution: Optional[Resolution] = None
|
self._resolution: Optional[Resolution] = None
|
||||||
|
|
||||||
|
self._has_audio = False
|
||||||
|
self._has_video = False
|
||||||
self._header_analysed = False
|
self._header_analysed = False
|
||||||
self._audio_analysed = False
|
self._audio_analysed = False
|
||||||
self._video_analysed = False
|
self._video_analysed = False
|
||||||
@ -83,8 +85,6 @@ class DataAnalyser:
|
|||||||
assert not self._header_analysed
|
assert not self._header_analysed
|
||||||
self._header_analysed = True
|
self._header_analysed = True
|
||||||
self._size_of_flv_header = header.size
|
self._size_of_flv_header = header.size
|
||||||
self._has_audio = header.has_audio()
|
|
||||||
self._has_video = header.has_video()
|
|
||||||
|
|
||||||
def analyse_tag(self, tag: FlvTag) -> None:
|
def analyse_tag(self, tag: FlvTag) -> None:
|
||||||
if is_audio_tag(tag):
|
if is_audio_tag(tag):
|
||||||
@ -198,6 +198,7 @@ class DataAnalyser:
|
|||||||
|
|
||||||
def _analyse_audio_tag(self, tag: AudioTag) -> None:
|
def _analyse_audio_tag(self, tag: AudioTag) -> None:
|
||||||
if not self._audio_analysed:
|
if not self._audio_analysed:
|
||||||
|
self._has_audio = True
|
||||||
self._audio_analysed = True
|
self._audio_analysed = True
|
||||||
self._audio_codec_id = tag.sound_format.value
|
self._audio_codec_id = tag.sound_format.value
|
||||||
self._audio_sample_rate = tag.sound_rate.value
|
self._audio_sample_rate = tag.sound_rate.value
|
||||||
@ -219,6 +220,7 @@ class DataAnalyser:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if not self._video_analysed:
|
if not self._video_analysed:
|
||||||
|
self._has_video = True
|
||||||
self._video_analysed = True
|
self._video_analysed = True
|
||||||
self._video_codec_id = tag.codec_id.value
|
self._video_codec_id = tag.codec_id.value
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ def non_negative_integer_validator(instance, attribute, value): # type: ignore
|
|||||||
raise ValueError(f"'{attribute}' has to be a non negative integer!")
|
raise ValueError(f"'{attribute}' has to be a non negative integer!")
|
||||||
|
|
||||||
|
|
||||||
@attr.s(auto_attribs=True, slots=True, frozen=True)
|
@attr.s(auto_attribs=True, slots=True)
|
||||||
class FlvHeader:
|
class FlvHeader:
|
||||||
signature: str
|
signature: str
|
||||||
version: int
|
version: int
|
||||||
@ -94,6 +94,18 @@ class FlvHeader:
|
|||||||
def has_audio(self) -> bool:
|
def has_audio(self) -> bool:
|
||||||
return bool(self.type_flag & 0b0000_0100)
|
return bool(self.type_flag & 0b0000_0100)
|
||||||
|
|
||||||
|
def set_video_flag(self, value: bool) -> None:
|
||||||
|
if value:
|
||||||
|
self.type_flag |= 0b0000_0001
|
||||||
|
else:
|
||||||
|
self.type_flag &= ~0b0000_0001
|
||||||
|
|
||||||
|
def set_audio_flag(self, value: bool) -> None:
|
||||||
|
if value:
|
||||||
|
self.type_flag |= 0b0000_0100
|
||||||
|
else:
|
||||||
|
self.type_flag &= ~0b0000_0100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self) -> int:
|
def size(self) -> int:
|
||||||
return self.data_offset
|
return self.data_offset
|
||||||
|
@ -208,7 +208,6 @@ class StreamProcessor:
|
|||||||
self._in_reader = FlvReaderWithTimestampFix(stream)
|
self._in_reader = FlvReaderWithTimestampFix(stream)
|
||||||
flv_header = self._read_header()
|
flv_header = self._read_header()
|
||||||
self._has_audio = flv_header.has_audio()
|
self._has_audio = flv_header.has_audio()
|
||||||
assert flv_header.has_video(), 'no video in the stream!'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
first_data_tag = self._read_first_data_tag()
|
first_data_tag = self._read_first_data_tag()
|
||||||
@ -230,7 +229,7 @@ class StreamProcessor:
|
|||||||
self._new_file()
|
self._new_file()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._write_header(flv_header)
|
self._write_header(self._ensure_header_correct(flv_header))
|
||||||
self._transfer_meta_tags()
|
self._transfer_meta_tags()
|
||||||
self._transfer_first_data_tag(first_data_tag)
|
self._transfer_first_data_tag(first_data_tag)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -486,6 +485,15 @@ class StreamProcessor:
|
|||||||
self._size_updates.on_next(size)
|
self._size_updates.on_next(size)
|
||||||
self._time_updates.on_next(tag.timestamp)
|
self._time_updates.on_next(tag.timestamp)
|
||||||
|
|
||||||
|
def _ensure_header_correct(self, header: FlvHeader) -> FlvHeader:
|
||||||
|
header.set_video_flag(
|
||||||
|
self._parameters_checker.last_video_header_tag is not None
|
||||||
|
)
|
||||||
|
header.set_audio_flag(
|
||||||
|
self._parameters_checker.last_audio_header_tag is not None
|
||||||
|
)
|
||||||
|
return header
|
||||||
|
|
||||||
def _ensure_ts_correct(self, tag: FlvTag) -> None:
|
def _ensure_ts_correct(self, tag: FlvTag) -> None:
|
||||||
if tag.timestamp + self._delta < 0:
|
if tag.timestamp + self._delta < 0:
|
||||||
self._delta = -tag.timestamp
|
self._delta = -tag.timestamp
|
||||||
|
Loading…
Reference in New Issue
Block a user