0

Is there an easy way to add chapters (i.e.: sections with titles) to .mp4 files using a python script?

For example, the script could process a 3-minutes video and label the first minute as "Beginning", the second minute as "Middle", and the last minute as "End".

The only solution (link) I stumbled upon so far involves using a ffmpeg command on the command line to extract the original ffmetadata from the video file before appending the chapters to it and updating the video with it.

However, I would like the process to be automated using a python script (instead of having to use the command line each time I have to process a video).

7
  • Running the program via the command line to achieve your objective is already a form of automation, so what is your question? If it's a recommendation to find a library in Python to do this, I am afraid that is off-topic for StackOverflow. Commented Mar 7, 2023 at 3:09
  • Not really, I would like to run that command within a larger python program that processes video files. I just want to find a way to do so without having to go through the command line separately. Commented Mar 7, 2023 at 3:27
  • 1
    You might be looking for a way to run ffmpeg through Python subprocess. Commented Mar 7, 2023 at 3:30
  • I tried doing so but it tells me that it doesn't recognize ffmpeg as a command for some reason, although I did import it to my pycharm virtual environment. @metatoaster Commented Mar 7, 2023 at 3:42
  • 1
    You may need to provide the full path to the ffmpeg executable. Commented Mar 7, 2023 at 5:06

1 Answer 1

0

As mentioned in the comments above, I was able to achieve what I wanted using the subprocess.call(command, shell=True) function after updating my path variable.

The 'shell=True' argument allowed me to process the command as a regular shell command (link), and updating the path variable made ffmpeg recognizable.

I didn't have to use ffmpeg-python module after all since it was easier to use the ffmpeg (downloaded from here) command on shell that worked fine initially.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.