Capturing audio from HLS stream - works in gui but not when using cmd line (cvlc)
Posted: 03 Mar 2020 05:05
For a number of years I have been using a script on a Windows 10 machine to successfully capture audio from a HLS live stream (BBC radio stream) to a file, however I am struggling to get the same setup working on a new Linux machine which I am putting together. Here is my setup:
Raspberry Pi4 with 4Gb Ram, OS: Ubuntu 19.10 64-Bit, Ubuntu-Mate desktop
VLC version 3.0.8 (installed from Ubuntu Snap store)
At first I tried using the same command as I am using successfully on my Windows machine, this extracts the stream and doesn't perform any transcoding, however this would not work on my Pi
So I tried doing a network stream capture using the gui version of VLC on my Pi. This works!!
Next I enabled logging in the gui, set to 2 (errors) so I could see the sout command which was being used in VLC gui. I made a note of the command:
Note, VLC gui seemed to default to h264 but I also tried ogg and that worked also.
Next I created a bash script which executes cvlc and effectively runs the exact same sout command which I extracted from the gui log:
However this does not work. The mp4 file which gets created is very small (around 150bytes) and has no audio. If I look in the log file there are a number of problems indicated with the following sequence of messages appearing to indicate where it finally gives up:
I wondered if anyone reading this might have any ideas how I can fix this?
Note, I have the full logs from my gui run and scripted runs which I can try uploading if it would be helpful
Raspberry Pi4 with 4Gb Ram, OS: Ubuntu 19.10 64-Bit, Ubuntu-Mate desktop
VLC version 3.0.8 (installed from Ubuntu Snap store)
At first I tried using the same command as I am using successfully on my Windows machine, this extracts the stream and doesn't perform any transcoding, however this would not work on my Pi
So I tried doing a network stream capture using the gui version of VLC on my Pi. This works!!
Next I enabled logging in the gui, set to 2 (errors) so I could see the sout command which was being used in VLC gui. I made a note of the command:
Code: Select all
qt debug: Transcode MRL: sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:std{access=file{no-overwrite},mux=mp4,dst='/home/ubuntu/Desktop/vlc_test_bbc_gui.mp4'}
Next I created a bash script which executes cvlc and effectively runs the exact same sout command which I extracted from the gui log:
Code: Select all
/usr/bin/cvlc http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/nonuk/sbr_low/ak/bbc_radio_two.m3u8 --sout "#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:std{mux=mp4,access=file,dst=/home/ubuntu/Desktop/vlc_test_bbc.mp4} sout-keep" --run-time=60 --play-and-exit --logfile=/home/ubuntu/Desktop/vlc_saturday_test_mp4.log
Code: Select all
main debug: ts warning: Broken stream: pid 34 sends packets with dts 934566us later than pcr, applying delay main debug: selecting program id=0 main debug: looking for packetizer module matching "any": 25 candidates mpeg4audio debug: running MPEG4 audio packetizer mpeg4audio debug: ADTS Mode main debug: using packetizer module "mpeg4audio" main debug: Buffering 0% main debug: EOF reached main debug: Stream buffering done (0 ms in 0 ms) main error: buffer deadlock prevented main debug: Decoder wait done in 0 ms main debug: killing decoder fourcc `mp4a' main debug: removing module "mpeg4audio" main debug: removing module "adaptive" main debug: removing module "ts" main debug: Program doesn't contain anymore ES main debug: removing module "record" main debug: removing module "prefetch" main debug: removing module "access" main debug: dead input main debug: destroying useless sout
Code: Select all
ts warning: Broken stream: pid 34 sends packets with dts 934566us later than pcr, applying delay main debug: selecting program id=0 main debug: looking for packetizer module matching "any": 25 candidates mpeg4audio debug: running MPEG4 audio packetizer mpeg4audio debug: ADTS Mode main debug: using packetizer module "mpeg4audio" main debug: Buffering 0% main debug: Buffering 5% main debug: Buffering 10% main debug: Buffering 15% main debug: Buffering 20% main debug: Buffering 25% main debug: Buffering 30% main debug: Buffering 35% main debug: Buffering 40% main debug: Buffering 45% main debug: Buffering 50% main debug: Buffering 55% main debug: Buffering 60% main debug: Buffering 65% main debug: Buffering 70% main debug: Buffering 75% main debug: Buffering 80% main debug: Buffering 85% main debug: Buffering 90% main debug: Buffering 95% main debug: Buffering 100% main debug: switching to async mode main debug: Stream buffering done (1009 ms in 1 ms) mpeg4audio info: AAC channels: 2 samplerate: 24000 main debug: adding a new sout input for `mp4a` (sout_input: 0xffff38001020) stream_out_transcode debug: creating audio transcoding from fcc=`mp4a' to fcc=`mpga'
I wondered if anyone reading this might have any ideas how I can fix this?
Note, I have the full logs from my gui run and scripted runs which I can try uploading if it would be helpful