Skip to content

Commit

Permalink
Merge pull request happycube#876 from happycube/chad-2024.01.15
Browse files Browse the repository at this point in the history
ld-cut: add custom ffmpeg-settings
  • Loading branch information
happycube authored Jan 15, 2024
2 parents 3fc0e1e + f113992 commit c71ae28
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
18 changes: 16 additions & 2 deletions ld-cut
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,24 @@ 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)
filename = args.infile
outname = args.outfile

if outname == '-':
outname = "/dev/stdout"

vid_standard = "PAL" if args.pal else "NTSC"

if args.pal and args.ntsc:
Expand Down Expand Up @@ -131,15 +143,17 @@ 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
)
fd = process.stdin
elif makeldf:
process, fd = ldf_pipe(outname, args.ldfcomp)
else:
fd = open(args.outfile, "wb")
fd = open(outname, "wb")

# print(startloc, endloc, startidx, endidx)

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 c71ae28

Please sign in to comment.