mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
Revert switch to mpegts format and audio default
This commit is contained in:
parent
c1132e6897
commit
4cf55ad8e2
@ -15,8 +15,8 @@ Note that mjpeg cameras require encoding the video into h264 for recording, and
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
output_args:
|
output_args:
|
||||||
record: -f segment -segment_time 10 -segment_format ts -reset_timestamps 1 -strftime 1 -c:v libx264
|
record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c:v libx264 -an
|
||||||
rtmp: -c:v libx264 -f flv
|
rtmp: -c:v libx264 -an -f flv
|
||||||
```
|
```
|
||||||
|
|
||||||
### RTMP Cameras
|
### RTMP Cameras
|
||||||
|
@ -140,7 +140,7 @@ ffmpeg:
|
|||||||
# Optional: output args for detect streams (default: shown below)
|
# Optional: output args for detect streams (default: shown below)
|
||||||
detect: -f rawvideo -pix_fmt yuv420p
|
detect: -f rawvideo -pix_fmt yuv420p
|
||||||
# Optional: output args for record streams (default: shown below)
|
# Optional: output args for record streams (default: shown below)
|
||||||
record: -f segment -segment_time 10 -segment_format ts -reset_timestamps 1 -strftime 1 -c copy
|
record: -f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 -strftime 1 -c copy -an
|
||||||
# Optional: output args for rtmp streams (default: shown below)
|
# Optional: output args for rtmp streams (default: shown below)
|
||||||
rtmp: -c copy -f flv
|
rtmp: -c copy -f flv
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ A solid green image means that frigate has not received any frames from ffmpeg.
|
|||||||
|
|
||||||
### How can I get sound or audio in my recordings?
|
### How can I get sound or audio in my recordings?
|
||||||
|
|
||||||
The recommended audio codec is `aac`. Not all audio codecs are supported by RTMP, so you may need to re-encode your audio with `-c:a aac`. The default ffmpeg args are shown [here](configuration/index#full-configuration-reference).
|
By default, Frigate removes audio from recordings to reduce the likelihood of failing for invalid data. If you would like to include audio, you need to override the output args to remove `-an` for where you want to include audio. The recommended audio codec is `aac`. Not all audio codecs are supported by RTMP, so you may need to re-encode your audio with `-c:a aac`. The default ffmpeg args are shown [here](configuration/index#full-configuration-reference).
|
||||||
|
|
||||||
### My mjpeg stream or snapshots look green and crazy
|
### My mjpeg stream or snapshots look green and crazy
|
||||||
|
|
||||||
|
@ -298,13 +298,14 @@ RECORD_FFMPEG_OUTPUT_ARGS_DEFAULT = [
|
|||||||
"-segment_time",
|
"-segment_time",
|
||||||
"10",
|
"10",
|
||||||
"-segment_format",
|
"-segment_format",
|
||||||
"ts",
|
"mp4",
|
||||||
"-reset_timestamps",
|
"-reset_timestamps",
|
||||||
"1",
|
"1",
|
||||||
"-strftime",
|
"-strftime",
|
||||||
"1",
|
"1",
|
||||||
"-c",
|
"-c",
|
||||||
"copy",
|
"copy",
|
||||||
|
"-an",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -564,16 +565,9 @@ class CameraConfig(FrigateBaseModel):
|
|||||||
else self.ffmpeg.output_args.record.split(" ")
|
else self.ffmpeg.output_args.record.split(" ")
|
||||||
)
|
)
|
||||||
|
|
||||||
# backwards compatibility check for segment_format change from mp4 to ts
|
|
||||||
record_args = (
|
|
||||||
" ".join(record_args)
|
|
||||||
.replace("-segment_format mp4", "-segment_format ts")
|
|
||||||
.split(" ")
|
|
||||||
)
|
|
||||||
|
|
||||||
ffmpeg_output_args = (
|
ffmpeg_output_args = (
|
||||||
record_args
|
record_args
|
||||||
+ [f"{os.path.join(CACHE_DIR, self.name)}-%Y%m%d%H%M%S.ts"]
|
+ [f"{os.path.join(CACHE_DIR, self.name)}-%Y%m%d%H%M%S.mp4"]
|
||||||
+ ffmpeg_output_args
|
+ ffmpeg_output_args
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
recordings = [
|
recordings = [
|
||||||
d
|
d
|
||||||
for d in os.listdir(CACHE_DIR)
|
for d in os.listdir(CACHE_DIR)
|
||||||
if os.path.isfile(os.path.join(CACHE_DIR, d)) and d.endswith(".ts")
|
if os.path.isfile(os.path.join(CACHE_DIR, d))
|
||||||
|
and d.endswith(".mp4")
|
||||||
|
and not d.startswith("clip_")
|
||||||
]
|
]
|
||||||
|
|
||||||
files_in_use = []
|
files_in_use = []
|
||||||
@ -111,38 +113,9 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
file_name = f"{start_time.strftime('%M.%S.mp4')}"
|
file_name = f"{start_time.strftime('%M.%S.mp4')}"
|
||||||
file_path = os.path.join(directory, file_name)
|
file_path = os.path.join(directory, file_name)
|
||||||
|
|
||||||
cache_path_mp4 = f"{cache_path[:-2]}mp4"
|
|
||||||
|
|
||||||
ffmpeg_cmd = [
|
|
||||||
"ffmpeg",
|
|
||||||
"-hide_banner",
|
|
||||||
"-y",
|
|
||||||
"-i",
|
|
||||||
cache_path,
|
|
||||||
"-c",
|
|
||||||
"copy",
|
|
||||||
"-movflags",
|
|
||||||
"+faststart",
|
|
||||||
cache_path_mp4,
|
|
||||||
]
|
|
||||||
|
|
||||||
p = sp.run(
|
|
||||||
ffmpeg_cmd,
|
|
||||||
encoding="ascii",
|
|
||||||
capture_output=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
Path(cache_path).unlink(missing_ok=True)
|
|
||||||
|
|
||||||
if p.returncode != 0:
|
|
||||||
logger.error(f"Unable to convert {cache_path} to {file_path}")
|
|
||||||
logger.error(p.stderr)
|
|
||||||
Path(cache_path_mp4).unlink(missing_ok=True)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# copy then delete is required when recordings are stored on some network drives
|
# copy then delete is required when recordings are stored on some network drives
|
||||||
shutil.copyfile(cache_path_mp4, file_path)
|
shutil.copyfile(cache_path, file_path)
|
||||||
Path(cache_path_mp4).unlink(missing_ok=True)
|
os.remove(cache_path)
|
||||||
|
|
||||||
rand_id = "".join(
|
rand_id = "".join(
|
||||||
random.choices(string.ascii_lowercase + string.digits, k=6)
|
random.choices(string.ascii_lowercase + string.digits, k=6)
|
||||||
|
Loading…
Reference in New Issue
Block a user