Stdout to memory python - vlc

I wanted to stream the raspivid using VLC. So I followed the below link
raspivid -o - -t 9999999 -w 1280 -h 1024 -b 500000 -fps 20|cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8080/}' :demux=h264
Now I wanted to record the streamed result in vlc with
cvlc -vvv stream:///rtsp://0.0.0.0:8554/}' --sout=file/ps:record.mpg
Am I doing it right? Alternative approach/methods appreciated.

Related

how to only print Lua output with tshark

I am using a Lua script with tshark and when I run it with -V I get the protocol decode output. When I try anything else to limit output to just the Lua decoded data I am not having any luck. i.e.
tshark -X lua_script:my.lua -r input.pcap.gz -w output.pcap -O "my lua protocol" or tshark -X lua_script:my.lua -r input.pcap.gz -w output.pcap -O "my lua protocol" -V
even when I try -O udp -V I do not get the protocol output.
Any ideas?

Stream multiple docker container audio

I want to run multiple docker containers on a machine and stream the audio via RTP. I can run apps with sound with this command:
sudo docker run -it \
--device /dev/snd \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/root/.config/pulse/cookie \
--group-add $(getent group audio | cut -d: -f3) \
ubuntu:16.04 /bin/bash
It works fine and when i play any sound in the container it plays and i can hear it and i can stream it with FFmpeg. The problem is when i run multiple containers and play any sound from any container, it seems they are using the same sink in pulseaudio server so i can't separate them and each stream client hear all the sounds from all the running containers. How can i achieve my goal?
My FFmpeg Stream code:
ffmpeg -f alsa -i pulse -acodec libmp3lame -ab 128k -ac 2 -ar 48000 -c:a libopus -f rtp rtp://$IP:4001
Untested, but it looks as if you are using alsa instead of pulse, and also using two codecs (-acodec and -a:c are the same)
Can you try:
ffmpeg -f pulse -i default -ab 128k -ac 2 -c:a libopus -f rtp rtp://$IP:400
Also, if you're trying to run pulse audio inside a docker container, you might need to start the pulseaudio daemon:
# your docker apt-get:
apt-get install -y pulseaudio
# your entrypoint/command script:
pulseaudio &
# or, if using root (dont)
pulseaudio --system &

How to capture MQTT data locally in SSH remote server using Wireshark?

I want to capture MQTT packets on the SSH Linux-based remote server using Wireshark from my home. I can capture data go out through the Internet, such as when I use this command line mosquitto_pub -h test.mosquitto.org -t topic -m "Hello", I can see the packets in Wireshark. But, When I publish data in localhost, such as using this command mosquitto_pub -d -h localhost -t hello/world -m "75" I can't see any packets in Wireshark. I want to make a client/server in the same remote server.
I use this command to open Wireshark:
sudo ssh user#x.x.x.x tcpdump -U -s0 -w - | wireshark -k -i -
I know only a basic thing in Wireshark, so please how I solve this?
You didn't specify the interface that tcpdump should capture on. Try adding the -i lo option, as in:
sudo ssh user#x.x.x.x tcpdump -i lo -U -s0 -w - | wireshark -k -i -

Why UDP port fails only in Docker?

I've got the following docker that streams out some sample sine wav via UDP port 1234:
from ubuntu
RUN apt update
RUN apt install -y ffmpeg
EXPOSE 1234/udp
CMD ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://localhost:1234
I run the container using:
docker run -p 127.0.0.1:1234:1234/udp xxxx
Now I try to open VLC and play that stream from my host machine using the stream URL rtp://#:1234 as instructed by VLC. It plays nothing. Silence. However, if I run the same ffmpeg cmd from the host machine, it works and I can hear the sample.
Any ideas what's going on?
Found the problem. I guess I misunderstood RTP. ffmpeg is expected to send the RTP packets to a "server" (peer, actually) outside the container (i.e. my host machine). It was not "serving" the sample audio like an RTSP server...
So I don't need to expose any ports. The problem was the rtp url on the container side - it should target the host machine's IP:
ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://$HOST_MACHINE_IP:1234
And its the VLC app that is actually the peer. Once I do it, VLC can receive the stream - no problem.

How to hide data displayed on the terminal while executing tshark?

I need to hide data that is displayed while executing tshark command line for wireshark:
tshark -i tun0 -T ek -w /home/PCAP_Folder/Sim_Run1st.pcap
I am running two program simultaneously
The following will send the output to /dev/null:
tshark -i tun0 -T ek -w /home/PCAP_Folder/Sim_Run1st.pcap > /dev/null
If you also want to hide any error message:
tshark -i tun0 -T ek -w /home/PCAP_Folder/Sim_Run1st.pcap &> /dev/null
Note that if you also hide the error messages, the -T ek option becomes pointless.

Resources