### Liquidsoap Installation Guide Source: https://liquidsoap.readthedocs.io/en/stable/index Provides instructions for installing Liquidsoap on various platforms. It covers installation via package managers like OPAM, system packages (Debian/Ubuntu), and building from source. ```shell # Install using OPAM opam install liquidsoap # Install on Debian/Ubuntu sudo apt-get update && sudo apt-get install liquidsoap # Install from source # (Refer to the official documentation for detailed steps) ``` -------------------------------- ### Install Liquidsoap from Source Source: https://liquidsoap.readthedocs.io/en/stable/content/install This guide covers compiling and installing Liquidsoap directly from its source code. It typically involves downloading the source, configuring, compiling, and installing. ```shell # Download the source code # tar xzf liquidsoap-X.Y.Z.tar.gz # cd liquidsoap-X.Y.Z # Configure the build # ./configure # Compile the source code # make # Install Liquidsoap # sudo make install ``` -------------------------------- ### Liquidsoap Configuration and Customization Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Covers Liquidsoap configuration variables, adding the liquidsoap binary to your system, and setting up custom paths. This section also includes a full example demonstrating a complete Liquidsoap setup. ```liquidsoap # Configuration variables # Adding liquidsoap binary # Custom paths # Full example ``` -------------------------------- ### Liquidsoap Directory Structure Example Source: https://liquidsoap.readthedocs.io/en/stable/content/custom-path Illustrates the typical file and directory layout for a Liquidsoap installation, including executable scripts, libraries, and configuration files. ```bash ./bin ./bin/liquidsoap ./camomile ./camomile/charmaps (...) ./ld ./ld/libao.so.2 (...) ./libs ./libs/externals.liq (...) ./log ./magic ./magic/magic.mime ./plugins ./run ``` -------------------------------- ### Liquidsoap Cookbook Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/faq A collection of practical examples and recipes for common Liquidsoap tasks, demonstrating various functionalities. ```liquidsoap # Example: Simple radio automation radio = playlist("playlist.m3u") output.dummy(radio) ``` -------------------------------- ### Liquidsoap Installation and Dependencies Source: https://liquidsoap.readthedocs.io/en/stable/content/build Details on installing Liquidsoap, including mandatory, recommended, optional, and runtime optional dependencies. It also covers installation via the configure script. ```liquidsoap # Mandatory dependencies: # Recommended dependencies: # Optional dependencies: # Runtime optional dependencies: # Installing via configure ``` -------------------------------- ### Install OCaml and Liquidsoap with OPAM Source: https://liquidsoap.readthedocs.io/en/stable/content/install This snippet demonstrates the recommended installation of Liquidsoap using OPAM. It includes creating an OCaml switch, installing external dependencies, and then installing Liquidsoap and its core dependencies. It also shows how to install optional dependencies like Opus. ```bash opam switch create 4.08.0 opam depext taglib mad lame vorbis cry samplerate liquidsoap opam install taglib mad lame vorbis cry samplerate liquidsoap opam depext opus opam install opus ``` -------------------------------- ### Liquidsoap Cookbook Examples Source: https://liquidsoap.readthedocs.io/en/stable/index A collection of practical examples from the Liquidsoap cookbook, demonstrating file operations, transcoding, scheduling, handling special events, server interaction, and stream dumping. ```liquidsoap # Files # Transcoding # Re-encoding a file # Scheduling # Force a file/playlist to be played at least every XX minutes # Handle special events: mix or switch # Unix interface, dynamic requests # Dynamic input with harbor # Adding new commands # Dump a stream into segmented files # Manually dump a stream # Transitions # Alsa unbuffered output ``` -------------------------------- ### Dynamic Playlist Creation and Management Source: https://liquidsoap.readthedocs.io/en/stable/content/dynamic_sources This example demonstrates how to dynamically create and destroy playlist sources in Liquidsoap. It registers telnet commands to start and stop playlists, allowing for runtime control of audio streams and their outputs. The code utilizes functional programming concepts for intricate logic and includes comments for clarity. It suggests using `output.dummy(blank())` if no other output is configured and mentions adapting the approach to integrate with existing outputs via `input.harbor`. ```liquidsoap dynamic_playlist.start - Creates a new playlist source using the provided URI and outputs it to a fixed icecast output. dynamic_playlist.stop - Destroys the playlist source associated with the given URI. ``` -------------------------------- ### Liquidsoap Cookbook Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/cookbook A collection of practical examples demonstrating various functionalities in Liquidsoap, such as file handling, transcoding, scheduling, event handling, and stream manipulation. ```liquidsoap # Force a file/playlist to be played at least every XX minutes # Example: Ensure 'my_track.mp3' plays at least once every 30 minutes playlist("my_track.mp3").schedule(30*60) ``` ```liquidsoap # Handle special events: mix or switch # Example: Mix in a jingle when a specific event occurs request.event("play_jingle").connect(playlist("jingle.mp3")) ``` ```liquidsoap # Unix interface, dynamic requests # Example: Expose a playlist via a Unix socket for dynamic control server.tcpin("localhost", 8080).mount("/playlist") ``` ```liquidsoap # Dynamic input with harbor # Example: Connect to a remote stream using harbor input.harbor("http://example.com/stream") ``` ```liquidsoap # Adding new commands # Example: Define a custom command to toggle a specific output command.add("toggle_output", function() { output.dummy.toggle() }) ``` ```liquidsoap # Dump a stream into segmented files # Example: Save a stream to hourly segmented files output.file("%Y-%m-%d-%H.mp3", stream.segment(3600)) ``` ```liquidsoap # Manually dump a stream # Example: Manually trigger a dump of the current stream to a file request.event("dump_now").connect(output.file("manual_dump.mp3")) ``` ```liquidsoap # Switch-based transitions # Example: Smoothly switch between two playlists playlist("playlist1.m3u").transition(playlist("playlist2.m3u")) ``` ```liquidsoap # Cross-based transitions # Example: Crossfade between two streams stream.crossfade(playlist("stream1.mp3"), playlist("stream2.mp3")) ``` ```liquidsoap # Alsa unbuffered output # Example: Output audio to ALSA device with minimal buffering output.alsa(device="hw:0,0", buffer_size=0) ``` -------------------------------- ### Liquidsoap Example: Complex Case Analysis Source: https://liquidsoap.readthedocs.io/en/stable/content/complete_case This example demonstrates a complex Liquidsoap script scenario. It includes playing different playlists throughout the day, handling user requests via the telnet server, inserting jingles between songs and at the start of each hour, relaying live shows, and setting up multiple outputs to Icecast in different formats. The explanation emphasizes a modular approach to script design and provides guidance on testing and modifying the example. ```liquidsoap # This is a conceptual example and requires specific configuration for file names and intervals. # The actual script would involve defining playlists, request handling, jingle insertion logic, # live stream relay, and output configurations. # Example structure (not runnable as-is): # Define playlists for different times of the day playlist_morning = playlist("morning.m3u") playlist_afternoon = playlist("afternoon.m3u") playlist_evening = playlist("evening.m3u") # Define jingles jingle_normal = sound("jingle_normal.ogg") jingle_hourly = sound("jingle_hourly.ogg") # Define live show source stream_live = input.http("http://your-live-stream.com/live.ogg") # Define outputs out_icecast1 = output.icecast(%mp3, host="localhost", port=8000, password="hackme", mount="/stream1") out_icecast2 = output.icecast(%aac, host="localhost", port=8000, password="hackme", mount="/stream2") # Main logic combining sources and outputs # This would involve switch, crossfade, and other operators to manage the streams # For example, switching playlists based on time: # when time("06:00") do playlist_morning end # when time("12:00") do playlist_afternoon end # when time("18:00") do playlist_evening end # Inserting jingles: # add_hook(after_song=function(song) { # if random() < 0.2 then jingle_normal else null # }) # Mixing hourly jingle: # add_hook(at_hour=function() { # crossfade(jingle_hourly, main_stream, duration=10) # }) # Relaying live shows: # when is_available(stream_live) do stream_live end # Connect sources to outputs # connect(main_stream, out_icecast1) # connect(main_stream, out_icecast2) # Example of starting a live show from soundcard input (requires ALSA setup): # input.alsa(device="hw:0,0") ``` -------------------------------- ### Liquidsoap Custom Path Source: https://liquidsoap.readthedocs.io/en/stable/content/clocks This section explains how to manage Liquidsoap's custom path, including adding the Liquidsoap binary to the system's PATH and understanding how configuration files are loaded. It also provides a full example of a custom path setup. ```liquidsoap # Example: Adding a custom plugin directory add_path("plugins", "/usr/local/lib/liquidsoap/plugins") ``` -------------------------------- ### Liquidsoap Installation Source: https://liquidsoap.readthedocs.io/en/stable/content/install Instructions for installing Liquidsoap on different operating systems, including using OPAM, Debian/Ubuntu packages, Windows, and compiling from source. ```bash # Install using OPAM opam install liquidsoap # Install on Debian/Ubuntu sudo apt-get update && sudo apt-get install liquidsoap # Installing from source # git clone git://github.com/savonet/liquidsoap.git # cd liquidsoap # ./autogen.sh # ./configure # make # sudo make install # Latest development version # git clone git://github.com/savonet/liquidsoap.git # cd liquidsoap # ./autogen.sh # ./configure --enable-dev-mode # make # sudo make install ``` -------------------------------- ### Installing Liquidsoap from Source Source: https://liquidsoap.readthedocs.io/en/stable/content/build Instructions for installing Liquidsoap from source using the configure script. This method is intended for system administrators or package maintainers. ```bash # Configure script for manual installation ./configure make sudo make install ``` -------------------------------- ### Liquidsoap Harbor Usage Example Source: https://liquidsoap.readthedocs.io/en/stable/content/harbor An example of how to define a Harbor source in Liquidsoap. It shows setting up the source with a specific mountpoint and implies the need for MP3 decoding support if using Shoutcast clients. ```liquidsoap input.harbor("mountpoint") ``` -------------------------------- ### HLS Output Configuration Example Source: https://liquidsoap.readthedocs.io/en/stable/content/hls_output Example configuration for sending streams as HLS output using `output.file.hls`. This demonstrates setting up encoded streams, stream information for playlists, and persistence options. ```liquidsoap set("log.file.level", "debug") set("log.stdout.level", "debug") # Define the streams to be encoded streams = [ ("stream1", "%ffmpeg") ] # Define stream information for HLS playlists streams_info = [ ("stream1", (128000, "aac", "ts")) ] # Configure HLS output output.file.hls( "/mnt/stream/hls/", streams=streams, streams_info=streams_info, persist=true, persist_at="/mnt/stream/hls/persist", segments=5, segments_overhead=2 ) ``` -------------------------------- ### Installing Liquidsoap with opam Source: https://liquidsoap.readthedocs.io/en/stable/content/build Recommends using the opam package manager for installing Liquidsoap. Opam handles OCaml compiler, modules, and system dependencies. ```bash # Recommended installation method using opam opam install liquidsoap ``` -------------------------------- ### Liquidsoap Advanced Techniques and Cookbook Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Provides insights into advanced Liquidsoap techniques, including smart crossfading and a collection of practical examples in the cookbook. This section is useful for users looking to optimize their audio streaming setups. ```liquidsoap # Smart crossfade # Cookbook examples ``` -------------------------------- ### Install Liquidsoap using OPAM Source: https://liquidsoap.readthedocs.io/en/stable/content/install This section details the recommended method for installing Liquidsoap using the OPAM package manager. It assumes OPAM is already set up. ```shell opam install liquidsoap ``` -------------------------------- ### Liquidsoap Configuration and Custom Paths Source: https://liquidsoap.readthedocs.io/en/stable/content/build Information on configuring Liquidsoap, including adding the Liquidsoap binary to the path and understanding configuration variables. A full example is provided. ```liquidsoap # Adding liquidsoap binary # Configuration variables # Full example ``` -------------------------------- ### Liquidsoap Command-Line Tools for Settings and Plugins Source: https://liquidsoap.readthedocs.io/en/stable/content/help Provides examples of using the `liquidsoap` command-line interface to inspect configuration settings and list available plugins. These commands help in understanding and managing Liquidsoap's features. ```bash liquidsoap --conf-descr liquidsoap --conf-descr-key server liquidsoap --list-plugins liquidsoap --list-plugins-xml ``` -------------------------------- ### Liquidsoap Cue Point Example Source: https://liquidsoap.readthedocs.io/en/stable/content/seek This example demonstrates how to use the `cue_cut` operator to set cue-in at 10 seconds and cue-out at 45 seconds for a source. ```liquidsoap set( "cue_in_metadata", "liq_cue_in", "cue_out_metadata", "liq_cue_out" ) my_source = cue_cut(my_source) ``` -------------------------------- ### Configure and Build Liquidsoap Source: https://liquidsoap.readthedocs.io/en/stable/content/build This snippet shows the basic steps to configure, build, and install Liquidsoap. It includes options for specifying the user and group for daemon operation and mentions the INSTALL_DAEMON variable for package preparation. ```bash % ./configure % make % make install ``` ```bash % ./configure --with-user= --with-group= % make % make install ``` ```bash INSTALL_DAEMON="yes" % make install ``` -------------------------------- ### Install Liquidsoap from Debian/Ubuntu Repository Source: https://liquidsoap.readthedocs.io/en/stable/content/install This snippet shows how to install a specific version of Liquidsoap from the added repository on Debian/Ubuntu systems. It demonstrates how to list available packages and install a package, such as the latest master branch. ```bash apt-cache show liquidsoap [sudo] apt-get install liquidsoap-master ``` -------------------------------- ### Liquidsoap Protocol Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/requests Demonstrates the usage of various supported protocols in Liquidsoap for fetching media and synthesizing speech, including custom metadata annotation. ```liquidsoap say:I am a robot time: It is exactly $(time), and you're still listening. annotate:nick="alice",message="for bob":/some/track/uri ``` -------------------------------- ### Pin Liquidsoap from Source using OPAM Source: https://liquidsoap.readthedocs.io/en/stable/content/install This code block shows how to install Liquidsoap by pinning a local source repository using OPAM. This is useful for development or testing specific versions. ```bash git clone https://github.com/savonet/liquidsoap.git cd liquidsoap opam pin add liquidsoap . ``` -------------------------------- ### Install Liquidsoap on Debian/Ubuntu Source: https://liquidsoap.readthedocs.io/en/stable/content/install Instructions for installing Liquidsoap on Debian-based systems like Ubuntu using the system's package manager. ```shell sudo apt-get update sudo apt-get install liquidsoap ``` -------------------------------- ### Liquidsoap Source Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/quick_start Illustrates different ways to define audio sources in Liquidsoap, including HTTP streams, local files, and soundcards. It highlights the fallible nature of sources and how to handle potential errors. ```liquidsoap # HTTP Stream Source http_source = input.http("http://stream.example.com/music.mp3") # Local File Source file_source = input.file("/path/to/your/music.ogg") # Soundcard Input (requires configuration) soundcard_source = input.soundcard() # Example of a fallible source fallible_source = fallback(sources=[http_source, file_source]) # Using a source in a playlist my_playlist = playlist([fallible_source]) # Output the playlist output.dummy(my_playlist) ``` -------------------------------- ### GStreamer Encoder Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/gstreamer_encoder Provides basic examples for using the GStreamer encoder in Liquidsoap, including content type inference and metadata handling. It also mentions caveats related to its usage. ```liquidsoap # Basic GStreamer encoding example set_encoder(encoder_gstreamer(bitrate=128, samplerate=44100, channels=2, "audio/mpeg")) # Example with metadata set_encoder(encoder_gstreamer(bitrate=128, samplerate=44100, channels=2, "audio/mpeg", metadata=true)) # Content type inference example set_encoder(encoder_gstreamer(bitrate=128, samplerate=44100, channels=2, "audio/x-raw", "audio/mpeg")) ``` -------------------------------- ### Install Latest Development Version Source: https://liquidsoap.readthedocs.io/en/stable/content/install Information on how to obtain and install the most recent development version of Liquidsoap, often from a version control system like Git. ```shell # Clone the Git repository # git clone https://github.com/savonet/liquidsoap.git # cd liquidsoap # Follow build instructions as for installing from source ``` -------------------------------- ### Example: FFmpeg for Video Encoding Source: https://liquidsoap.readthedocs.io/en/stable/content/external_encoders An example of using FFmpeg with LiquidSoap's external encoder functionality to generate a compressed AVI file. ```bash ffmpeg -i - -f avi "compressed.avi" ``` -------------------------------- ### Liquidsoap Configuration Variables Example Source: https://liquidsoap.readthedocs.io/en/stable/content/custom-path Demonstrates how to set environment variables to configure Liquidsoap's behavior, such as library paths, base directory, and magic file locations. ```bash LD_LIBRARY_PATH=/path/to/ld LIQUIDSOAP_BASE_DIR=.. MAGIC=../magic/magic.mime ``` -------------------------------- ### List and Describe LADSPA Plugins Source: https://liquidsoap.readthedocs.io/en/stable/content/ladspa This section details how to interact with LADSPA plugins from the command line. It explains how to list all available plugins and how to get specific details about a single plugin. ```bash liquidsoap --list-plugins liquidsoap -h ladspa.plugin ``` -------------------------------- ### Example Query Transformation Source: https://liquidsoap.readthedocs.io/en/stable/content/bubble Illustrates how an IRC bot might transform a user's song request into a Liquidsoap-compatible Bubble URI. This example shows the process of taking a natural language query and converting it into a structured URI that Liquidsoap can understand and process. ```liquidsoap bubble:title="Alabama song" ``` -------------------------------- ### Liquidsoap Request Resolution Example Source: https://liquidsoap.readthedocs.io/en/stable/content/requests Illustrates a complex recursive resolution process with backtracking for media requests in Liquidsoap, showing how URIs are transformed and resolved to local files. ```liquidsoap * bubble:artist="bodom" * ftp://no/where * Error * ftp://some/valid.ogg * /tmp/success.ogg ``` -------------------------------- ### Liquidsoap init.d Service Script Source: https://liquidsoap.readthedocs.io/en/stable/content/advanced This section explains the usage of the `init.d/liquidsoap` service script for managing Liquidsoap instances in a production environment. It covers starting, stopping, and restarting the service. ```bash # Example: Managing the Liquidsoap service using init.d script # sudo /etc/init.d/liquidsoap start # sudo /etc.init.d/liquidsoap stop # sudo /etc/init.d/liquidsoap restart ``` -------------------------------- ### Ogg Container Syntax Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Demonstrates the syntax for combining audio formats within an Ogg container using Liquidsoap. It shows the general %ogg(x,y,z) syntax and a specific example for Vorbis. ```liquidsoap %ogg(x,y,z) %vorbis(...) ``` -------------------------------- ### Liquidsoap Configuration Variables Source: https://liquidsoap.readthedocs.io/en/stable/content/install Details on how to set and manage configuration variables within Liquidsoap, including examples of adding custom paths and defining variables. ```liquidsoap # Example of setting a configuration variable set("log.file.path", "/var/log/liquidsoap/liquidsoap.log") # Example of adding a custom path for plugins or scripts add_path("script.dir", "/path/to/my/scripts") # Example of a full configuration file structure # startup_script = "/etc/liquidsoap/startup.liq" # log.file.path = "/var/log/liquidsoap/liquidsoap.log" # log.stdout = true # log.stderr = true # log.level = 5 # Example of defining a variable my_variable = "hello world" output(my_variable) ``` -------------------------------- ### Harbor HTTP Server Configuration Source: https://liquidsoap.readthedocs.io/en/stable/content/gstreamer_encoder Demonstrates how to configure Liquidsoap to act as an HTTP server using the Harbor protocol. It includes basic setup and mentions limitations. ```liquidsoap # Basic Harbor HTTP server configuration set_harbor(port=8000, "/stream") # Harbor with specific mount point set_harbor(port=8000, "/radio") # Harbor with custom mount point and protocol set_harbor(port=8000, "/live.mp3", "audio/mpeg") ``` -------------------------------- ### Liquidsoap Harbor HTTP Server Source: https://liquidsoap.readthedocs.io/en/stable/content/metadata Details the configuration and usage of Harbor as an HTTP server within Liquidsoap, including limitations and specific setup instructions. ```liquidsoap # Configure Harbor as an HTTP server harbor.http.bind("0.0.0.0", 8080) harbor.http.mount("/", liquidsoap.default_source) # Example of a limitation (e.g., max connections) harbor.http.set("max_connections", 100) ``` -------------------------------- ### GStreamer Encoder Basic Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/gstreamer_encoder Demonstrates basic configurations for GStreamer encoders with different media types (MP3, x264, MPEG TS, ogg/vorbis+theora). It also shows how to override the entire pipeline using the 'pipeline' argument. ```liquidsoap % liquidsoap 'output.file(%gstreamer(pipeline="appsrc name=\"audio_src\" block=true caps=\"audio/x-raw,format=S16LE,layout=interleaved, channels=1,rate=44100\" format=time ! lamemp3enc ! appsink name=sink sync=false emit-signals=true",channels=1,log=3),...)' ``` -------------------------------- ### Liquidsoap Server Commands for Request Monitoring Source: https://liquidsoap.readthedocs.io/en/stable/content/requests Provides examples of Liquidsoap server commands used to trace, monitor, and retrieve information about media requests, including their resolution process and metadata. ```APIDOC request.trace - Shows a log of the resolution process for a request. request.metadata - Shows the current metadata of a request. request.all - Returns the list of all requests. request.alive - Returns the list of currently alive requests. request.resolving - Returns the list of currently resolving requests. request.on_air - Returns the list of currently playing requests. ``` -------------------------------- ### Harbor HTTP Input Configuration Source: https://liquidsoap.readthedocs.io/en/stable/content/harbor_http This section details the configuration options for the Harbor HTTP input in Liquidsoap. It covers redirecting Icecast pages, getting and setting metadata, and limitations of the Harbor HTTP input. ```liquidsoap ## Harbor HTTP Input ### Redirect Icecast’s pages This allows redirecting Icecast's pages to a custom URL. ### Get metadata This describes how to retrieve metadata from the Harbor HTTP input. ### Set metadata This describes how to set metadata for the Harbor HTTP input. ### Limitations This section outlines the limitations of the Harbor HTTP input. ``` -------------------------------- ### Custom Protocol Example: Cue Cut and Normalization Source: https://liquidsoap.readthedocs.io/en/stable/content/advanced Illustrates a custom Liquidsoap protocol that cuts a specific segment from an audio file and applies normalization. The protocol string specifies the cut duration and start time, followed by the normalization command. ```liquidsoap protocol.add("normalize:cue_cut", "normalize --seek %fs --length %fs %s", "cut_protocol") ``` -------------------------------- ### Liquidsoap Basic Radio Script Source: https://liquidsoap.readthedocs.io/en/stable/content/quick_start A fundamental Liquidsoap script to set up a simple internet radio station. This script demonstrates basic source declaration, playlist management, and streaming output configuration. ```liquidsoap radio = input.http("http://stream.example.com/radio") playlist = playlist([radio]) output.dummy(playlist) ``` -------------------------------- ### Liquidsoap Execution Phases Overview Source: https://liquidsoap.readthedocs.io/en/stable/content/phases Provides a high-level understanding of how Liquidsoap scripts execute. This includes the initialization phase where the script is loaded and configured, the main execution loop where audio processing and streaming occur, and the shutdown phase for cleanup. ```liquidsoap # Liquidsoap Execution Phases # # 1. Initialization Phase: # - Script loading and parsing # - Configuration loading # - Resource allocation (e.g., network sockets, file handles) # - Initial setup of audio sources and outputs # # 2. Main Execution Loop: # - Processing incoming requests (e.g., HTTP, Icecast) # - Managing audio sources (e.g., playlists, live inputs) # - Applying audio transformations (e.g., normalization, effects) # - Encoding and streaming audio data # - Handling events and timers # # 3. Shutdown Phase: # - Graceful termination of all operations # - Releasing resources # - Saving any necessary state ``` -------------------------------- ### Liquidsoap Scripting Language Basics Source: https://liquidsoap.readthedocs.io/en/stable/content/playlist_parsers Introduction to the core concepts and syntax of the Liquidsoap scripting language. Covers basic operators, flow control, and fundamental building blocks for creating audio streams. ```liquidsoap # Basic stream definition radio = stream.connect("http://stream.example.com/radio") # Applying an effect processed_radio = effect.volume(radio, -3.0) # Outputting the stream output.icecast(processed_radio, host="localhost", port=8000, password="hackme", mount="/radio") ``` -------------------------------- ### Liquidsoap Scripting Language Basics Source: https://liquidsoap.readthedocs.io/en/stable/content/harbor Introduction to the fundamental concepts and syntax of the Liquidsoap scripting language. This covers basic operators and how to structure scripts for audio streaming. ```liquidsoap # Basic script structure radio = input.http("http://stream.example.com/radio") output.icecast(%vorbis, radio) # Using a variable my_stream = input.dummy(samplerate=44100, channels=2) output.file("output.wav", my_stream) ``` -------------------------------- ### Liquidsoap Scripting Language Basics Source: https://liquidsoap.readthedocs.io/en/stable/content/install Introduction to Liquidsoap's scripting language, including basic syntax, variable assignment, and output. ```liquidsoap # Assigning a string to a variable my_string = "Hello, Liquidsoap!" # Assigning a number to a variable my_number = 123 # Printing a variable to the console or log log(my_string) # Basic conditional statement if my_number > 100 then log("Number is greater than 100") else log("Number is 100 or less") end # Defining a simple function def greet(name) return "Hello, " + name + "!" end log(greet("World")) ``` -------------------------------- ### Anonymizer Effect (Blur Face, Change Voice) Source: https://liquidsoap.readthedocs.io/en/stable/content/video An example effect to blur faces and alter voice for anonymity in video streams. This is a conceptual example and requires specific implementations for blurring and voice modification. ```liquidsoap # Conceptual example for anonymizer # Requires specific plugins/operators for face detection and voice modification ``` -------------------------------- ### GStreamer Encoder Metadata Examples Source: https://liquidsoap.readthedocs.io/en/stable/content/gstreamer_encoder Illustrates how to encode metadata with the GStreamer encoder by specifying a pipeline element for GStreamer's tag_setter API. Examples include ogg/vorbis with vorbis tags and MP3 with id3v2 tags. ```liquidsoap % liquidsoap 'output.file(%gstreamer(audio="vorbisenc ! vorbistag name='metadata'", muxer="oggmux", video=""),...)' ``` ```liquidsoap % liquidsoap 'output.file(%gstreamer(audio="lamemp3enc", muxer="id3v2mux", video="", metadata="muxer"),...)' ``` -------------------------------- ### Setting Metadata via HTTP GET Request Source: https://liquidsoap.readthedocs.io/en/stable/content/harbor_http Shows how to create an HTTP GET handler that updates the metadata of a Liquidsoap source. A request like `http://server:7000/setmeta?title=foo` modifies the source's metadata. ```liquidsoap s = source.file("audio.mp3") harbor.http.register(port=7000, uri="/setmeta", handler=function(protocol, data, headers, uri) -> string { params = url_query_params(uri) if has_key(params, "title") { s.metadata.insert("title", params["title"]) } return http_response(data="Metadata updated.") }) ``` -------------------------------- ### Liquidsoap Basic Concepts and Features Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Introduces fundamental Liquidsoap concepts such as clocks, blank detection, and bubble functionality. It also touches upon building Liquidsoap from source and handling documentation indices. ```liquidsoap # Clocks # Blank detection # Bubble # Building Liquidsoap # Documentation index ``` -------------------------------- ### Server/Telnet Seek Function Example Source: https://liquidsoap.readthedocs.io/en/stable/content/seek An example demonstrating how to implement a server/telnet seek function using Liquidsoap's `source.seek` capability. It shows hooking the function close to the original source for seeking within radio streams. ```liquidsoap server.add_telnet_client(port=1234, "telnet_client") radio_source = input.http(url="http://stream.example.com/radio") # Hook the seek function to the radio source seekable_radio_source = source.seekable(radio_source) # Example of a telnet command to seek server.add_telnet_command(port=1234, "seek", function(client, args) { if args == "+" then source.seek(seekable_radio_source, 3.) elseif args == "-" then source.seek(seekable_radio_source, -3.) else client.print("Usage: seek + or -\n") end }) ``` -------------------------------- ### Liquidsoap Scripting Language Basics Source: https://liquidsoap.readthedocs.io/en/stable/content/help Provides an overview of Liquidsoap's scripting language, covering fundamental concepts and syntax for developing audio processing flows. ```liquidsoap This section details the core scripting language used in Liquidsoap, enabling users to define complex audio processing pipelines and streaming logic. ``` -------------------------------- ### Recommended Dependencies Source: https://liquidsoap.readthedocs.io/en/stable/content/build Lists dependencies that enhance Liquidsoap's capabilities, specifically for character set recoding and audio conversion. These are recommended for improved metadata handling and audio processing. ```APIDOC camomile: Version: >=1.0.0 Functionality: Charset recoding in metadata ocaml-samplerate: Version: >=0.1.1 Functionality: Libsamplerate audio conversion ``` -------------------------------- ### Get Single Radio API Source: https://liquidsoap.readthedocs.io/en/stable/content/flows Retrieves details for a single radio, encoded in JSON format, using its unique token. All arguments are optional and should be UTF8 encoded for HTTP GET requests. A direct request using a radio's token can also be performed. ```APIDOC GET http://flows.liquidsoap.info/radio/:token Response Body Example: { "token": "a60f5cadf2645321d4d061896318a2d99f2ff6a6", "name": "RadioPi - Canal Jazz", "website": "http://www.radiopi.org/", "description": "Cool vibes from Chatenay!", "genre": "jazz", "longitude": 2.26670002937317, "latitude": 48.7667007446289, "title": "Bud Powell - Un Poco Loco", "artist": "Va-1939-1999 - 60 Ans De Jazz", "streams": [ { "format": "mp3/128k", "url": "http://radiopi.org:8080/jazz" } ] } ``` -------------------------------- ### Disjoint Clocks Error Example Source: https://liquidsoap.readthedocs.io/en/stable/content/clocks This example demonstrates a scenario where Liquidsoap would produce a fatal error due to a source being assigned to two different clocks. The error message 'a source cannot belong to two clocks' highlights the conflict when a source is tied to an ALSA output and then used in an operator like 'crossfade' which requires its own dedicated clock. ```liquidsoap s = alsa.output(port="hw:0,0") crossfade(s, s2) ``` -------------------------------- ### Liquidsoap External Encoders Source: https://liquidsoap.readthedocs.io/en/stable/content/faq Details on using external encoders with Liquidsoap, including configuration and usage examples. ```liquidsoap # Example: Using an external Ogg Vorbis encoder output.file("output.ogg", init=encoder.vorbis(), file="output.ogg") ``` -------------------------------- ### Initial Perl Implementation Source: https://liquidsoap.readthedocs.io/en/stable/content/geekradio Describes the early version of the Geek Radio system which used Perl and Ices to play audio files. It highlights the limitations and the need for a more robust solution. ```perl sub play_file { my ($file) = @_; # Ices command to play a file system("ices --play $file"); } ``` -------------------------------- ### Blue Screen Effect Example Source: https://liquidsoap.readthedocs.io/en/stable/content/video Replace a blue screen background in a video source with another video or image. ```liquidsoap video.blue_screen(source, background_video) ``` -------------------------------- ### Liquidsoap Server Commands and Help Source: https://liquidsoap.readthedocs.io/en/stable/index Provides information on interacting with a running Liquidsoap instance via server commands and accessing help resources. This includes scripting API, server commands, settings, and plugin lists. ```APIDOC Liquidsoap Server Commands: help Description: Displays available server commands. scripting.api Description: Shows the available scripting functions and their signatures. server.commands Description: Lists all available server commands. settings Description: Displays the current Liquidsoap configuration settings. plugins.list Description: Lists all loaded Liquidsoap plugins. Usage: Connect to the Liquidsoap server using a telnet client or the 'liqcli' tool and issue these commands. ``` -------------------------------- ### Liquidsoap Smart Crossfade Source: https://liquidsoap.readthedocs.io/en/stable/content/faq Explanation and examples of implementing smart crossfade techniques in Liquidsoap for smooth transitions between tracks. ```liquidsoap # Example: Basic crossfade configuration set("crossfade.duration", 3.0) set("crossfade.mode", "smart") ``` -------------------------------- ### FFmpeg MP3 Encoding Example Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Configures the FFmpeg encoder for MP3 audio encoding using the libshine codec. ```liquidsoap %ffmpeg(format="mp3",codec="libshine") ``` -------------------------------- ### Liquidsoap Harbor Input Source: https://liquidsoap.readthedocs.io/en/stable/content/faq Details on configuring and using Harbor as an input source in Liquidsoap. ```liquidsoap # Example: Using Harbor as an input source input.harbor(port=8080) ``` -------------------------------- ### Server Readline Source: https://liquidsoap.readthedocs.io/en/stable/content/server Reads a line of text from the server connection. This is a simple way to get input from a client connected via telnet or a socket. ```liquidsoap server.readline() ``` -------------------------------- ### Liquidsoap Harbor HTTP Server Source: https://liquidsoap.readthedocs.io/en/stable/content/faq Documentation for setting up and using Harbor as an HTTP server within Liquidsoap for streaming. ```liquidsoap # Example: Starting Harbor HTTP server server.harbor.start(port=8000, mount="/stream") ``` -------------------------------- ### Liquidsoap Harbor HTTP Server Source: https://liquidsoap.readthedocs.io/en/stable/content/playlist_parsers Configuration and usage of Harbor as an HTTP server for streaming. This includes setting up mount points and handling client connections. ```liquidsoap # Configuring Harbor HTTP output output.http(..., port=8080, mount="/stream") # Setting up a fallback stream for Harbor set("harbor.fallback_stream", "http://fallback.example.com/stream") ``` -------------------------------- ### Liquidsoap Scripting Language Basics Source: https://liquidsoap.readthedocs.io/en/stable/content/flows_devel Introduces the fundamental concepts and syntax of Liquidsoap's scripting language. It covers how to write basic scripts for audio streaming, including defining sources, applying effects, and managing playlists. ```liquidsoap # Basic Liquidsoap script radio = input.dummy(duration=10.0) output.stdout(radio) ``` -------------------------------- ### Liquidsoap Playlist Management Source: https://liquidsoap.readthedocs.io/en/stable/content/quick_start Demonstrates how to create and manage playlists in Liquidsoap, including adding sources and defining playback behavior. This is crucial for organizing and playing audio content. ```liquidsoap # Create a playlist with multiple sources my_playlist = playlist([ input.file("/music/song1.mp3"), input.http("http://stream.example.com/stream.ogg"), input.file("/music/song2.flac") ]) # Set playlist to repeat set("playlist.repeat", true) # Output the playlist output.dummy(my_playlist) ``` -------------------------------- ### Liquidsoap Flow Development Source: https://liquidsoap.readthedocs.io/en/stable/content/flows Information on developing custom flows within Liquidsoap. This includes getting information from flows, managing playlists, and setting up stream redirection. ```liquidsoap # Example of a simple flow radio = single("http://stream.example.com/radio") output.dummy(radio) ``` -------------------------------- ### Runtime Optional Dependencies Source: https://liquidsoap.readthedocs.io/en/stable/content/build Lists external tools and libraries that are optional at runtime for specific protocol support and advanced features like YouTube integration and audio analysis. ```APIDOC awscli: Functionality: `s3://` and `polly://` protocol support curl: Functionality: `http`/`https`/`ftp` protocol support ffmpeg: Functionality: external I/O, `replay_gain` level computation, .. youtube-dl: Functionality: youtube video and playlist support ``` -------------------------------- ### Liquidsoap Script Execution Source: https://liquidsoap.readthedocs.io/en/stable/content/cookbook Illustrates the method for running longer Liquidsoap recipes, which typically involve creating a dedicated script file. This approach is suitable for more complex configurations and functionalities. ```liquidsoap # Your longer Liquidsoap script here # Example: # source = audio_file("path/to/your/audio.mp3") # out(source) ``` -------------------------------- ### FFmpeg AAC Encoding Example Source: https://liquidsoap.readthedocs.io/en/stable/content/encoding_formats Configures the FFmpeg encoder for AAC audio encoding at 22050kHz using the fdk-aac encoder and mpegts muxer. Includes settings for bitrate and afterburner. ```liquidsoap %ffmpeg(format="mpegts",ar=22050,codec="libfdk_aac",b="32k",afterburner=1,profile="aac_he_v2") ``` -------------------------------- ### GStreamer Encoder in Liquidsoap Source: https://liquidsoap.readthedocs.io/en/stable/index Details the usage of the GStreamer encoder within Liquidsoap. It covers basic examples, content type inference, metadata handling, and potential caveats when using this encoder. ```liquidsoap # Basic GStreamer encoder example set encoder.gstreamer.codec "libmp3lame" set encoder.gstreamer.bitrate "128" # Content type inference # Liquidsoap can often infer content types automatically. # Metadata handling # Metadata can be set using the metadata.set function. ``` -------------------------------- ### Liquidsoap Configuration Variables Source: https://liquidsoap.readthedocs.io/en/stable/content/advanced This section details various configuration variables used in Liquidsoap for customizing its behavior. It covers aspects like adding binaries, setting up paths, and managing runtime parameters. ```liquidsoap # Example of a configuration variable set("log.file.path", "/var/log/liquidsoap.log") set("prefs.user_agent", "MyLiquidsoapClient") ``` -------------------------------- ### Liquidsoap Server Commands and Settings Source: https://liquidsoap.readthedocs.io/en/stable/content/help Details the available server commands and settings that can be used to control and configure a running Liquidsoap instance. ```APIDOC Liquidsoap Server Commands: - `help`: - Displays help information for various aspects of Liquidsoap. - Usage: `help [topic]` - Topics include: scripting-api, server-commands, settings, all-plugins. - `quit`: - Shuts down the Liquidsoap instance. - Usage: `quit` Liquidsoap Settings: - `set = `: - Sets a configuration variable. - Example: `set log_level = "info"` - `get `: - Retrieves the current value of a configuration variable. - Example: `get log_level` ```