我刚刚创建了一个 shell 脚本并添加到crontab -e
Crontab 运行良好,但是当我手动终止进程时,该进程的录制视频无法播放。
因为当我从终端运行应用程序并通过按q或Ctrl+关闭该应用程序时C,该应用程序的录制的视频可以播放,但当我们终止该进程时则不能播放。
该应用程序是 Deepstream 应用程序,它从 RTSP 摄像头获取输入并在 RTSP 中输出流并录制该视频。为了终止该进程,我使用sudo kill PID
但这sudo pkill process-name
会使录制的视频无法播放。
如何解决这个问题呢?
如果我在终端中运行并用 Ctrl+关闭C,则录制的视频将可播放。
$ sudo deepstream-app -c source8_1080p_dec_infer-resnet_tracker_tiled_display_fp16_nano.txt
[sudo] password for mindnotice:
*** DeepStream: Launched RTSP Streaming at rtsp://localhost:8554/ds-test ***
Opening in BLOCKING MODE
Opening in BLOCKING MODE
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_nvmultiobjecttracker.so
gstnvtracker: Batch processing is ON
gstnvtracker: Past frame output is ON
[NvMultiObjectTracker] Initialized
0:00:03.299363263 11754 0x18710b20 INFO nvinfer gstnvinfer.cpp:638:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1900> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.0/samples/models/tao_pretrained_models/latest-yolov4/yolov4_resnet18_epoch_070.etlt_b1_gpu0_fp16.engine
INFO: [Implicit Engine Info]: layers num: 5
0 INPUT kFLOAT Input 3x384x1248
1 OUTPUT kINT32 BatchedNMS 1
2 OUTPUT kFLOAT BatchedNMS_1 200x4
3 OUTPUT kFLOAT BatchedNMS_2 200
4 OUTPUT kFLOAT BatchedNMS_3 200
0:00:03.313609834 11754 0x18710b20 INFO nvinfer gstnvinfer.cpp:638:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2004> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.0/samples/models/tao_pretrained_models/latest-yolov4/yolov4_resnet18_epoch_070.etlt_b1_gpu0_fp16.engine
0:00:03.328004320 11754 0x18710b20 INFO nvinfer gstnvinfer_impl.cpp:313:notifyLoadModelStatus:<primary_gie> [UID 1]: Load new model:/opt/nvidia/deepstream/deepstream-6.0/samples/configs/deepstream-app/nvinfer1_config.txt sucessfully
Runtime commands:
h: Print this help
q: Quit
p: Pause
r: Resume
** INFO: <bus_callback:194>: Pipeline ready
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279
** INFO: <bus_callback:180>: Pipeline running
NvMMLiteOpen : Block : BlockType = 4
NvMMLiteOpen : Block : BlockType = 8
===== NVMEDIA: NVENC =====
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
NvMMLiteBlockCreate : Block : BlockType = 8
H264: Profile = 66, Level = 0
NVMEDIA: H265 : Profile : 1
NVMEDIA_ENC: bBlitMode is set to TRUE
NVMEDIA_ENC: bBlitMode is set to TRUE
**PERF: FPS 0 (Avg)
**PERF: 58.13 (52.30)
**PERF: 31.18 (31.90)
**PERF: 24.95 (28.51)
^C** ERROR: <_intr_handler:140>: User Interrupted..
Quitting
[NvMultiObjectTracker] De-initialized
App run successful
mindnotice@ubuntu:/opt/nvidia/deepstream/deepstream-6.0/samples/configs/deepstream-app$ ps ax |grep deepstream
11890 pts/0 S+ 0:00 grep --color=auto deepstream
mindnotice@ubuntu:/opt/nvidia/deepstream/deepstream-6.0/samples/configs/deepstream-app$ sudo deepstream-app -c source8_1080p_dec_infer-resnet_tracker_tiled_display_fp16_nano.txt
*** DeepStream: Launched RTSP Streaming at rtsp://localhost:8554/ds-test ***
Opening in BLOCKING MODE
Opening in BLOCKING MODE
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream-6.0/lib/libnvds_nvmultiobjecttracker.so
gstnvtracker: Batch processing is ON
gstnvtracker: Past frame output is ON
[NvMultiObjectTracker] Initialized
0:00:03.177978493 11892 0x30168b20 INFO nvinfer gstnvinfer.cpp:638:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1900> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.0/samples/models/tao_pretrained_models/latest-yolov4/yolov4_resnet18_epoch_070.etlt_b1_gpu0_fp16.engine
INFO: [Implicit Engine Info]: layers num: 5
0 INPUT kFLOAT Input 3x384x1248
1 OUTPUT kINT32 BatchedNMS 1
2 OUTPUT kFLOAT BatchedNMS_1 200x4
3 OUTPUT kFLOAT BatchedNMS_2 200
4 OUTPUT kFLOAT BatchedNMS_3 200
0:00:03.190724954 11892 0x30168b20 INFO nvinfer gstnvinfer.cpp:638:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2004> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.0/samples/models/tao_pretrained_models/latest-yolov4/yolov4_resnet18_epoch_070.etlt_b1_gpu0_fp16.engine
0:00:03.204207961 11892 0x30168b20 INFO nvinfer gstnvinfer_impl.cpp:313:notifyLoadModelStatus:<primary_gie> [UID 1]: Load new model:/opt/nvidia/deepstream/deepstream-6.0/samples/configs/deepstream-app/nvinfer1_config.txt sucessfully
Runtime commands:
h: Print this help
q: Quit
p: Pause
r: Resume
** INFO: <bus_callback:194>: Pipeline ready
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 279
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 279
** INFO: <bus_callback:180>: Pipeline running
NvMMLiteOpen : Block : BlockType = 8
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8
NvMMLiteBlockCreate : Block : BlockType = 4
H264: Profile = 66, Level = 0
NVMEDIA: H265 : Profile : 1
NVMEDIA_ENC: bBlitMode is set to TRUE
NVMEDIA_ENC: bBlitMode is set to TRUE
**PERF: FPS 0 (Avg)
**PERF: 54.25 (50.33)
**PERF: 30.69 (31.71)
**PERF: 25.00 (28.45)
**PERF: 24.90 (27.32)
**PERF: 25.04 (26.75)
**PERF: 24.96 (26.40)
**PERF: 24.95 (26.17)
**PERF: 25.00 (26.00)
**PERF: 25.05 (25.88)
**PERF: 24.90 (25.78)
Terminated
答案1
要以类似于按Ctrl+的方式终止后台进程C,您可以发送信号情报使用杀命令。SIGINT 信号是当您在终端中按下Ctrl+时发送给进程的信号。C
Ctrl以+方式关闭后台进程C。
步骤1:
ps ax | grep process-name
它将为您提供一个进程列表以获取进程 ID。
第2步:
sudo kill -SIGINT PID
现在我已经关闭了我的进程并且视频可以播放了。哇