0

Good afternoon

I have the following code in python. The problem I have is that in the end I can't generate the flac file. I don't know what mistake I am making. Could you help me. I have installed vlc 3.0.8 and python-vlc.Thank you

import time
import vlc

def grabar_audio():
    convertidor = "--sout=#transcode{acodec=flac,ab=320,channels=1,samplerate=16000}:std{access=file,mux=raw,dst='/home/eparionad/Descargas/audio.flac'} --run-time=40 --stop-time=40"
    instancia = vlc.Instance(convertidor)
    reproductor = instancia.media_player_new()
    medios = instancia.media_new('http://198.15.86.218:9386/stream')
    medios.get_mrl()
    reproductor.set_media(medios)
    reproductor.play()
    time.sleep(40)

    return medios

grabar_audio()

1 Answers1

0

At any line of code you are creating a file, you are just opening it and saving in the runtime buffer.

In a quick look on vlc instance documentation, i've found two possible functions that you should use:

media_new_path(self, path)

Create a media for a certain file path. source code

media_new_fd(self, fd)

Create a media for an already open file descriptor.

Roni Antonio
  • 1,334
  • 1
  • 6
  • 11