去除CRF,避免码率设置失效
This commit is contained in:
parent
92bc5791ac
commit
c3993965a9
@ -30,8 +30,6 @@ FFMPEG_USE_INTEL_GPU = False
|
|||||||
FFMPEG_USE_VAAPI = False
|
FFMPEG_USE_VAAPI = False
|
||||||
# bitrate
|
# bitrate
|
||||||
VIDEO_BITRATE = "2.5M"
|
VIDEO_BITRATE = "2.5M"
|
||||||
# crf
|
|
||||||
VIDEO_CRF = 28
|
|
||||||
# gop
|
# gop
|
||||||
VIDEO_GOP = 60
|
VIDEO_GOP = 60
|
||||||
# [video]
|
# [video]
|
||||||
@ -96,7 +94,7 @@ def load_config():
|
|||||||
VIDEO_CLIP_OVERFLOW_SEC = section.getfloat('overflow_sec', VIDEO_CLIP_OVERFLOW_SEC)
|
VIDEO_CLIP_OVERFLOW_SEC = section.getfloat('overflow_sec', VIDEO_CLIP_OVERFLOW_SEC)
|
||||||
if config.has_section("ffmpeg"):
|
if config.has_section("ffmpeg"):
|
||||||
section = config['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
|
VIDEO_GOP, FFMPEG_USE_VAAPI
|
||||||
FFMPEG_EXEC = section.get('exec', FFMPEG_EXEC)
|
FFMPEG_EXEC = section.get('exec', FFMPEG_EXEC)
|
||||||
FFMPEG_USE_HEVC = section.getboolean('hevc', FFMPEG_USE_HEVC)
|
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_INTEL_GPU = section.getboolean('intel_gpu', FFMPEG_USE_INTEL_GPU)
|
||||||
FFMPEG_USE_VAAPI = section.getboolean('vaapi', FFMPEG_USE_VAAPI)
|
FFMPEG_USE_VAAPI = section.getboolean('vaapi', FFMPEG_USE_VAAPI)
|
||||||
VIDEO_BITRATE = section.get('bitrate', VIDEO_BITRATE)
|
VIDEO_BITRATE = section.get('bitrate', VIDEO_BITRATE)
|
||||||
VIDEO_CRF = section.getfloat('crf', VIDEO_CRF)
|
|
||||||
VIDEO_GOP = section.getfloat('gop', VIDEO_GOP)
|
VIDEO_GOP = section.getfloat('gop', VIDEO_GOP)
|
||||||
if config.has_section("recorder"):
|
if config.has_section("recorder"):
|
||||||
global BILILIVE_RECORDER_DIRECTORY, XIGUALIVE_RECORDER_DIRECTORY, VIDEO_OUTPUT_DIR
|
global BILILIVE_RECORDER_DIRECTORY, XIGUALIVE_RECORDER_DIRECTORY, VIDEO_OUTPUT_DIR
|
||||||
@ -144,7 +141,6 @@ def get_config():
|
|||||||
'intel_gpu': FFMPEG_USE_INTEL_GPU,
|
'intel_gpu': FFMPEG_USE_INTEL_GPU,
|
||||||
'vaapi': FFMPEG_USE_VAAPI,
|
'vaapi': FFMPEG_USE_VAAPI,
|
||||||
'bitrate': VIDEO_BITRATE,
|
'bitrate': VIDEO_BITRATE,
|
||||||
'crf': VIDEO_CRF,
|
|
||||||
'gop': VIDEO_GOP,
|
'gop': VIDEO_GOP,
|
||||||
},
|
},
|
||||||
'recorder': {
|
'recorder': {
|
||||||
|
@ -104,10 +104,6 @@
|
|||||||
<td>视频比特率</td>
|
<td>视频比特率</td>
|
||||||
<td>{{ config.ffmpeg.bitrate }}</td>
|
<td>{{ config.ffmpeg.bitrate }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>视频CRF</td>
|
|
||||||
<td>{{ config.ffmpeg.crf }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>GOP</td>
|
<td>GOP</td>
|
||||||
<td>{{ config.ffmpeg.gop }}</td>
|
<td>{{ config.ffmpeg.gop }}</td>
|
||||||
@ -328,7 +324,6 @@
|
|||||||
intel_gpu: false,
|
intel_gpu: false,
|
||||||
vaapi: false,
|
vaapi: false,
|
||||||
bitrate: "",
|
bitrate: "",
|
||||||
crf: "",
|
|
||||||
gop: "",
|
gop: "",
|
||||||
},
|
},
|
||||||
recorder: {
|
recorder: {
|
||||||
|
24
test/create_workflow.py
Normal file
24
test/create_workflow.py
Normal file
@ -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())
|
@ -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, \
|
from config import FFMPEG_EXEC, FFMPEG_USE_HEVC, VIDEO_BITRATE, FFMPEG_USE_NVIDIA_GPU, VIDEO_CLIP_EACH_SEC, \
|
||||||
VIDEO_CLIP_OVERFLOW_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
|
from . import LOGGER
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ def quick_split_video(file):
|
|||||||
split_process = subprocess.Popen([
|
split_process = subprocess.Popen([
|
||||||
FFMPEG_EXEC, *_common_ffmpeg_setting(),
|
FFMPEG_EXEC, *_common_ffmpeg_setting(),
|
||||||
"-ss", str(current_sec),
|
"-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),
|
"-t", str(VIDEO_CLIP_EACH_SEC + VIDEO_CLIP_OVERFLOW_SEC),
|
||||||
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
"-fflags", "+genpts", "-shortest", "-movflags", "faststart",
|
||||||
os.path.join(VIDEO_OUTPUT_DIR, "{}.mp4".format(current_dt))
|
os.path.join(VIDEO_OUTPUT_DIR, "{}.mp4".format(current_dt))
|
||||||
@ -239,6 +239,6 @@ def _common_ffmpeg_params():
|
|||||||
return (
|
return (
|
||||||
"-f", "mp4", "-b:v", VIDEO_BITRATE, "-c:a", "aac",
|
"-f", "mp4", "-b:v", VIDEO_BITRATE, "-c:a", "aac",
|
||||||
"-preset:v", "fast", "-profile:v", "main", "-avoid_negative_ts", "1",
|
"-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"
|
"-fflags", "+genpts", "-shortest"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user