Recherche avancée

Médias (16)

Mot : - Tags -/mp3

Autres articles (79)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

Sur d’autres sites (5536)

  • Anomalie #4074 (Nouveau) : Le code de plugin-dist/medias/modeles/video.html , produit un paragraph...

    11 janvier 2018, par eldk -

    Le code de plugin-dist/medias/modeles/video.html , produit un paragraphe de trop et casse le html.

    Ayant l’option pToBr désactivée, je ne suis pas sur que cela soit le
    cas général.

    Cependant, une petite remise en forme de plugin-dist/medias/modeles/video.html m’a permis de solutionner cela :

    ```
    diff —git a/squelettes/modeles/video.html
    b/squelettes/modeles/video.html
    index 9019d44..acf60a8 100644
    --- a/squelettes/modeles/video.html
    +++ b/squelettes/modeles/video.html
    @ -19,8 +19,7 @
    poster="[(#LOGO_DOCUMENTvignette|image_reduire
    #GETlargeur,0|extraire_attributsrc)]"
    controls="controls"
    preload="none"

    - [autoplay="autoplay"(#ENVauto
    play
    |oui)]
    - >

    + autoplay="autoplay"(#ENVautoplay>

    &amp;lt;source<br />type="[(#EXTENSION|in_array{#LISTE{mp4,webm,ogv}}|?{[(#MIME_TYPE|replac<br />e{application/,video/})],#MIME_TYPE})]" src="#FICHIER" /><br />                        &amp;lt;!-- Flash fallback for non-HTML5 browsers<br />without JavaScript --><br />                  &amp;lt;object width="#GET{largeur}" height="#GET{hauteur}" <br />type="application/x-shockwave-flash" <br />data="#CHEMIN{lib/mejs/flashmediaelement.swf}">

    Cordialement,

    Eric

  • Ffmpeg encoding too slow

    8 mars 2024, par Marc Cuadras

    I'm using a Python script to encode mp4 videos in various qualities, in my case 360 +720 +1080.&#xA;Ffmpeg encoding videos very slow, 1 video taking 2 hours or more, I'm using good dedicated server from hetzner (ryzen 5 3600 + 64gm ram), any suggestion to improve speed will be really appreciated

    &#xA;

    import os&#xA;import glob&#xA;from datetime import datetime&#xA;import subprocess&#xA;from rich import print&#xA;import time&#xA;import sys&#xA;import pymysql as sql&#xA;import move&#xA;&#xA;MYSQL_HOST = "127.0.0.1"&#xA;MYSQL_USER = ""&#xA;MYSQL_PASSWORD = ""&#xA;MYSQL_DB = ""&#xA;&#xA;BASE_PATH = &#x27;&#x27;&#xA;UPLOAD_PATH = os.path.join(BASE_PATH, &#x27;upload&#x27;)&#xA;UPLOAD_PATH2 = os.path.join(BASE_PATH, &#x27;upload2&#x27;)&#xA;VIDEO_PATH = os.path.join(BASE_PATH, &#x27;video&#x27;)&#xA;LOGO_PATH = os.path.join(BASE_PATH, &#x27;logo.png&#x27;)&#xA;ERROR_PATH = os.path.join(BASE_PATH, &#x27;error&#x27;)&#xA;RCLONE_PATH = os.path.join(BASE_PATH, &#x27;rclone&#x27;)&#xA;WAIT = 60&#xA;VIDEO_LENGTH = 10&#xA;MOVE_CMD = "screen -dmS move python3 move.py --folder {}"&#xA;&#xA;global current_video_id&#xA;&#xA;db = sql.connect(&#xA;        host=MYSQL_HOST,&#xA;        user=MYSQL_USER,&#xA;        password=MYSQL_PASSWORD,&#xA;        database=MYSQL_DB&#xA;    )&#xA;&#xA;def executedb(query):&#xA;    cursor = db.cursor()&#xA;    cursor.execute(query)&#xA;    db.commit()&#xA;&#xA;def time_now():&#xA;    now = datetime.now().strftime(&#x27;%Y-%m-%d %H:%M:%S&#x27;)&#xA;    return now&#xA;&#xA;def write_log(msg):&#xA;    log_msg = f"{time_now()}: {msg}"&#xA;    with open(&#x27;log.txt&#x27;,&#x27;a&#x27;) as f:&#xA;        f.write(log_msg)&#xA;        f.write(&#x27;\n&#x27;)&#xA;&#xA;def change_extension(files):&#xA;    for file in files:&#xA;        os.rename(file, file.split(&#x27;.&#x27;)[0] &#x2B; &#x27;.mkv&#x27;)&#xA;&#xA;def change_all_videos_extension():&#xA;    # changing all the vidoe&#x27;s extension to mkv format&#xA;    MKV_files = glob.glob(&#x27;*.MKV&#x27;)&#xA;    AVI_files = glob.glob(&#x27;*.AVI&#x27;)&#xA;    avi_files = glob.glob(&#x27;*.avi&#x27;)&#xA;    MP4_files = glob.glob(&#x27;*.MK4&#x27;)&#xA;    mp4_files = glob.glob(&#x27;*.mp4&#x27;)&#xA;    webm_files = glob.glob(&#x27;*.webm&#x27;)&#xA;    ts_files = glob.glob(&#x27;*.ts&#x27;)&#xA;&#xA;    if len(avi_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting avi videos to mkv format&#x27;)&#xA;        change_extension(avi_files)&#xA;&#xA;    if len(MKV_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting MKV videos to mkv format&#x27;)&#xA;        change_extension(MKV_files)&#xA;&#xA;    if len(AVI_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting AVI videos to mkv format&#x27;)&#xA;        change_extension(AVI_files)&#xA;&#xA;    if len(MP4_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting MP4 videos to mkv format&#x27;)&#xA;        change_extension(MP4_files)&#xA;&#xA;    if len(mp4_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting mp4 videos to mkv format&#x27;)&#xA;        change_extension(mp4_files)&#xA;&#xA;    if len(webm_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting webm videos to mkv format&#x27;)&#xA;        change_extension(webm_files)&#xA;&#xA;    if len(ts_files) > 0:&#xA;        print(f&#x27;[{time_now()}] Converting ts videos to mkv format&#x27;)&#xA;        change_extension(ts_files)&#xA;        &#xA;def encode_480(filename):&#xA;    FILENAME_PATH = filename&#xA;    newname = filename.split(&#x27;.&#x27;)[0]&#xA;    newname_path = os.path.join(VIDEO_PATH, newname)&#xA;&#xA;    poster_cmd = f&#x27;ffmpeg -y -ss  00:00:10 -i {FILENAME_PATH} -vframes  1 -q:v  2 poster.jpg&#x27;&#xA;    os.system(poster_cmd)&#xA;    &#xA;    if not os.path.exists(newname_path):&#xA;        os.mkdir(newname_path)&#xA;&#xA;    os.replace(&#x27;poster.jpg&#x27;, os.path.join(newname_path, &#x27;poster.jpg&#x27;))&#xA;    &#xA;&#xA;    ffmpeg480_cmd = f&#x27;ffmpeg -hide_banner -y -i {FILENAME_PATH} -sn -c:a aac -ac 2 -c:v libx264 -crf 23 -preset fast -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -maxrate 1024k -bufsize 1536k -b:a 128k -pix_fmt yuv420p -hls_segment_filename 4835JRK9%03d.ts 480p.m3u8&#x27;&#xA;    os.system(ffmpeg480_cmd)&#xA;    &#xA;    # os.remove(FILENAME_PATH)&#xA;    &#xA;    ts_files = glob.glob(&#x27;*.ts&#x27;)&#xA;    for ts_file in ts_files:&#xA;        os.replace(ts_file, os.path.join(newname_path, ts_file))&#xA;    &#xA;    master_text = &#x27;&#x27;&#x27;#EXTM3U&#xA;#EXT-X-STREAM-INF:BANDWIDTH=1500000,RESOLUTION=854x480&#xA;480p.m3u8&#xA;#EXT-X-STREAM-INF:BANDWIDTH=840000,RESOLUTION=640x360&#xA;360p.m3u8&#xA;&#x27;&#x27;&#x27;&#xA;    with open(&#x27;master.m3u8&#x27;, &#x27;w&#x27;) as f:&#xA;        f.write(master_text)&#xA;    &#xA;    m3u8_files = glob.glob(&#x27;*.m3u8&#x27;)&#xA;    for m3u8_file in m3u8_files:&#xA;        os.replace(m3u8_file, os.path.join(newname_path, m3u8_file))&#xA;&#xA;&#xA;def encode_360(filename):&#xA;    FILENAME_PATH = filename&#xA;    newname = filename.split(&#x27;.&#x27;)[0]&#xA;    newname_path = os.path.join(VIDEO_PATH,newname)&#xA;    poster_cmd = f&#x27;ffmpeg -y -ss 00:00:10 -i {FILENAME_PATH} -vframes 1 -q:v 2 poster.jpg&#x27;&#xA;    os.system(poster_cmd)&#xA;    if not os.path.exists(newname_path):&#xA;        os.mkdir(newname_path)&#xA;    os.replace(&#x27;poster.jpg&#x27;,os.path.join(newname_path, &#x27;poster.jpg&#x27;))&#xA;&#xA;    &#xA;    ffmpeg360_cmd = f&#x27;ffmpeg -hide_banner -y -i {FILENAME_PATH} -sn -c:a aac -ac 2 -c:v libx264 -crf 23 -preset fast -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -maxrate 512k -bufsize 768k -b:a 128k -pix_fmt yuv420p -hls_segment_filename 365RL6TJ%03d.ts 360p.m3u8&#x27;&#xA;    os.system(ffmpeg360_cmd)&#xA;    # return&#xA;    &#xA;    &#xA;    ts_files = glob.glob(&#x27;*.ts&#x27;)&#xA;    for ts_file in ts_files:&#xA;        os.replace(ts_file, os.path.join(newname_path,ts_file))&#xA;    master_text = &#x27;&#x27;&#x27;#EXTM3U&#xA;#EXT-X-STREAM-INF:BANDWIDTH=840000,RESOLUTION=640x360&#xA;360p.m3u8&#xA;    &#x27;&#x27;&#x27;&#xA;    with open(&#x27;master.m3u8&#x27;, &#x27;w&#x27;) as f:&#xA;        f.write(master_text)&#xA;    m3u8_files = glob.glob(&#x27;*.m3u8&#x27;)&#xA;    for m3u8_file in m3u8_files:&#xA;        os.replace(m3u8_file, os.path.join(newname_path, m3u8_file))&#xA;&#xA;&#xA;def encode_720(filename):&#xA;    FILENAME_PATH = filename&#xA;    newname = filename.split(&#x27;.&#x27;)[0]&#xA;    newname_path = os.path.join(VIDEO_PATH,newname)&#xA;    poster_cmd = f&#x27;ffmpeg -y -ss 00:00:10 -i {FILENAME_PATH} -vframes 1 -q:v 2 poster.jpg&#x27;&#xA;    os.system(poster_cmd)&#xA;&#xA;    if not os.path.exists(newname_path):&#xA;        os.mkdir(newname_path)&#xA;&#xA;    os.replace(&#x27;poster.jpg&#x27;,os.path.join(newname_path, &#x27;poster.jpg&#x27;))&#xA;&#xA;    ffmpeg720_cmd = f&#x27;ffmpeg -hide_banner -y -i {FILENAME_PATH} -sn -c:a aac -ac 2 -c:v libx264 -crf 23 -preset fast -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -maxrate 2048k -bufsize 3072k -b:a 160k -pix_fmt yuv420p -hls_segment_filename 7269TKL0%03d.ts 720p.m3u8&#x27;&#xA;    os.system(ffmpeg720_cmd)&#xA;&#xA;    # os.remove(FILENAME_PATH)&#xA;&#xA;    ts_files = glob.glob(&#x27;*.ts&#x27;)&#xA;    for ts_file in ts_files:&#xA;        os.replace(ts_file, os.path.join(newname_path,ts_file))&#xA;        &#xA;    m3u8_text = &#x27;&#x27;&#x27;#EXTM3U&#xA;#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720&#xA;720p.m3u8&#xA;#EXT-X-STREAM-INF:BANDWIDTH=840000,RESOLUTION=640x360&#xA;360p.m3u8        &#xA;        &#x27;&#x27;&#x27;&#xA;&#xA;    with open(&#x27;master.m3u8&#x27;,&#x27;w&#x27;) as f:&#xA;        f.write(m3u8_text)&#xA;            &#xA;    m3u8_files = glob.glob(&#x27;*.m3u8&#x27;)&#xA;    for m3u8_file in m3u8_files:&#xA;        os.replace(m3u8_file, os.path.join(newname_path,m3u8_file))  &#xA;&#xA;&#xA;def encode_1080(filename):&#xA;    FILENAME_PATH = filename&#xA;    newname = filename.split(&#x27;.&#x27;)[0]&#xA;    newname_path = os.path.join(VIDEO_PATH, newname)&#xA;    poster_cmd = f&#x27;ffmpeg -y -ss 00:00:10 -i {FILENAME_PATH} -vframes 1 -q:v 2 poster.jpg&#x27;&#xA;    os.system(poster_cmd)&#xA;&#xA;    if not os.path.exists(newname_path):&#xA;        os.mkdir(newname_path)&#xA;&#xA;    os.replace(&#x27;poster.jpg&#x27;, os.path.join(newname_path, &#x27;poster.jpg&#x27;))&#xA;&#xA;    ffmpeg1080_cmd = f&#x27;ffmpeg -hide_banner -y -i {FILENAME_PATH} -sn -c:a aac -ac 2 -c:v libx264 -crf 23 -preset fast -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -maxrate 4000k -bufsize 6000k -b:a 192k -pix_fmt yuv420p -hls_segment_filename 108YUT8T%03d.ts 1080p.m3u8&#x27;&#xA;    os.system(ffmpeg1080_cmd)&#xA;&#xA;    # os.remove(FILENAME_PATH)&#xA;&#xA;    ts_files = glob.glob(&#x27;*.ts&#x27;)&#xA;    for ts_file in ts_files:&#xA;        os.replace(ts_file, os.path.join(newname_path, ts_file))&#xA;&#xA;    m3u8_text = &#x27;&#x27;&#x27;#EXTM3U&#xA;#EXT-X-STREAM-INF:BANDWIDTH=4000000,RESOLUTION=1920x1080&#xA;1080p.m3u8&#xA;#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720&#xA;720p.m3u8&#xA;#EXT-X-STREAM-INF:BANDWIDTH=840000,RESOLUTION=640x360&#xA;360p.m3u8&#xA;&#x27;&#x27;&#x27;&#xA;&#xA;    with open(&#x27;master.m3u8&#x27;, &#x27;w&#x27;) as f:&#xA;        f.write(m3u8_text)&#xA;&#xA;    m3u8_files = glob.glob(&#x27;*.m3u8&#x27;)&#xA;    for m3u8_file in m3u8_files:&#xA;        os.replace(m3u8_file, os.path.join(newname_path, m3u8_file))&#xA;&#xA;&#xA;&#xA;def vod(filename, resolution):&#xA;    os.replace(filename,filename.replace(&#x27; &#x27;,&#x27;_&#x27;))&#xA;    filename = filename.replace(&#x27; &#x27;,&#x27;_&#x27;)&#xA;    FILENAME_PATH = filename&#xA;    width_cmd = f&#x27;ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=nw=1:nk=1 {FILENAME_PATH}&#x27;&#xA;    height_cmd= f&#x27;ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=nw=1:nk=1 {FILENAME_PATH}&#x27;&#xA;&#xA;    width_result = subprocess.run(width_cmd.split(), stdout=subprocess.PIPE)&#xA;    width = width_result.stdout.strip().decode(&#x27;utf-8&#x27;)&#xA;&#xA;    height_result = subprocess.run(height_cmd.split(), stdout=subprocess.PIPE)&#xA;    height = height_result.stdout.strip().decode(&#x27;utf-8&#x27;)&#xA;&#xA;    if not os.path.exists(VIDEO_PATH):&#xA;        os.mkdir(VIDEO_PATH)&#xA;&#xA;    if resolution == 360: &#xA;        write_log(f&#x27;Encoding {filename} in 360p&#x27;) &#xA;        encode_360(filename)&#xA;&#xA;    if resolution == 720 :&#xA;        if int(height) >=400 :&#xA;            if int(height) &lt;= 700:&#xA;                query = f"""UPDATE videos SET encoding_status = &#x27;encoding480&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                executedb(query)&#xA;                write_log(f&#x27;Encoding {filename} in 480p&#x27;)&#xA;                encode_480(filename) &#xA;                query = f"""UPDATE videos SET encoding_status = &#x27;done480&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                executedb(query)&#xA;                query = f"""UPDATE videos SET quality = 2 WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                executedb(query)&#xA;            else:&#xA;                if int(height) >= 800:&#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;encoding720&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    write_log(f&#x27;Encoding {filename} in 720p&#x27;)&#xA;                    encode_720(filename)   &#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;done720&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    query = f"""UPDATE videos SET quality = 3 WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;encoding1080&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    write_log(f&#x27;Encoding {filename} in 720p&#x27;)&#xA;                    encode_1080(filename)   &#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;done1080&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    query = f"""UPDATE videos SET quality = 4 WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                else:&#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;encoding720&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    write_log(f&#x27;Encoding {filename} in 720p&#x27;)&#xA;                    encode_720(filename)   &#xA;                    query = f"""UPDATE videos SET encoding_status = &#x27;done720&#x27; WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                    query = f"""UPDATE videos SET quality = 3 WHERE file_uid LIKE &#x27;%{filename.replace(".mkv","")}&#x27;"""&#xA;                    executedb(query)&#xA;                &#xA;        &#xA;            &#xA;        os.remove(filename)&#xA;&#xA;&#xA;def move_to_rclone():&#xA;    if not os.path.exists(RCLONE_PATH):&#xA;        os.mkdir(RCLONE_PATH)&#xA;    folders = os.listdir(VIDEO_PATH)&#xA;    if len(folders) > 0:&#xA;        for folder in folders:&#xA;            folder_in_rclone = os.path.join(RCLONE_PATH, folder)&#xA;            if not os.path.exists(folder_in_rclone):&#xA;                os.mkdir(folder_in_rclone)&#xA;            files = os.listdir(os.path.join(VIDEO_PATH, folder))&#xA;            for file in files:&#xA;                os.replace(os.path.join(VIDEO_PATH, folder, file), os.path.join(folder_in_rclone, file))&#xA;            os.system(MOVE_CMD.format(folder_in_rclone))&#xA;        if len(os.listdir(os.path.join(VIDEO_PATH, folder))) == 0:&#xA;            os.rmdir(os.path.join(VIDEO_PATH, folder))&#xA;    # rclone_folders = os.listdir(RCLONE_PATH)&#xA;    # if len(rclone_folders)> 0:&#xA;    #     for rclone_folder in rclone_folders:&#xA;    #         os.system(MOVE_CMD.format(rclone_folder))&#xA;&#xA;def get_length(input_video):&#xA;    result = subprocess.run([&#x27;ffprobe&#x27;, &#x27;-v&#x27;, &#x27;error&#x27;, &#x27;-show_entries&#x27;, &#x27;format=duration&#x27;, &#x27;-of&#x27;, &#x27;default=noprint_wrappers=1:nokey=1&#x27;, input_video], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)&#xA;    try:&#xA;        output = float(result.stdout)&#xA;    except:&#xA;        output = 0&#xA;    return output&#xA;&#xA;def move_to_error(file):&#xA;    if not os.path.exists(ERROR_PATH):&#xA;        os.mkdir(ERROR_PATH)&#xA;    print(f&#x27;[red][-][/red] Moving {file} to the error folder&#x27;)&#xA;    os.replace(file, os.path.join(ERROR_PATH, file.split(&#x27;/&#x27;)[-1]))&#xA;&#xA;def main():&#xA;    db = sql.connect(&#xA;        host=MYSQL_HOST,&#xA;        user=MYSQL_USER,&#xA;        password=MYSQL_PASSWORD,&#xA;        database=MYSQL_DB&#xA;    )&#xA;&#xA;    def get_video_data(file_uid):&#xA;        cursor = db.cursor()&#xA;        query = f"""SELECT id, post_title, file_uid, group_id FROM videos WHERE file_uid LIKE %s"""&#xA;        cursor.execute(query, (f&#x27;%{file_uid}%&#x27;,))&#xA;        data = cursor.fetchone()&#xA;        return data if data else None&#xA;    &#xA;    if os.path.exists(UPLOAD_PATH):&#xA;        upload_files = os.listdir(UPLOAD_PATH)&#xA;        upload_files = [os.path.join(UPLOAD_PATH, x) for x in upload_files]&#xA;        upload_files.sort(key=lambda x: os.path.getmtime(x))&#xA;    else:&#xA;        upload_files = []&#xA;&#xA;    if len(upload_files) > 0:&#xA;        for upload_file in upload_files:&#xA;            if get_length(upload_file) &lt; VIDEO_LENGTH:&#xA;                move_to_error(upload_file)&#xA;                write_log(f&#x27;Length of {upload_file} is less than 60 sec.  Moving to error folder&#x27;)&#xA;                continue&#xA;            try:&#xA;                os.replace(upload_file, upload_file.split(&#x27;/&#x27;)[-1])&#xA;                query = f"""UPDATE videos SET encoding_status = &#x27;uploaded&#x27; WHERE file_uid LIKE &#x27;%{upload_file.replace(".mkv","").replace(".mp4","")}&#x27;"""&#xA;                executedb(query)&#xA;            except:&#xA;                print(e)&#xA;                continue&#xA;            change_all_videos_extension()&#xA;&#xA;            mkv_files = glob.glob(&#x27;*.mkv&#x27;)&#xA;            if len(mkv_files) > 0:&#xA;                for mkv_file in mkv_files:&#xA;                    try:&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;encoding360&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        vod(mkv_file, 360)&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;done360&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        query = f"""UPDATE videos SET quality = 1 WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;&#xA;                        &#xA;                        vod(mkv_file, 720)&#xA;                        &#xA;                    except Exception as e:&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;error&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        video_data = get_video_data(&#xA;                            mkv_file.replace(".mkv", ""))&#xA;                        if video_data:&#xA;                            cursor = db.cursor()&#xA;                            video_id, video_title, video_uid, group_id = video_data&#xA;                            error_log_query = f"""INSERT INTO error_logs (video_id, video_title, video_uid, group_id, log, created_at, updated_at) &#xA;                                                VALUES (%s, %s, %s, %s, %s, NOW(), NOW())"""&#xA;                            cursor.execute(&#xA;                                error_log_query, (video_id, video_title, video_uid, group_id, str(e)))&#xA;                            db.commit()&#xA;                        write_log(f&#x27;Error: {e}&#x27;)&#xA;                        move_to_error(mkv_file)&#xA;                    move_to_rclone()&#xA;    else:&#xA;        print(f&#x27;[{time_now()}] No new video found on upload folder&#x27;)&#xA;&#xA;    if os.path.exists(UPLOAD_PATH2):&#xA;        upload_files2 = os.listdir(UPLOAD_PATH2)&#xA;        upload_files2 = [os.path.join(UPLOAD_PATH2, x) for x in upload_files2]&#xA;        upload_files2.sort(key=lambda x: os.path.getmtime(x))&#xA;    else:&#xA;        upload_files2 = []&#xA;&#xA;    if len(upload_files2) > 0:&#xA;        for upload_file2 in upload_files2:&#xA;            if get_length(upload_file2) &lt; VIDEO_LENGTH:&#xA;                move_to_error(upload_file2)&#xA;                continue&#xA;            if len(os.listdir(UPLOAD_PATH)) != 0:&#xA;                main()&#xA;            try:&#xA;                os.replace(upload_file2, upload_file2.split(&#x27;/&#x27;)[-1])&#xA;                query = f"""UPDATE videos SET encoding_status = &#x27;uploaded&#x27; WHERE file_uid LIKE &#x27;%{upload_file2.replace(".mkv","").replace(".mp4","")}&#x27;"""&#xA;                executedb(query)&#xA;            except:&#xA;                continue&#xA;&#xA;            change_all_videos_extension()&#xA;&#xA;            mkv_files = glob.glob(&#x27;*.mkv&#x27;)&#xA;            if len(mkv_files) > 0:&#xA;                for mkv_file in mkv_files:&#xA;                    try:&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;encoding360&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        vod(mkv_file, 360)&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;done360&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        query = f"""UPDATE videos SET quality = 1 WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;&#xA;&#xA;                        vod(mkv_file, 720)&#xA;&#xA;                    except Exception as e:&#xA;                        query = f"""UPDATE videos SET encoding_status = &#x27;error&#x27; WHERE file_uid LIKE &#x27;%{mkv_file.replace(".mkv","")}&#x27;"""&#xA;                        executedb(query)&#xA;                        video_data = get_video_data(&#xA;                            mkv_file.replace(".mkv", ""))&#xA;                        if video_data:&#xA;                            cursor = db.cursor()&#xA;                            video_id, video_title, video_uid, group_id = video_data&#xA;                            error_log_query = f"""INSERT INTO error_logs (video_id, video_title, video_uid, group_id, log, created_at, updated_at) &#xA;                                                VALUES (%s, %s, %s, %s, %s, NOW(), NOW())"""&#xA;                            cursor.execute(&#xA;                                error_log_query, (video_id, video_title, video_uid, group_id, str(e)))&#xA;                            db.commit()&#xA;                        write_log(f&#x27;Error: {e}&#x27;)&#xA;                        move_to_error(mkv_file)&#xA;            move_to_rclone()&#xA;    else:&#xA;        print(f&#x27;[{time_now()}] No new video found on upload2 folder.&#x27;)&#xA;    move_to_rclone()&#xA;    db.close()&#xA;&#xA;if __name__=="__main__":&#xA;    while True:&#xA;        try:&#xA;            main()&#xA;        except Exception as e:&#xA;            print(f&#x27;Error: {e}&#x27;)&#xA;        for i in range(WAIT):&#xA;            print(f&#x27;[green][&#x2B;][/green] Waiting for {WAIT-i} seconds  &#x27;, end="\r")&#xA;            time.sleep(1)&#xA;&#xA;&#xA;

    &#xA;

    looking for suggestion to improve encoding speed

    &#xA;

  • avformat/segafilmenc : Postpone check for existence of video stream

    14 janvier 2020, par Andreas Rheinhardt
    avformat/segafilmenc : Postpone check for existence of video stream
    

    Up until now, the Sega FILM muxer complained if the first stream wasn't a
    video stream that there is no video stream at all which is of course
    nonsense. So postpone this check.

    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/segafilmenc.c