Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How about

  for wmv in Path(sys.argv[1]).rglob("\*.wmv"):
        print(wmv, end=" ")
        r = subprocess.run(
            ["ffmpeg", "-i", wmv, wmv.with_suffix(".mpg")],
            stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
        )
        lines = [l for l in r.stdout.decode().splitlines() if "kb/s:" in l]
        print("\n".join(lines) if lines else f"ERROR {r.returncode}")
?

If you go outside stdlib you can use the sh library instead of subprocess.run.



Not bad, but the subprocess invocation is too verbose given this is a staple of shell script type work, and the string mangling is a bit painful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: