Recherche avancée

Médias (91)

Autres articles (54)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (2803)

  • I want to reduce my PYTHON code and also make proper

    7 mai 2022, par Anuj Saxena

    I have a CSV file From the client.
In my code, first, read the CSV file and create folders based on the CSV Column Heading name
and, convert the video into jpeg and also compress the video and apply a watermark on the compressed video.
hi below is my code example. Is there a way to reduce the number of lines of code and save time ?
example.. using function or loops. I need any other method. please help

    


    enter image description here

    


    CODE BEGIN

    


    #import library
import csv
import os
import subprocess
import shutil

path = r'/home/anuj/FIle_server/from_client/shots_data.csv' #path of client CSV File
root = r"/home/anuj/FIle_server/production/"# path where i want create folders 
list = ['JPG', 'LOW', 'RAW'] #also add these folders in the last directory


def read_csv(path):  #create function to read csv file 
    with open(path, 'r') as csv_file:
        csv_reader = csv.DictReader(csv_file)
        for line in csv_reader:
            print(line)
            new_path  = f"{root}/{line['Project']}/{line['Sequence']}/{line['Shot']}/{line['task']}/{line['software']}/{line['artist']}"
            print(new_path)
            os.makedirs(new_path) #create folders.
            for items in list:
                path = os.path.join(new_path, items)
                os.mkdir(path) #create jpeg, low ,raw folders in the last directory


read_csv(path)

def convert_1mov_to_seq():# Declare function to convert video into jpeg and also compress the video,and apply watermark on the compressed video
    # input = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_001/SH001/ROTO/NUKE/VISHAL/RAW/SH001.MOV"
    input  = r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH001.MOV"
    output = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_001/SH001/ROTO/NUKE/VISHAL/JPG/frm_seq_v001.%3d.jpeg"
    output2 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_001/SH001/ROTO/NUKE/VISHAL/LOW/SH001.mp4"
    output3 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_001/SH001/ROTO/NUKE/VISHAL/LOW/Compress_SH001.mp4"

    cmd = f'ffmpeg -i "{input}" "{output}"'
    cmd2 = f"ffmpeg -i {input} -vcodec libx264 -acodec aac {output2}"
    cmd3 = f"ffmpeg -i {output2} -i watermark.png -filter_complex 'overlay=1660:970' {output3}"
    print(cmd)
    print(cmd2)
    print(cmd3)
    subprocess.call(cmd, shell=True)
    subprocess.call(cmd2, shell=True)
    subprocess.call(cmd3, shell=True)

def convert_2mov_to_seq():
    # input = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_002/SH002/MM/MAYA/ANUJ/RAW/SH002.MOV"
    input  = r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH002.MOV"
    output = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_002/SH002/MM/MAYA/ANUJ/JPG/frm_seq_v001.%3d.jpeg"
    output2 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_002/SH002/MM/MAYA/ANUJ/LOW/SH002.mp4"
    output3 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_002/SH002/MM/MAYA/ANUJ/LOW/Compress_SH002.mp4"

    cmd = f'ffmpeg -i "{input}" "{output}"'
    cmd2 = f"ffmpeg -i {input} -vcodec libx264 -acodec aac {output2}"
    cmd3 = f"ffmpeg -i {output2} -i watermark.png -filter_complex 'overlay=1660:970' {output3}"
    print(cmd)
    print(cmd2)
    print(cmd3)
    subprocess.call(cmd, shell=True)
    subprocess.call(cmd2, shell=True)
    subprocess.call(cmd3, shell=True)

def convert_3mov_to_seq():
    # input = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_003/SH003/VFX/HOUDINI/KESHV/RAW/SH003.MOV"
    input  = r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH003.MOV"
    output = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_003/SH003/VFX/HOUDINI/KESHV/JPG/frm_seq_v001.%3d.jpeg"
    output2 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_003/SH003/VFX/HOUDINI/KESHV/LOW/SH003.mp4"
    output3 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_003/SH003/VFX/HOUDINI/KESHV/LOW/compress_SH003.mp4"

    cmd = f'ffmpeg -i "{input}" "{output}"'
    cmd2 = f"ffmpeg -i {input} -vcodec libx264 -acodec aac {output2}"
    cmd3 = f"ffmpeg -i {output2} -i watermark.png -filter_complex 'overlay=1660:970' {output3}"
    print(cmd)
    print(cmd2)
    print(cmd3)
    subprocess.call(cmd, shell=True)
    subprocess.call(cmd2, shell=True)
    subprocess.call(cmd3, shell=True)

def convert_4mov_to_seq():# i want only one compressed video with watermark, but here i create two compressed video one with watermark and another without watermark.
    # input = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_004/SH004/CLEANUP/BLENDER/VARSHA/RAW/SH004.MOV"
    input  = r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH004.MOV"
    output = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_004/SH004/CLEANUP/BLENDER/VARSHA/JPG/frm_seq_v001.%3d.jpeg"
    output2 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_004/SH004/CLEANUP/BLENDER/VARSHA/LOW/SH004.mp4"
    output3 = r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_004/SH004/CLEANUP/BLENDER/VARSHA/LOW/Compress_SH004.mp4"

    cmd = f'ffmpeg -i "{input}" "{output}"'
    cmd2 = f"ffmpeg -i {input} -vcodec libx264 -acodec aac {output2}"
    cmd3 = f"ffmpeg -i {output2} -i watermark.png -filter_complex 'overlay=1660:970' {output3}"
    print(cmd)
    print(cmd2)
    print(cmd3)
    subprocess.call(cmd, shell=True)
    subprocess.call(cmd2, shell=True)
    subprocess.call(cmd3, shell=True)

 convert_1mov_to_seq()
 convert_2mov_to_seq()
 convert_3mov_to_seq()
 convert_4mov_to_seq()

def copy_mov(): #copy videos from client folder to RAW folders
    shutil.copy2(r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH001.MOV", r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_001/SH001/ROTO/NUKE/VISHAL/RAW/SH001.mp4")
    shutil.copy2(r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH002.MOV", r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_002/SH002/MM/MAYA/ANUJ/RAW/SH002.mp4")
    shutil.copy2(r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH003.MOV", r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_003/SH003/VFX/HOUDINI/KESHV/RAW/SH003.mp4")
    shutil.copy2(r"/home/anuj/FIle_server/from_client/AI_PROJECT/SEQ_001/SH004.MOV", r"/home/anuj/FIle_server/production/AI_PROJECT/SEQ_004/SH004/CLEANUP/BLENDER/VARSHA/RAW/SH004.mp4")


copy_mov()