Pages

Showing posts with label ffmpeg. Show all posts
Showing posts with label ffmpeg. Show all posts

Monday, August 24, 2020

Python script to cut and merge videos using ffmpeg

Python script to help cut and merge multiple videos .



Script : https://github.com/sterin501/PythonScripts/tree/master/cutMergeVideo

Install :
Install the ffmpeg



Config :
a. Copy the videos to same folder
b. Put the details in details.txt

Like :
VideoFilename startpoint endpoint
c. Run the script -- cutMerge.py





#!/bin/python

import time,subprocess

## ffmpeg -i 2.mkv -ss 00:10:03.500 -to 00:20:08.500 -async 1 cut.mp4 -y
## ffmpeg -i "concat:input1|input2" -codec copy output

#subprocess.Popen("pwd", shell=True)

processList=[]

def creatCutCommad(inputfile,time1,time2,outputfile):
    return "ffmpeg -i "+inputfile+"  -ss "+time1+ "  -to "+time2+"  -async 1   "+ outputfile+" -y"

def runCommand(comand):
        print "running __________________________________"+comand
        subprocess.Popen(comand+" ; echo '1' >> done ",shell=True,stdout=subprocess.PIPE)




if __name__ == '__main__':
    #print creatCutCommad("2.mkv","00:10:03.500","00:20:08.500","cut.mp4")
    filename="details.txt"
    temp=[]
    comands=[]
    part=0
    paS=""

    with open (filename) as engfin:
        for line in engfin:
           if line.startswith('#'):
                 continue
           else:
                cc=line.split()
                comands.append(creatCutCommad(cc[0],cc[1],cc[2],"part"+str(part)+".mp4")    )
                paS=paS+"file part"+str(part)+".mp4\n"
                part=part+1

    f = open("mylist.txt", "w")
    f.write(paS)
    ca='ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4'
    #comands.append(ca)
    #print comands
    f = open("done", "w")
    f.write("")

    for kk in comands:
        runCommand(kk)
    while True:
        print "checking cut job  status\n\n\n "
        time.sleep (2)
        num_lines = sum(1 for line in open('done'))
        print "number of lines " + str (num_lines)
        print "part " + str (part)
        if num_lines == part:
            runCommand(

Wednesday, November 11, 2015

How to install ffmpeg and image magic for DAM conversion in Linux ( OEL 6 , Redhat 6)




Video Conversion :

ffmpeg is used for video conversion . It is commad line conversion tool which is much simpler than flipfactory etc

Steps to install

1. Install : EPEL Repo



Edit /etc/yum.repos.d/epel.repo :::

edit all urls from https to http

if https is used , then there can be connection issues


1.B  Install Remi Repo


yum localinstall --nogpgcheck http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 


2. Install RPM Fusion Repo :

32 bit system

rpm -Uvh http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm

rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm


64 bit system :

rpm -ivh http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-1.noarch.rpm




3. After installing both Repo, update the yum 

yum update



After updating the yum , make sure that all repo shows properly like this

[root@stjacob-pc1 yum.repos.d]# yum repolist
Loaded plugins: refresh-packagekit, security, ulninfo
repo id repo name status
*epel Extra Packages for Enterprise Linux 6 - x86_64 11,750
ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Server (x86_64) 429
ol6_addons Oracle Linux 6Server Add ons (x86_64) 257
ol6_internal Oracle Linux 6Server Internal Mirror 7
ol6_latest Oracle Linux 6Server Latest (x86_64) 26,286
ol6_oracle Oracle Software for Oracle Linux 6Server (x86_64) 53
public_ol6_UEKR3_latest Unbreakable Enterprise Kernel Release 3 for Oracle Linux 6Server (x86_64) 478
public_ol6_latest Oracle Linux 6Server Latest (x86_64) 32,597
remi-safe Safe Remi's RPM repository for Enterprise Linux 6 - x86_64 494
rpmfusion-free-updates RPM Fusion for EL 6 - Free - Updates 293
rpmfusion-nonfree-updates RPM Fusion for EL 6 - Nonfree - Updates 87


4. After adding all repo , install using yum 

yum install ffmpeg



5. Image Conversion tool : Image Magic



  yum install ImageMagick