diff --git a/config.py b/config.py index c3de16b..41dadd6 100644 --- a/config.py +++ b/config.py @@ -30,8 +30,6 @@ FFMPEG_USE_INTEL_GPU = False FFMPEG_USE_VAAPI = False # bitrate VIDEO_BITRATE = "2.5M" -# crf -VIDEO_CRF = 28 # gop VIDEO_GOP = 60 # [video] @@ -96,7 +94,7 @@ def load_config(): VIDEO_CLIP_OVERFLOW_SEC = section.getfloat('overflow_sec', VIDEO_CLIP_OVERFLOW_SEC) if config.has_section("ffmpeg"): section = config['ffmpeg'] - global FFMPEG_EXEC, FFMPEG_USE_HEVC, FFMPEG_USE_NVIDIA_GPU, FFMPEG_USE_INTEL_GPU, VIDEO_BITRATE, VIDEO_CRF, \ + global FFMPEG_EXEC, FFMPEG_USE_HEVC, FFMPEG_USE_NVIDIA_GPU, FFMPEG_USE_INTEL_GPU, VIDEO_BITRATE, \ VIDEO_GOP, FFMPEG_USE_VAAPI FFMPEG_EXEC = section.get('exec', FFMPEG_EXEC) FFMPEG_USE_HEVC = section.getboolean('hevc', FFMPEG_USE_HEVC) @@ -104,7 +102,6 @@ def load_config(): FFMPEG_USE_INTEL_GPU = section.getboolean('intel_gpu', FFMPEG_USE_INTEL_GPU) FFMPEG_USE_VAAPI = section.getboolean('vaapi', FFMPEG_USE_VAAPI) VIDEO_BITRATE = section.get('bitrate', VIDEO_BITRATE) - VIDEO_CRF = section.getfloat('crf', VIDEO_CRF) VIDEO_GOP = section.getfloat('gop', VIDEO_GOP) if config.has_section("recorder"): global BILILIVE_RECORDER_DIRECTORY, XIGUALIVE_RECORDER_DIRECTORY, VIDEO_OUTPUT_DIR @@ -144,7 +141,6 @@ def get_config(): 'intel_gpu': FFMPEG_USE_INTEL_GPU, 'vaapi': FFMPEG_USE_VAAPI, 'bitrate': VIDEO_BITRATE, - 'crf': VIDEO_CRF, 'gop': VIDEO_GOP, }, 'recorder': { diff --git a/templates/index.html b/templates/index.html index e844cf2..b5bc675 100644 --- a/templates/index.html +++ b/templates/index.html @@ -104,10 +104,6 @@ 视频比特率 {{ config.ffmpeg.bitrate }} - - 视频CRF - {{ config.ffmpeg.crf }} - GOP {{ config.ffmpeg.gop }} @@ -328,7 +324,6 @@ intel_gpu: false, vaapi: false, bitrate: "", - crf: "", gop: "", }, recorder: { diff --git a/test/create_workflow.py b/test/create_workflow.py new file mode 100644 index 0000000..40eb889 --- /dev/null +++ b/test/create_workflow.py @@ -0,0 +1,24 @@ +import requests +from time import sleep + + +API_BASE = "https://bilirec.home.jerryyan.top" +FILE = "24048885/20221125_201819.flv" + +requests.post(API_BASE+"/api/bilirecorder/", json={ + "EventType": "SessionStarted" +}) +sleep(1) +response = requests.post(API_BASE+"/api/bilirecorder/", json={ + "EventType": "FileClosed", + "EventData": { + "RelativePath": FILE + } +}) +sleep(1) +requests.post(API_BASE+"/api/bilirecorder/", json={ + "EventType": "SessionEnded", +}) + +print(response) +print(response.json()) \ No newline at end of file diff --git a/workflow/video.py b/workflow/video.py index fd0e2e5..cbb88f1 100644 --- a/workflow/video.py +++ b/workflow/video.py @@ -5,7 +5,7 @@ from typing import IO from config import FFMPEG_EXEC, FFMPEG_USE_HEVC, VIDEO_BITRATE, FFMPEG_USE_NVIDIA_GPU, VIDEO_CLIP_EACH_SEC, \ VIDEO_CLIP_OVERFLOW_SEC, \ - FFMPEG_USE_INTEL_GPU, VIDEO_OUTPUT_DIR, VIDEO_CRF, VIDEO_GOP, FFMPEG_USE_VAAPI + FFMPEG_USE_INTEL_GPU, VIDEO_OUTPUT_DIR, VIDEO_GOP, FFMPEG_USE_VAAPI from . import LOGGER @@ -214,7 +214,7 @@ def quick_split_video(file): split_process = subprocess.Popen([ FFMPEG_EXEC, *_common_ffmpeg_setting(), "-ss", str(current_sec), - "-i", file, "-c:v", "copy", "-c:a", "aac", "-f", "mp4", + "-i", file, "-c:v", "copy", "-c:a", "copy", "-f", "mp4", "-t", str(VIDEO_CLIP_EACH_SEC + VIDEO_CLIP_OVERFLOW_SEC), "-fflags", "+genpts", "-shortest", "-movflags", "faststart", os.path.join(VIDEO_OUTPUT_DIR, "{}.mp4".format(current_dt)) @@ -239,6 +239,6 @@ def _common_ffmpeg_params(): return ( "-f", "mp4", "-b:v", VIDEO_BITRATE, "-c:a", "aac", "-preset:v", "fast", "-profile:v", "main", "-avoid_negative_ts", "1", - "-qmin", "18", "-qmax", "38", "-crf", str(VIDEO_CRF), "-g:v", str(VIDEO_GOP), + "-qmin", "18", "-qmax", "38", "-g:v", str(VIDEO_GOP), "-fflags", "+genpts", "-shortest" )