
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (107)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
Sur d’autres sites (11725)
-
How to mix videos from two participants in a video call layout where each video from the participants are not in sync in janus videoroom and ffmpeg ?
5 mars 2024, par Adrien3001I am using janus gateway to implement a video call app using videoroom plugin. If for example there are two participants in the call the recorded mjr files will be 4 (one audio and video mjr for each user). I am using ffmpeg to first convert the audio to opus and the video to webm for each user. I then combine the video with the audio for each user. Finally I want to mix the resulting two webm videos in a video call layout where one video will overlay the other at the bottom right corner and will be a smaller screen (picture in picture mode). The problem is that I noticed sometimes one of the webm video will have a longer duration than the other and the final mp4 video is out of sync. This is the bash script im using for the video processing to the final mp4 video :


#!/bin/bash
set -x # Enable debugging

# Check if the correct number of arguments are provided
if [ "$#" -ne 3 ]; then
 echo "Usage: $0 videoroomid bossid minionid"
 exit 1
fi

videoroomid=$1
bossid=$2
minionid=$3

# Define paths and tools
MJR_DIR="/opt/janus/recordings-folder"
OUTPUT_DIR="/opt/janus/recordings-folder"
JANUS_PP_REC="/usr/bin/janus-pp-rec"
FFMPEG="/usr/bin/ffmpeg"
THUMBNAIL_DIR="/home/adrienubuntu/okok.spassolab-ubuntu.com/okok-recordings-thumbnail"

# Function to convert MJR to WebM (for video) and Opus (for audio)
convert_mjr() {
 local mjr_file=$1
 local output_file=$2
 local type=$(basename "$mjr_file" | cut -d '-' -f 6)

 echo "Attempting to convert file: $mjr_file"

 if [ ! -f "$mjr_file" ]; then
 echo "MJR file not found: $mjr_file"
 return 1
 fi

 if [ "$type" == "audio" ]; then
 # Convert audio to Opus format
 echo "Converting audio to Opus: $mjr_file"
 $JANUS_PP_REC "$mjr_file" "$output_file"
 if [ $? -ne 0 ]; then
 echo "Conversion failed for file: $mjr_file"
 return 1
 fi
 # Check and adjust audio sample rate
 adjust_audio_sample_rate "$output_file"
 elif [ "$type" == "video" ]; then
 # Convert video to WebM format with VP8 video codec
 echo "Converting video to WebM: $mjr_file"
 $JANUS_PP_REC "$mjr_file" "$output_file"
 if [ $? -ne 0 ]; then
 echo "Conversion failed for file: $mjr_file"
 return 1
 fi
 # Check and convert to constant frame rate
 convert_to_constant_frame_rate "$output_file"
 fi

 echo "Conversion successful: $output_file"
 return 0
}

# Function to merge audio (Opus) and video (WebM) files
merge_audio_video() {
 local audio_file=$1
 local video_file=$2
 local merged_file="${video_file%.*}_merged.webm"

 echo "Merging audio and video files into: $merged_file"

 # Merge audio and video
 $FFMPEG -y -i "$video_file" -i "$audio_file" -c:v copy -c:a libopus -map 0:v:0 -map 1:a:0 "$merged_file"

 if [ $? -eq 0 ]; then
 echo "Merging successful: $merged_file"
 return 0
 else
 echo "Error during merging."
 return 1
 fi
}

# Function to check if MJR files exist
check_mjr_files_exist() {
 local videoroomid=$1
 local bossid=$2
 local minionid=$3

 if ! ls ${MJR_DIR}/videoroom-${videoroomid}-user-${bossid}-*-video-*.mjr &>/dev/null ||
 ! ls ${MJR_DIR}/videoroom-${videoroomid}-user-${minionid}-*-video-*.mjr &>/dev/null; then
 echo "Error: MJR files not found for videoroomid: $videoroomid, bossid: $bossid, minionid: $minionid"
 exit 1
 fi
}

# Function to calculate delay
calculate_delay() {
 local video1=$1
 local video2=$2

 # Get the start time of the first video
 local start_time1=$(ffprobe -v error -show_entries format=start_time -of default=noprint_wrappers=1:nokey=1 "$video1")

 # Get the start time of the second video
 local start_time2=$(ffprobe -v error -show_entries format=start_time -of default=noprint_wrappers=1:nokey=1 "$video2")

 # Calculate the delay (in seconds)
 local delay=$(echo "$start_time2 - $start_time1" | bc)

 # If the delay is negative, make it positive
 if [ $(echo "$delay < 0" | bc) -eq 1 ]; then
 delay=$(echo "-1 * $delay" | bc)
 fi

 echo "$delay"
}

