Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 39

Thread: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and JACK

  1. #21
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Awesome, nice tutorial! Thanks pokapeski for clarifying that..

  2. #22
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    By the way, if anyone wants to record to an ogg file, the command is
    Code:
    oggenc -b 192 -o radio.ogg -
    instead of the lame command.

  3. #23
    Join Date
    Feb 2009
    Beans
    115

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    HELP! I followed the guide and have everything installed. But when I try to start JACK it gives me an error. I suppose this has to do with the script that is mentioned to load the module, though I can't find instructions on how to make that script anywhere in the link in the first post. Can someone please post those instructions here? I've never made a script, don't know how to do it....

  4. #24
    Join Date
    Sep 2006
    Beans
    548

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Just make a text file with the following, and make it executable in the file properties.

    Code:
    #!/bin/bash
    
    pactl load-module module-jack-sink channels=2
    pactl load-module module-jack-source channels=2
    The point of the script is to load the jack sink and source for use with pulseaudio when Jack starts. You can execute the 2 commands above in a terminal and it accomplishes the same thing. The point of doing it in a script is so you only load the modules when you start Jack. I know a lot of this seems convoluted at first, but you'll get the hang of it eventually.

  5. #25
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    If anyone cares, I've almost finished writing a script which allows you to record any pulseaudio stream. I've currently got a problem with it not returning the stream back to the correct output device but it does work fully. You just need to manually move it back with pavucontrol or pactl. If anyone wants it, I'll post it here.

  6. #26
    Join Date
    Sep 2006
    Beans
    548

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Quote Originally Posted by durand View Post
    If anyone cares, I've almost finished writing a script which allows you to record any pulseaudio stream. I've currently got a problem with it not returning the stream back to the correct output device but it does work fully. You just need to manually move it back with pavucontrol or pactl. If anyone wants it, I'll post it here.
    Sounds good. Let's have a look!

  7. #27
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Code:
    #!/usr/bin/python
    
    ## This script helps you to record pulseaudio streams
    
    # Filename of the recording
    filename = "recording.ogg"
    # Bitrate of the recording in kbps
    bitrate = 192
    
    import os
    
    # Get a list of pulseaudio objects
    objects = os.popen('pactl list').read().split('\n\n')
    # Form dictionaries containing the details of the 
    # inputs
    streams = {}
    for object in objects:
        if "Sink Input" in object:
            object = object.replace('\t','').split('\n')
            # Get the stream id
            id = object[0].split('#')[-1]
            # Get the stream's name and app to identify it
            for info in object:
                if "media.name" in info:
                    media_name = info.replace('"','').split(' = ')[-1]
                if "application.name" in info:
                    app_name = info.replace('"','').split(' = ')[-1]
            # Add the details to the dictionary
            streams[id] = (app_name,media_name)
    
    # Display the streams and ask the user to choose one to record
    id = 0
    stream_list = streams.keys()
    for stream in stream_list:
        id += 1
        print str(id) + ") " + streams[stream][0] + ": " + streams[stream][1]
    print
    try:
        stream_id = int(raw_input("ID of stream to record: "))
    except:
        stream_id = -1
    while stream_id not in range(1,id+1):
        print stream_id,range(1,id+1)
        try:
            stream_id = int(raw_input("ID of stream to record: "))
        except:
            stream_id = -1
    # Get the PA id of the stream to record
    stream_id = stream_list[stream_id-1]
    # Load a null sink
    print "Loading a null sink..."
    null_id = os.popen('pactl load-module module-null-sink').read()
    
    # Start recorder and get its pid to kill it later. We need to use threads here to background it.
    print "Starting recorder..."
    import threading
    class Recorder(threading.Thread):
        def run(self):
            try:
                os.popen('arecord -f cd -t raw | oggenc -b %s -o %s --raw -'%(bitrate,filename))
            except KeyboardInterrupt:
                print "I'm not quitting!"
    Recorder().start()
    
    # Wait for arecord to load
    import time
    time.sleep(2)
    objects = os.popen('pactl list').read().split('\n\n')
    
    for object in objects:
        # Get name of the null sink
        if "Sink #" in object and "Owner Module: " + null_id in object:
            object = object.replace('\t','').split('\n')
            for info in object:
                if "Name: null" in info:
                    null_name = info.replace('Name: ','')
        # Get recorder id (Assume that it is the last Source Output)
        if "ALSA Capture" in object:
            object = object.replace('\t','').split('\n')
            recorder_id = object[0].split('#')[-1]
    
    # Move stream to null sink
    print "Moving %s to %s..."%(streams[stream_id][1],null_name)
    os.popen('pactl move-sink-input %s %s'%(stream_id,null_name))
    
    # Move recorder to null monitor
    print "Moving recorder to %s..."%null_name
    os.popen('pactl move-source-output %s %s'%(recorder_id,null_name+".monitor"))
    
    print "Stream recording to %s!"%filename
    I'm having a bit of trouble with getting it to close nicely. It's the threading thats causing the problem but I'm completely out of depth there.

    Run it with python file.py

  8. #28
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Oh yea, forgot to mention that you need oggenc installed for that. Its in the vorbis-tools package. If you want to use lame instead, just replace the encoding line in the script.
    Last edited by durand; July 6th, 2009 at 07:27 PM.

  9. #29
    Join Date
    Sep 2006
    Beans
    548

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    That's nice! I'll try it later and let you know what happens.

  10. #30
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Beans
    1,634
    Distro
    Ubuntu Development Release

    Re: HOWTO: Record Internal Audio Mix with gtk-recordmydesktop using PulseAudio and J

    Okay. I'll post on the python mailing list about that error. Hopefully, it will be fixed soon.

Page 3 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •