-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoin_mp3
More file actions
executable file
·43 lines (33 loc) · 857 Bytes
/
join_mp3
File metadata and controls
executable file
·43 lines (33 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python3
import json
import shlex
import subprocess as sp
from pathlib import Path
from typing import List
import typer
from rich import print as echo
app = typer.Typer(pretty_exceptions_show_locals=False)
@app.command()
def main(
files: List[Path],
outfile: Path = "joined.mp3",
):
"""Join multiple audio files into one."""
if not files:
echo("No files to join.")
raise typer.Exit()
echo(f'Create "{outfile}" from {len(files)} input files')
for ii, file in enumerate(files):
echo(f" ... {ii+1:03d}: '{file}'")
cmd = [
"ffmpeg",
"-i",
"concat:" + "|".join(str(f) for f in files),
"-c",
"copy",
str(outfile),
]
echo(" ".join(shlex.quote(arg) for arg in cmd))
sp.run(cmd, check=True)
if __name__ == "__main__":
app()