0

I'm trying to save X seconds from a audio stream to a file. I have a RTSP server, and I made a simple script in python to save several seconds from this server to record in a file (.wav).

def main():
    ########################### MAIN INIT ###########################

    instance = vlc.Instance("-vvv", "--no-video", "--clock-jitter=0", "--sout-audio", "--sout",
                            "#transcode{acodec=s16l,channels=2}:std{access=file,mux=wav,dst=test.wav}")

    # Create a MediaPlayer with the default instance
    player = instance.media_player_new()

    # Load the media file
    media = instance.media_new("rtsp://XXX.XX.XXX.XX:YYYY/") 

    # Add the media to the player
    player.set_media(media)

    # Play for 10 seconds then exit
    player.play()
    time.sleep(10)


if __name__ == '__main__':
    main()

But when I run the script it creates the file "test.wav" but it's a text plane file instead of wav, what it's I'm waiting for.

Log show me next info:

[00000000022aec08] core input error: ES_OUT_RESET_PCR called
[00007f6704040518] core decoder error: cannot continue streaming due to errors

So I really appreciate someone who can help me. Thank so much.

adder
  • 3,512
  • 1
  • 16
  • 28

1 Answers1

0

Wav files are structured with different fields representing different information as you probably know - see an exmample here from this link (https://github.com/kushalpandya/WavStagno):

enter image description here

It sounds like your output is not formatted correctly - there are tools available to inspect a WAV file which would be a good place to start, or if you are bale to share a link to the file here then people can take a look.

If what you are trying to do is to listen to the stream and save it at the same time, then you likely want to use the duplicate functionality - there is a god example here (albeit video based): https://stackoverflow.com/a/16758988/334402

Mick
  • 24,231
  • 1
  • 54
  • 120