# Function to adjust audio sample rate
adjust_audio_sample_rate() {
 local audio_file=$1
 local desired_sample_rate=48000 # Set the desired sample rate

 # Get the current sample rate of the audio file
 local current_sample_rate=$(ffprobe -v error -show_entries stream=sample_rate -of default=noprint_wrappers=1:nokey=1 "$audio_file")

 # Check if the sample rate needs to be adjusted
 if [ "$current_sample_rate" -ne "$desired_sample_rate" ]; then
 echo "Adjusting audio sample rate from $current_sample_rate to $desired_sample_rate"
 local temp_file="${audio_file%.*}_temp.opus"
 $FFMPEG -y -i "$audio_file" -ar "$desired_sample_rate" "$temp_file"
 mv "$temp_file" "$audio_file"
 fi
}

# Function to convert video to a constant frame rate
convert_to_constant_frame_rate() {
 local video_file=$1
 local desired_frame_rate=30 # Set the desired frame rate

 # Check if the video has a variable frame rate
 local has_vfr=$(ffprobe -v error -select_streams v -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 "$video_file")

 if [ "$has_vfr" == "0/0" ]; then
 echo "Video has a variable frame rate. Converting to a constant frame rate of $desired_frame_rate fps."
 local temp_file="${video_file%.*}_temp.webm"
 $FFMPEG -y -i "$video_file" -r "$desired_frame_rate" -c:v libvpx -b:v 1M -c:a copy "$temp_file"
 mv "$temp_file" "$video_file"
 fi
}

