diff --git a/ld-cut b/ld-cut index ae0afa566..4d3247970 100755 --- a/ld-cut +++ b/ld-cut @@ -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) @@ -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 ) diff --git a/lddecode/utils.py b/lddecode/utils.py index cffd5ad72..b46d1f65e 100644 --- a/lddecode/utils.py +++ b/lddecode/utils.py @@ -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 = []