streammp3playbackpython-vlc

Delay occouring when skipping to another mp3


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

Solution

  • 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