AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-88800

MrMas's questions

Martin Hope
MrMas
Asked: 2023-10-12 00:21:17 +0800 CST

如何获取正在运行的脚本而不是 shell 的 PID?

  • 5

运行./run_func_and_get_pid.sh有以下内容

#!/bin/bash

run () {
    while true
    do
        "$@" & echo -n $! > duh && echo "" `cat duh` `cat dih`
        sleep 5
    done
}

run echo -n my name is mudd & echo -n $$ > dih

输出

my name is mudd 392056 392054
my name is mudd 392060 392054
my name is mudd 392066 392054
my name is mudd 392070 392054
my name is mudd 392074 392054
my name is mudd 392082 392054
my name is mudd 392087 392054
my name is mudd 392091 392054
my name is mudd 392095 392054
my name is mudd 392122 392054
my name is mudd 392126 392054
my name is mudd 392130 392054
my name is mudd 392134 392054
my name is mudd 392139 392054
my name is mudd 392143 392054
my name is mudd 392147 392054
my name is mudd 392151 392054
my name is mudd 392160 392054
my name is mudd 392164 392054
. . .

这篇文章表明这392054​​将是 pidrun_func_and_get_pid.sh但后来我明白了

$ ps aux | grep run_func
. . .
user   392055  0.0  0.0   9632  1852 pts/5    S    09:51   0:00 /bin/bash ./run_func_and_get_pid.sh
user   398763  0.0  0.0   9040  2508 pts/6    S+   10:10   0:00 grep -I --color=auto run_func

$ ps aux | grep 392054
user   398975  0.0  0.0   9040   720 pts/6    S+   10:13   0:00 grep -I --color=auto 392054

我只能猜测这392054是我运行命令时生成的 bash shell。无论进程是什么,它都已经退出了。

如何获取正在运行的脚本的 PID,而不是脚本的父级?

bash
  • 2 个回答
  • 26 Views
Martin Hope
MrMas
Asked: 2021-12-11 12:52:06 +0800 CST

为什么来自 Gstreamer 的 rtpbin 示例不起作用?

  • 0

我正在尝试运行带有 GStream 1.18.5的 Ubuntu 21.10 VirtualBox VM 的 rtpbin 示例。

  • 我设置了 GStreamer 并且已经能够运行许多基本和播放教程。
  • 我还阅读了Application Developer Manual的大部分内容。

从 C 代码做所有事情似乎很简单,但rtpbin示例使用gst-launch-1.0(在基本教程之一中介绍)。

我最初无法让rtpbin示例运行而没有错误:

  • ffenc_h263和ffdec_h263( WARNING: erroneous pipeline: no element "ffenc_h263"),所以我分别用avenc_h263和替换了它们avdec_h263
  • v4l2src正在寻找一个不可用的设备,/dev所以我切换到videotestsrc.

为了确保这些替换没有问题,我摆脱了 RTSP 和 UDP 的东西并通过运行检查:

gst-launch-1.0 videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay \ 
    ! rtph263depay ! avdec_h263 ! xvimagesink

并看到了“酒吧”视频。我也跑了

gst-launch-1.0 audiotestsrc ! amrnbenc ! rtpamrpay ! rtpamrdepay ! amrnbdec ! alsasink

并听到那恼人的测试音。基于此,我认为问题出在 UDP 和 RTSP 上。

跑步

 gst-launch-1.0 rtpbin name=rtpbin \
         videotestsrc ! videoconvert ! avenc_h263 ! rtph263pay ! rtpbin.send_rtp_sink_0 \
                   rtpbin.send_rtp_src_0 ! udpsink port=5000                            \
                   rtpbin.send_rtcp_src_0 ! udpsink port=5001 sync=false async=false    \
                   udpsrc port=5005 ! rtpbin.recv_rtcp_sink_0                           \
         audiotestsrc ! amrnbenc ! rtpamrpay ! rtpbin.send_rtp_sink_1                   \
                   rtpbin.send_rtp_src_1 ! udpsink port=5002                            \
                   rtpbin.send_rtcp_src_1 ! udpsink port=5003 sync=false async=false    \
                   udpsrc port=5007 ! rtpbin.recv_rtcp_sink_1

节目

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:59.0 / 99:99:99 # This is counting up

然后在另一个窗口中,我运行

gst-launch-1.0 rtpbin name=rtpbin                                          \
     udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1996" \
             port=5000 ! rtpbin.recv_rtp_sink_0                                \
         rtpbin. ! rtph263depay ! avdec_h263 ! xvimagesink                    \
      udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0                               \
      rtpbin.send_rtcp_src_0 ! udpsink port=5005 sync=false async=false        \
     udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)AMR,encoding-params=(string)1,octet-align=(string)1" \
             port=5002 ! rtpbin.recv_rtp_sink_1                                \
         rtpbin. ! rtpamrdepay ! amrnbdec ! alsasink                           \
      udpsrc port=5003 ! rtpbin.recv_rtcp_sink_1                               \
      rtpbin.send_rtcp_src_1 ! udpsink port=5007 sync=false async=false

看看

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

我希望看到一些 UDP 端口打开(5000、5001、5002、5003、5005 和 5007)。果然,跑步netstat节目:

rtsp@rtsp-VirtualBox:~$ sudo netstat -apn | grep -w 500[0-9]
udp        0      0 0.0.0.0:5000            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5001            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5002            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5003            0.0.0.0:*                           7076/gst-launch-1.0 
udp        0      0 0.0.0.0:5005            0.0.0.0:*                           6862/gst-launch-1.0 
udp        0      0 0.0.0.0:5007            0.0.0.0:*                           6862/gst-launch-1.0 

确保所有端口都正常工作

  • 我从 snaprtsp-test-server和 VLC安装
  • 我能够通过rtsp-test-server. 我想这不是一个完美的测试,因为使用的是 TCP 端口而不是 UDP,但它很容易测试,所以我试了一下。

但我没有看到任何视频或听到任何声音。有人可以指出我的错误吗?

gstreamer
  • 1 个回答
  • 518 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve