Score:1

ffmpeg output doesn't have the audio

cu flag

I'm working on a 24/7 music streaming channel. This script should stream the bg.mp4 on loop and play mp3 files from a folder called mp3. Currently streaming the mp4 file on loop works but no audio is played.

Here is my current script:

ffmpeg -loglevel info -y -re \
    -re -stream_loop -1 -i bg.mp4 \
    -f concat -safe 0 -i <((for f in ./mp3/*.mp3; do path="$PWD/$f"; echo "file ${path@Q}"; done) | shuf) \
    -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \
    -framerate 25 -video_size 1280x720 -vf "format=yuv420p" -g 50 -shortest -strict experimental \
    -c:a aac -b:a 128k -ar 44100 \
    -f flv rtmp://a.rtmp.youtube.com/live2/

Running ffmpeg version 4.4.2-0ubuntu0.22.04.1

I'm relatively new to ffmpeg and any hints towards fixing this would be great.

My output logs: https://pastebin.com/aVbsWwgF

========= UPDATE =========

After a while of researching I finally got it working by using map: -map 0:v:0 -map 1:a:0

Final code:

ffmpeg -y -re \
    -re -stream_loop -1 -i bg.mp4 \
    -f concat -safe 0 -i <((for f in ./mp3/*.mp3; do path="$PWD/$f"; echo "file ${path@Q}"; done) | shuf) \
    -c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \
    -framerate 25 -video_size 1280x720 -vf "format=yuv420p" -g 50 -shortest -strict experimental \
    -c:a aac -b:a 128k -ar 44100 -map 0:v:0 -map 1:a:0 \
    -f flv rtmp://a.rtmp.youtube.com/live2/
David avatar
cn flag
Is there a Ubuntu product involved, if so what version?
JonaPoka avatar
cu flag
I'm running Ubuntu 22.04
petep avatar
in flag
Try using gstreamer instead
JonaPoka avatar
cu flag
@peter Why isn't ffmpeg good for this? Could you send any kind of documentation of gstreamer?
pl flag
Hey! This is neat! Can you post the output of a section of ffmpeg while it's running (redacting streaming keys)? We might be able to tell from the (verbose) ffmpeg output what's going on. Please paste a snippet in the question above. Also get rid of the loglevel info, so it's more verbose.
JonaPoka avatar
cu flag
@popey I've added them to the post. I apologize for taking so long.
petep avatar
in flag
gstreamer is likely already inztalled if you using ubuntu. Type "man gst-launch-1.0"
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.