How to get parts of different videos from a list contained in a csv file

If we want to get parts from videos contained in a csv file that has this data:

001.mp4,1,10
002.mp4,2,10
003.mp4,3,10
004.mp4,5,10
005.mp4,1,10

Saved in text.csv,

You can use this code:

import os, glob

from tkinter import filedialog
import tkinter as tk


def getpart(name, start, end):
    newname = name[:-4] + "_.mp4"
    os.system(f"ffmpeg -i {name} -ss {start} -t {end} -c copy {newname}")
    print(f"saved {name[:-4]}_.mp4")

with open("movie.csv") as file:
    mlist = file.readlines()
    mlist = [x.strip() for x in mlist]
    print(mlist)

for line in mlist:
    name, start, end = line.split(",")
    getpart(name, start, end)
Get a part of a video (just one video)

How to get a video from another one telling where to start and where to end with Python and ffmpeg


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts