Kaynağa Gözat

算法交互修改推流码率,指定推流码率为3000k

pull/1/head
chenyukun 2 yıl önce
ebeveyn
işleme
e3b3853eb9
3 değiştirilmiş dosya ile 44 ekleme ve 37 silme
  1. +17
    -34
      .idea/workspace.xml
  2. +20
    -0
      test/read.py
  3. +7
    -3
      util/Cv2Utils.py

+ 17
- 34
.idea/workspace.xml Dosyayı Görüntüle

@@ -5,28 +5,9 @@
</component>
<component name="ChangeListManager">
<list default="true" id="4f7dccd9-8f92-4a6e-90cc-33890d102263" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.idea/sshConfigs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/webServers.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/deployment.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/deployment.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/CommonProcess.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/CommonProcess.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/FileUpdateThread.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/FileUpdateThread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/HeartbeatThread.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/HeartbeatThread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/IntelligentRecognitionProcess.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/IntelligentRecognitionProcess.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/concurrency/MessagePollingThread.py" beforeDir="false" afterPath="$PROJECT_DIR$/concurrency/MessagePollingThread.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dsp_application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/dsp_application.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enums/ExceptionEnum.py" beforeDir="false" afterPath="$PROJECT_DIR$/enums/ExceptionEnum.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/font/全字库正楷体.ttf" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/font/阿里汉仪智能黑体.ttf" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/service/Dispatcher.py" beforeDir="false" afterPath="$PROJECT_DIR$/service/Dispatcher.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/producer_start.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/producer_start.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/视频添加图片水印1.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/视频添加图片水印1.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tuoheng_alg.iml" beforeDir="false" afterPath="$PROJECT_DIR$/tuoheng_alg.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/AliyunSdk.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/AliyunSdk.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/Cv2Utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/Cv2Utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/ImageUtils.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/ImageUtils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/util/KafkaUtils.py" beforeDir="false" afterPath="$PROJECT_DIR$/util/KafkaUtils.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -147,7 +128,7 @@
<property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
<property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
<property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../code/dsp/tuoheng_dsp" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../code/python/learn" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
@@ -170,7 +151,7 @@
<recent name="D:\work\alg\tuoheng_alg\image" />
</key>
</component>
<component name="RunManager" selected="Python.ImageUtils">
<component name="RunManager" selected="Python.read">
<configuration name="ImageUtils" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
@@ -237,20 +218,20 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="asnyc" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="mysqltest" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="sftp://root@212.129.223.66:20653/opt/conda/bin/python3.8" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
<option name="IS_MODULE_SDK" value="false" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="/home/DATA/chenyukun/algSch/test/asnyc.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/mysqltest.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -259,20 +240,20 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="mysqltest" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<configuration name="producer_start" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_HOME" value="sftp://root@212.129.223.66:20653/opt/conda/bin/python3.8" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
<option name="IS_MODULE_SDK" value="true" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/mysqltest.py" />
<option name="SCRIPT_NAME" value="/home/DATA/chenyukun/algSch/test/producer_start.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -281,20 +262,20 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="producer_start" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<configuration name="read" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="tuoheng_alg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="sftp://root@212.129.223.66:20653/opt/conda/bin/python3.8" />
<option name="SDK_HOME" value="$PROJECT_DIR$/../../../software/anaconda/envs/test/python.exe" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/test" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="/home/DATA/chenyukun/algSch/test/producer_start.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test/read.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
@@ -305,19 +286,19 @@
</configuration>
<list>
<item itemvalue="Python.mysqltest" />
<item itemvalue="Python.asnyc" />
<item itemvalue="Python.KafkaUtils" />
<item itemvalue="Python.KafkaUtils (1)" />
<item itemvalue="Python.producer_start" />
<item itemvalue="Python.ImageUtils" />
<item itemvalue="Python.read" />
</list>
<recent_temporary>
<list>
<item itemvalue="Python.read" />
<item itemvalue="Python.ImageUtils" />
<item itemvalue="Python.producer_start" />
<item itemvalue="Python.KafkaUtils" />
<item itemvalue="Python.KafkaUtils (1)" />
<item itemvalue="Python.asnyc" />
</list>
</recent_temporary>
</component>
@@ -360,6 +341,7 @@
<workItem from="1663472604061" duration="19071000" />
<workItem from="1663515200540" duration="648000" />
<workItem from="1663545195142" duration="3595000" />
<workItem from="1663631838059" duration="7995000" />
</task>
<servers />
</component>
@@ -393,6 +375,7 @@
<SUITE FILE_PATH="coverage/tuoheng_alg$dsp_master.coverage" NAME="dsp_master Coverage Results" MODIFIED="1663403978477" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/tuoheng_alg$5.coverage" NAME="视频添加图片水印5 Coverage Results" MODIFIED="1661905982885" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$KafkaUtils.coverage" NAME="KafkaUtils Coverage Results" MODIFIED="1663465345491" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$read.coverage" NAME="read Coverage Results" MODIFIED="1663640070956" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$ImageUtils.coverage" NAME="ImageUtils Coverage Results" MODIFIED="1663499421253" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/util" />
<SUITE FILE_PATH="coverage/tuoheng_alg$2.coverage" NAME="视频添加图片水印2 Coverage Results" MODIFIED="1661875306428" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
<SUITE FILE_PATH="coverage/tuoheng_alg$4.coverage" NAME="视频添加图片水印4 Coverage Results" MODIFIED="1661874731395" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />

+ 20
- 0
test/read.py Dosyayı Görüntüle

@@ -0,0 +1,20 @@
import cv2
import time
def aa():
start = time.time()
vid = cv2.VideoCapture("http://live.play.t-aaron.com/live/THSAk_hd.m3u8")
print("aaaaaaa", time.time() - start)
while True:
if vid is None or not vid.isOpened():
print("11111111111111111111111", vid)
continue
return_value, frame = vid.read()
if return_value is not None and return_value:
print("拉流时间", time.time()-start)
# break




if __name__=="__main__":
aa()

+ 7
- 3
util/Cv2Utils.py Dosyayı Görüntüle

@@ -72,9 +72,11 @@ class Cv2Util():
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
# '-s', "{}x{}".format(self.width * 2, self.height),
'-s', "{}x{}".format(self.width, int(self.height/2)),
'-s', "{}x{}".format(int(self.width), int(self.height/2)),
'-r', str(15),
'-i', '-', # 指定输入文件
'-g', '5',
'-b:v', '3000k',
'-c:v', 'libx264', # 指定视频编码器
'-pix_fmt', 'yuv420p',
'-preset', 'ultrafast', # 指定输出的视频质量,会影响文件的生成速度,有以下几个可用的值 ultrafast,
@@ -109,9 +111,11 @@ class Cv2Util():
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
# '-s', "{}x{}".format(self.width * 2, self.height),
'-s', "{}x{}".format(self.width, int(self.height/2)),
'-s', "{}x{}".format(int(self.width), int(self.height/2)),
'-r', str(15),
'-i', '-', # 指定输入文件
'-g', '5',
'-b:v', '3000k',
'-c:v', 'libx264', # 指定视频编码器
'-pix_fmt', 'yuv420p',
'-preset', 'ultrafast', # 指定输出的视频质量,会影响文件的生成速度,有以下几个可用的值 ultrafast,
@@ -135,7 +139,7 @@ class Cv2Util():
# self.ai_video_file = cv2.VideoWriter(self.aiFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps,
# (self.width * 2, self.height))
self.ai_video_file = cv2.VideoWriter(self.aiFilePath, cv2.VideoWriter_fourcc(*'mp4v'), self.fps,
(self.width, int(self.height/2)))
(int(self.width), int(self.height/2)))
except ServiceException as s:
logger.exception("构建文件写对象异常: {}, requestId:{}", s, self.requestId)
raise s

Yükleniyor…
İptal
Kaydet