Skip to content

Commit

Permalink
add -F option to allow custom ffmpeg settings in ld-cut
Browse files Browse the repository at this point in the history
  • Loading branch information
happycube committed Jan 15, 2024
1 parent f9b1995 commit f113992
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
13 changes: 12 additions & 1 deletion ld-cut
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ parser.add_argument(
help="compression level for .ldf files",
)

parser.add_argument(
"-F",
"--fmpeg-options",
dest="ffmpeg_options",
type=str,
default=None,
help="custom ffmpeg format options"
)

args = parser.parse_args()

# print(args)
Expand Down Expand Up @@ -134,7 +143,9 @@ startidx = int(ldd.fdoffset)
ldd.roughseek(endloc)
endidx = int(ldd.fdoffset)

if makelds:
if args.ffmpeg_options is not None:
process, fd = ffmpeg_pipe(outname, args.ffmpeg_options)
elif makelds:
process = subprocess.Popen(
["ld-lds-converter", "-o", outname, "-p"], stdin=subprocess.PIPE
)
Expand Down
18 changes: 13 additions & 5 deletions lddecode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,17 +529,25 @@ def __call__(self, infile, sample, readlen):
return self.read(infile, sample, readlen)


def ldf_pipe(outname: str, compression_level: int = 6):
corecmd = "ffmpeg -y -hide_banner -loglevel error -f s16le -ar 40k -ac 1 -i - -acodec flac -f ogg".split(
" "
)
def ffmpeg_pipe(outname: str, opts: str):
cmd = f"ffmpeg -y -hide_banner -loglevel error -f s16le -ar 40k -ac 1 -i -"
if opts and len(opts):
cmd += f" {opts}"

cmd = cmd.split(' ')

process = subprocess.Popen(
[*corecmd, "-compression_level", str(compression_level), outname],
[*cmd, outname],
stdin=subprocess.PIPE,
)

return process, process.stdin


def ldf_pipe(outname: str, compression_level: int = 6):
return ffmpeg_pipe(outname, f"-acodec flac -f ogg -compression_level {compression_level}")


def ac3_pipe(outname: str):
processes = []

Expand Down

0 comments on commit f113992

Please sign in to comment.