0

I am recording incoming stream to mp3 file into 20 seconds parts in sender device. After that i am uploading this files to Google Drive(using RCLONE). Then i am downloading this files to receiver device. I am waiting about a while time (buffering) in the receiver side. Then i start to play this file using VLC-player from command line and listening this song. Having a problem when skipping to another m3 file in media-player occurring an silence about 0.1 seconds. I tried to concatenate those mp3 files into one file, but same problem had occurred again.

How can i handle this problem ?

Here is the part of code;

def Sound(self):
    t1=threading.Thread(target=self.read_playlist)  # update playlist file continuously
    t1.start()
    vlc_instance = vlc.Instance() 
    player = vlc_instance.media_player_new()
    i=0
    while 1:           
        media = vlc_instance.media_new(self.playlist[i].strip())
        player.set_media(media)
        duration=self.len_mp3(self.playlist[i].strip())
        player.play()
        time.sleep(duration)
        i=i+1
Veysel Olgun
  • 552
  • 1
  • 3
  • 15
  • There is inherent delay in this whole process. Frankly, I'm surprised you got the skip to be down to 0.1 seconds. :-) VLC in particular cannot seamlessly play from one track to the next. I'm not sure entirely what you're trying to do, but I'd recommend revisiting this entire stack. – Brad Dec 24 '20 at 06:23
  • Actually it is noticeable when media-player changed to another mp3, but delay time can be less or more 0.1 seconds. My purpose is to do Live Broadcasting with some delay(2-3 minutes) because when internet goes down for between 0-2 minutes, broadcasting should not be stop. That's why, firstly i am uploading mp3 files to drive then i am downloading this files to broadcast device and waiting for 2-3 minutes(buffering). Then i am starting to broadcast. – Veysel Olgun Dec 24 '20 at 07:19
  • Have you considered simply using HLS with a significant buffer size? VLC can play that directly. – Brad Dec 24 '20 at 07:26
  • I have no info about HLS, but i am searching it now – Veysel Olgun Dec 24 '20 at 08:01

1 Answers1

0

Mr. Brad, i am so late for feedback sorry about that. Problem solved with your advice, here what i do:

First i am creating an HLS segment with this command;

ffmpeg -f alsa -i plughw:1,0 -c:a libmp3lame -f segment -strftime 1 -segment_time 1 -segment_format mpegts path/%Y%m%d%H%M%S.ts 

This creates a ".ts" files which is the length of 1 second according to timestamp

In the receiver side, i am downloading this ".ts" files to my device. While downloading these ".ts" files, i am waiting to create a ".m3u8" file for example let's say, buffer time is 3 minutes, then i am starting the download process and waiting for 3 minutes to create ".m3u8" file. After 3 minutes, i am starting to create ".m3u8" file manually and i am starting mpv-player(python interface) to play the ".m3u8" file. I am updating ".m3u8" file every one second in the receiver side

Veysel Olgun
  • 552
  • 1
  • 3
  • 15