Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply to multiple files? #32

Open
CU4thSpace opened this issue Jun 22, 2022 · 2 comments
Open

apply to multiple files? #32

CU4thSpace opened this issue Jun 22, 2022 · 2 comments

Comments

@CU4thSpace
Copy link

I love this script, it finally got me using ffmpeg. My only question, is it possible to apply this to a folder of video files? Thank you!

@bryanseah234
Copy link

I love this script, it finally got me using ffmpeg. My only question, is it possible to apply this to a folder of video files? Thank you!

hey you can write a batch script since this is a command line tool!

@tuminzee
Copy link

tuminzee commented Mar 20, 2023

Hey @CU4thSpace if your issue is not solved, have a look at this
I was going through the same problem and took on the advice by @bryanseah234

After following https://stackoverflow.com/questions/68070092/is-there-a-way-to-wait-in-a-bash-script-for-a-python-program-started-in-a-new

I made a python code which will generate a shell script which will split all the videos located at a directory
https://gist.github.com/tuminzee/70596f47dfb2669111e2313f0bdf7a36

After running this, it will generate a shell script run.sh, run the file and it should split multiple files present in the directory

import os

basepath = 'videos'
i = -1

f = open("run.sh", "x")

f.writelines("#!/bin/bash \n")

for entry in os.listdir(basepath):

    if not entry.startswith('.') and os.path.isfile(os.path.join(basepath, entry)):
        i += 1
        input = f'python3 ffmpeg-split.py -f {basepath}/"{entry}" -s 30 & pid{i}=$! \n'
        f.writelines(input)
        print(f'python3 ffmpeg-split.py -f {basepath}/"{entry}" -s 30 & pid{i}=$!')

f.writelines("wait ")
print('wait', end=' ')

for j in range(i):
    input = f"$pid{j} "
    f.writelines(input)
    print(f'$pid{j}', end=' ')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants