Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Add ffmpeg pixi example for blog post (#10993)

Trevor Manzbff395104c36
diff --git a/docs/guides/package_management/sandboxes.md b/docs/guides/package_management/sandboxes.md
index 142c69b05b..ab74b15910 100644
--- a/docs/guides/package_management/sandboxes.md
+++ b/docs/guides/package_management/sandboxes.md
@@ -225,7 +225,7 @@ print(ro.r("summary(iris)"))
```
For an interactive example combining a marimo slider, dplyr, Arrow, and Polars,
-see the [Using R notebook](https://github.com/marimo-team/marimo/blob/main/examples/misc/using_r.py).
+see the [R with Pixi notebook](https://github.com/marimo-team/marimo/blob/main/examples/misc/pixi_r.py).
Manage [Conda dependencies](https://pixi.prefix.dev/latest/python/scripts/#manage-dependencies)
through the metadata or Pixi's script commands; marimo's package panel manages
diff --git a/examples/misc/README.md b/examples/misc/README.md
index 6086d9504f..e637e571f2 100644
--- a/examples/misc/README.md
+++ b/examples/misc/README.md
@@ -21,10 +21,11 @@ comment. Here are the steps to open an example notebook:
You can also open notebooks without `uv`, with just `marimo edit <notebook.py>`;
however, you'll need to install the requirements yourself.
-The [Using R](using_r.py) example uses Pixi to install R and its packages
-alongside Python dependencies. With [Pixi installed](https://pixi.prefix.dev/latest/installation/),
-open it with:
+The [R](pixi_r.py) and [FFmpeg](pixi_ffmpeg.py) examples use Pixi to install
+non-Python dependencies. With [Pixi installed](https://pixi.prefix.dev/latest/installation/),
+run:
```bash
-marimo edit --sandbox=pixi examples/misc/using_r.py
+marimo edit --sandbox=pixi examples/misc/pixi_r.py
+marimo edit --sandbox=pixi examples/misc/pixi_ffmpeg.py
```
diff --git a/examples/misc/pixi_ffmpeg.py b/examples/misc/pixi_ffmpeg.py
new file mode 100644
index 0000000000..e7398d5cee
--- /dev/null
+++ b/examples/misc/pixi_ffmpeg.py
@@ -0,0 +1,63 @@
+# /// script
+# requires-python = ">=3.12"
+# dependencies = ["marimo>=0.25.0"]
+#
+# [tool.pixi.workspace]
+# channels = ["conda-forge"]
+#
+# [tool.pixi.dependencies]
+# ffmpeg = "*"
+# ///
+
+import marimo
+
+__generated_with = "0.25.0"
+app = marimo.App(width="compact")
+
+
[email protected](hide_code=True)
+def _(mo):
+ mo.md("""
+ With [Pixi installed](https://pixi.prefix.dev/latest/installation/), run:
+
+ ```bash
+ marimo edit --sandbox=pixi examples/misc/pixi_ffmpeg.py
+ ```
+ """)
+ return
+
+
+def _():
+ import marimo as mo
+
+ pitch = mo.ui.slider(220, 880, step=20, value=440, label="Pitch (Hz)")
+ pitch
+ return mo, pitch
+
+
+def _(mo, pitch):
+ import io
+ import subprocess
+
+ tone = subprocess.run(
+ [
+ "ffmpeg",
+ "-f",
+ "lavfi",
+ "-i",
+ f"sine=frequency={pitch.value}:duration=2",
+ "-f",
+ "wav",
+ "pipe:1",
+ ],
+ capture_output=True,
+ check=True,
+ )
+ mo.audio(io.BytesIO(tone.stdout))
+ return
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/examples/misc/using_r.py b/examples/misc/pixi_r.py
similarity index 91%
rename from examples/misc/using_r.py
rename to examples/misc/pixi_r.py
index bfb8d634ec..ff571930a4 100644
--- a/examples/misc/using_r.py
+++ b/examples/misc/pixi_r.py
@@ -37,7 +37,7 @@ with app.setup:
@app.cell(hide_code=True)
def _():
mo.md("""
- # Using R
+ # R with Pixi
With Pixi sandboxing, a marimo notebook can describe more than its Python
dependencies, including system libraries and even another language's runtime.
@@ -45,12 +45,17 @@ def _():
This demo declares R and Python dependencies together, uses marimo's
reactivity to run R code when a slider changes, and shares the resulting
Arrow table back to Python without copying its data.
+ """)
+ return
+
- With [Pixi installed](https://pixi.prefix.dev/latest/installation/), open
- this notebook in a Pixi sandbox to install both its R and Python dependencies:
[email protected](hide_code=True)
+def _():
+ mo.md("""
+ With [Pixi installed](https://pixi.prefix.dev/latest/installation/), run:
```bash
- marimo edit --sandbox=pixi examples/misc/using_r.py
+ marimo edit --sandbox=pixi examples/misc/pixi_r.py
```
""")
return