# Main processing function
process_videos() {
 # Check if MJR files exist
 check_mjr_files_exist "$videoroomid" "$bossid" "$minionid"

 # Output a message indicating the start of processing
 echo "Processing started for videoroomid: $videoroomid, bossid: $bossid, minionid: $minionid"

 # Process boss's files
 local boss_audio_files=($(ls ${MJR_DIR}/videoroom-${videoroomid}-user-${bossid}-*-audio-*.mjr))
 local boss_video_files=($(ls ${MJR_DIR}/videoroom-${videoroomid}-user-${bossid}-*-video-*.mjr))
 local boss_merged_files=()

 for i in "${!boss_audio_files[@]}"; do
 local audio_file=${boss_audio_files[$i]}
 local video_file=${boss_video_files[$i]}
 convert_mjr "$audio_file" "${audio_file%.*}.opus"
 convert_mjr "$video_file" "${video_file%.*}.webm"
 if merge_audio_video "${audio_file%.*}.opus" "${video_file%.*}.webm"; then
 boss_merged_files+=("${video_file%.*}_merged.webm")
 fi
 done

 # Concatenate boss's merged files
 if [ ${#boss_merged_files[@]} -gt 0 ]; then
 local boss_concat_list=$(mktemp)
 for file in "${boss_merged_files[@]}"; do
 echo "file '$file'" >> "$boss_concat_list"
 done
 $FFMPEG -y -f concat -safe 0 -i "$boss_concat_list" -c copy "${OUTPUT_DIR}/${bossid}_final.webm"
 rm "$boss_concat_list"
 fi

 # Process minion's files
 local minion_audio_files=($(ls ${MJR_DIR}/videoroom-${videoroomid}-user-${minionid}-*-audio-*.mjr))
 local minion_video_files=($(ls ${MJR_DIR}/videoroom-${videoroomid}-user-${minionid}-*-video-*.mjr))
 local minion_merged_files=()

 for i in "${!minion_audio_files[@]}"; do
 local audio_file=${minion_audio_files[$i]}
 local video_file=${minion_video_files[$i]}
 convert_mjr "$audio_file" "${audio_file%.*}.opus"
 convert_mjr "$video_file" "${video_file%.*}.webm"
 if merge_audio_video "${audio_file%.*}.opus" "${video_file%.*}.webm"; then
 minion_merged_files+=("${video_file%.*}_merged.webm")
 fi
 done

 # Concatenate minion's merged files
 if [ ${#minion_merged_files[@]} -gt 0 ]; then
 local minion_concat_list=$(mktemp)
 for file in "${minion_merged_files[@]}"; do
 echo "file '$file'" >> "$minion_concat_list"
 done
 $FFMPEG -y -f concat -safe 0 -i "$minion_concat_list" -c copy "${OUTPUT_DIR}/${minionid}_final.webm"
 rm "$minion_concat_list"
 fi

 if [ -f "${OUTPUT_DIR}/${bossid}_final.webm" ] && [ -f "${OUTPUT_DIR}/${minionid}_final.webm" ]; then
 final_mp4="${OUTPUT_DIR}/final-output-${videoroomid}-${bossid}-${minionid}.mp4"
 echo "Combining boss and minion videos into: $final_mp4"

 # Calculate the delay between the boss and minion videos
 delay=$(calculate_delay "${OUTPUT_DIR}/${bossid}_final.webm" "${OUTPUT_DIR}/${minionid}_final.webm")

 # Convert the delay to milliseconds for the adelay filter
 delay_ms=$(echo "$delay * 1000" | bc)

 $FFMPEG -i "${OUTPUT_DIR}/${bossid}_final.webm" -i "${OUTPUT_DIR}/${minionid}_final.webm" -filter_complex \
 "[0:v]transpose=1,scale=160:-1[boss_clip]; \
 [0:a]volume=2.0[boss_audio]; \
 [1:a]volume=2.0,adelay=${delay_ms}|${delay_ms}[minion_audio]; \
 [1:v][boss_clip]overlay=W-w-10:H-h-10:shortest=0[output]; \
 [boss_audio][minion_audio]amix=inputs=2:duration=longest[audio]" \
 -map "[output]" -map "[audio]" -c:v libx264 -crf 20 -preset veryfast -c:a aac -strict experimental "$final_mp4"

 if [ $? -ne 0 ]; then
 echo "Error combining boss and minion videos"
 exit 1
 else
 echo "Combining boss and minion videos successful"
 # Generate a thumbnail at 5 seconds into the video
 thumbnail="${OUTPUT_DIR}/$(basename "$final_mp4" .mp4).png"
 echo "Generating thumbnail for: $final_mp4"
 $FFMPEG -ss 00:00:05 -i "$final_mp4" -vframes 1 -q:v 2 "$thumbnail"
 echo "Thumbnail generated: $thumbnail"
 sudo mv -f "$thumbnail" "/home/adrienubuntu/okok.spassolab-ubuntu.com/okok-recordings-thumbnail/"

 sudo mv -f "$final_mp4" "/home/adrienubuntu/okok.spassolab-ubuntu.com/okok-live-recordings/"
 rm -f "${OUTPUT_DIR}"/*.opus "${OUTPUT_DIR}"/*.webm "${OUTPUT_DIR}"/*.mp4
 fi
 else
 echo "Error: One or both final videos are missing"
 exit 1
 fi

 # Output a message indicating the end of processing
 echo "Processing completed for videoroomid: $videoroomid, bossid: $bossid, minionid: $minionid"
}

process_videos



I will then test by calling this command ./name-of-file.sh videoroomid bossid minionid. Is there a way to solve this and still keep the whole process in a dynamic way ? Thanks in advance


-
ffmpeg streaming UDP port is closed [closed]
26 décembre 2023, par BrilliantContractI'm trying to use ffmpeg in order to transcode RTSP stream from CCTV to HLS stream so it could be accessed through a web server.


ffmpeg used to stream video from CCTV with following command


$ ffmpeg -i "rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0" -hls_time 3 -hls_wrap 10 -f mpegts udp://localhost:6601
ffmpeg version 4.2.8 Copyright (c) 2000-2022 the FFmpeg developers
 built with gcc 8 (GCC)
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
[rtsp @ 0x5576c7340600] getaddrinfo(cam-1.loc): Name or service not known
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0':
 Metadata:
 title : RTSP Session
 Duration: N/A, start: 0.000000, bitrate: N/A
 Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
 Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
 Stream #0:1 -> #0:1 (pcm_alaw (native) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'udp://localhost:6601':
 Metadata:
 title : RTSP Session
 encoder : Lavf58.29.100
 Stream #0:0: Video: mpeg2video (Main), yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc
 Metadata:
 encoder : Lavc58.54.100 mpeg2video
 Side data:
 cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
 Stream #0:1: Audio: mp2, 16000 Hz, mono, s16, 160 kb/s
 Metadata:
 encoder : Lavc58.54.100 mp2
[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5338.9kbits/s dup=0 drop=5 speed=1.12x 
[rtsp @ 0x5576c7340600] RTP: missed 3 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 6 packets
[h264 @ 0x5576c7993c80] concealing 972 DC, 972 AC, 972 MV errors in I frame
rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0: corrupt decoded frame in stream 0=1.11x 
[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5298.4kbits/s dup=0 drop=5 speed=1.02x 
[rtsp @ 0x5576c7340600] RTP: missed 2 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 3 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 4 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 5 packets
[rtsp @ 0x5576c7340600] max delay reached. need to consume packet
[rtsp @ 0x5576c7340600] RTP: missed 2 packets
[h264 @ 0x5576c779b9c0] cabac decode of qscale diff failed at 66 60
[h264 @ 0x5576c779b9c0] error while decoding MB 66 60, bytestream 9825
[h264 @ 0x5576c779b9c0] concealing 943 DC, 943 AC, 943 MV errors in I frame
rtsp://cam-1.loc:554?user=admin&password=admin&channel=1&stream=0: corrupt decoded frame in stream 0=1.02x 
frame= 1315 fps= 25 q=31.0 Lsize= 34249kB time=00:00:53.32 bitrate=5261.8kbits/s dup=0 drop=5 speed=1.02x 
video:30544kB audio:1042kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.431973%



nmap used to check if 6601 port is open


$ nmap -Pn localhost -p 6601
Starting Nmap 7.70 ( https://nmap.org ) at 2023-12-26 10:47 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0011s latency).
Other addresses for localhost (not scanned): ::1

PORT STATE SERVICE
6601/tcp closed mstmg-sstp

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds



However, ffplayer able to play video stream


ffplay udp://localhost:6601
ffplay version 4.2.8 Copyright (c) 2003-2022 the FFmpeg developers
 built with gcc 8 (GCC)
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
[mpeg2video @ 0x7f1ad854afc0] Invalid frame dimensions 0x0. f=0/0 
 Last message repeated 7 times
Input #0, mpegts, from 'udp://localhost:6601':0KB sq= 0B f=0/0 
 Duration: N/A, start: 59.288000, bitrate: N/A
 Program 1 
 Metadata:
 service_name : RTSP Session
 service_provider: FFmpeg
 Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s



VLC cannot play the video stream :


vlc udp://localhost:6601
VLC media player 3.0.18 Vetinari (revision )
[000055769aa81ba0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[00007fec64011e90] mjpeg demux error: cannot peek



ffprobe output


ffprobe udp://localhost:6601
ffprobe version 4.2.8 Copyright (c) 2007-2022 the FFmpeg developers
 built with gcc 8 (GCC)
 configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' ' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
[mpeg2video @ 0x55e1be0910c0] Invalid frame dimensions 0x0.
 Last message repeated 9 times
Input #0, mpegts, from 'udp://localhost:6601':
 Duration: N/A, start: 262.760000, bitrate: N/A
 Program 1 
 Metadata:
 service_name : RTSP Session
 service_provider: FFmpeg
 Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s



Why the video stream is not playing in VLC ?


Why nmap do not see that UPD port is open ?


-
Discord.py repository example : bot can join voice channel, shows voice activity (green ring), but no sound is produced ?
19 juin 2023, par Jared RobertsonI copied an example from the discord.py repository to test out a bot with music capabilities. Though the code enables YouTube playback, I am only concerned with local audio playback. See code here : https://github.com/Rapptz/discord.py/blob/v2.3.0/examples/basic_voice.py. I tested this code as is with only the Discord token portion updated (from constants.py). See code below :


# This example requires the 'message_content' privileged intent to function.

#my constants.py with API keys, tokens, etc. stored
import constants

import asyncio

import discord
import youtube_dl

from discord.ext import commands

# Suppress noise about console usage from errors
youtube_dl.utils.bug_reports_message = lambda: ''


ytdl_format_options = {
 'format': 'bestaudio/best',
 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
 'restrictfilenames': True,
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': False,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0', # bind to ipv4 since ipv6 addresses cause issues sometimes
}

ffmpeg_options = {
 'options': '-vn',
}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)


class YTDLSource(discord.PCMVolumeTransformer):
 def __init__(self, source, *, data, volume=0.5):
 super().__init__(source, volume)

 self.data = data

 self.title = data.get('title')
 self.url = data.get('url')

 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

 if 'entries' in data:
 # take first item from a playlist
 data = data['entries'][0]

 filename = data['url'] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)


class Music(commands.Cog):
 def __init__(self, bot):
 self.bot = bot

 @commands.command()
 async def join(self, ctx, *, channel: discord.VoiceChannel):
 """Joins a voice channel"""

 if ctx.voice_client is not None:
 return await ctx.voice_client.move_to(channel)

 await channel.connect()

 @commands.command()
 async def play(self, ctx, *, query):
 """Plays a file from the local filesystem"""

 source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
 ctx.voice_client.play(source, after=lambda e: print(f'Player error: {e}') if e else None)

 await ctx.send(f'Now playing: {query}')

 @commands.command()
 async def yt(self, ctx, *, url):
 """Plays from a url (almost anything youtube_dl supports)"""

 async with ctx.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop)
 ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)

 await ctx.send(f'Now playing: {player.title}')

 @commands.command()
 async def stream(self, ctx, *, url):
 """Streams from a url (same as yt, but doesn't predownload)"""

 async with ctx.typing():
 player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
 ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)

 await ctx.send(f'Now playing: {player.title}')

 @commands.command()
 async def volume(self, ctx, volume: int):
 """Changes the player's volume"""

 if ctx.voice_client is None:
 return await ctx.send("Not connected to a voice channel.")

 ctx.voice_client.source.volume = volume / 100
 await ctx.send(f"Changed volume to {volume}%")

 @commands.command()
 async def stop(self, ctx):
 """Stops and disconnects the bot from voice"""

 await ctx.voice_client.disconnect()

 @play.before_invoke
 @yt.before_invoke
 @stream.before_invoke
 async def ensure_voice(self, ctx):
 if ctx.voice_client is None:
 if ctx.author.voice:
 await ctx.author.voice.channel.connect()
 else:
 await ctx.send("You are not connected to a voice channel.")
 raise commands.CommandError("Author not connected to a voice channel.")
 elif ctx.voice_client.is_playing():
 ctx.voice_client.stop()


intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(
 command_prefix=commands.when_mentioned_or("!"),
 description='Relatively simple music bot example',
 intents=intents,
)


@bot.event
async def on_ready():
 print(f'Logged in as {bot.user} (ID: {bot.user.id})')
 print('------')


async def main():
 async with bot:
 await bot.add_cog(Music(bot))
 #referenced my discord token in constants.py
 await bot.start(constants.discord_token)


asyncio.run(main())



This code should cause the Discord bot to join the voice channel and play a local audio file when the message " !play query" is entered into the Discord text channel, with query in my case being "test.mp3." When " !play test.mp3" is entered, the bot does join the voice channel and appears to generate voice activity, however no sound is heard. No errors are thrown in the output. The bot simply continues on silently.


Here's what I've checked and tried :


- 

-
I am in the Discord voice channel. The code will alert that user is not in the voice channel if a user attempts to summon the bot without being in a voice channel.


-
FFmpeg is installed and added to PATH. I even stored a copy of the .exe in the project folder.


-
I've tried specifying the full path of both FFmpeg (adding the "executable=" arg to the play function) and the audio file (stored at C :/test.mp3 and a copy in the project folder).


-
All libraries up to date.


-
Reviewed discord.py docs (https://discordpy.readthedocs.io/en/stable/api.html#voice-related) and played around with opuslib (docs say not necessary on Windows, which I'm on) and FFmpegOpusAudio, but results were the same.


-
Referenced numerous StackOverflow threads, including every one suggested when I typed the title of this post. Tried each suggestion individually and in various combinations when possible. See a few below :
Discord.py music_cog, bot joins channel but plays no sound
Discord.py Music Bot doesn’t play music
Discord.py Bot Not Playing music


-
Double checked my sound is on and volume turned up. My sound is working I can hear the Discord notification when the bot joins the voice channel.


-
Issue is the same if I try to play a YouTube file with !yt command. Bot joins channel fine but no sound is produced.




















That's everything I can think of at the moment. There seem to be many posts regarding this exact topic and also variations of it. I've been unable to find a clear and consistent answer, nor one the works for me. I am willing to try anything at this point as it is obviously possible, but for whatever reason success eludes me. Thank you in advance for any assistance you are willing to offer.


-