Recherche avancée

Médias (0)

Mot : - Tags -/flash

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (58)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • 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 (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (10298)

  • What causes an this error when using FFMPEG in Python ?

    30 mai 2022, par Vesero

    I'm trying to convert MP3 to OGG but it doesn't work. What's the problem ?
The paths to the audio files are correct. "ffmpeg.exe" is in the script directory.

    


    Code snippet from the program :

    


    def ProcessAudio(audioPath, destPath):
   inp = ffmpeg.input(audioPath)
   au = inp.audio
   stream = ffmpeg.output(au, destPath)
   ffmpeg.run(stream)

def Convert(listofmusic, pathofmsc, pathofdest, append):
   count = 0
   if len(listofmusic) >= 100:
      for i in range(100):
         count += 1
         out = mscPath + "/" + pathofdest + "/" + "track" + str(count) + ".ogg"
         print(out)
         ProcessAudio(audioFolder + "/" + listofmusic[i], out)
         break
      count = 0
   elif len(listofmusic) < 100:
      for i in range(len(listofmusic)):
         count += 1
         mscP = mscPath.replace("/", "\\")
         out = mscP + "\\" + pathofdest + "\\" + "track" + str(count) + ".ogg"
         print(out)
         audioProc = audioFolder + "\\" + listofmusic[i]
         print(audioProc)
         ProcessAudio(audioProc, out)
         break
      count = 0


    


    However, this code works fine :

    


    import ffmpeg

inputfile = ffmpeg.input("example.mp3")
iAudio = inputfile.audio
stream = ffmpeg.output(iAudio, "example.ogg")
ffmpeg.run(stream)


    


    Error :

    


    Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Santila\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
    return self.func(*args)
  File "C:\Users\Santila\Desktop\MSC_Audio_Converter.py", line 75, in pressed
    Convert(musicList, mscPath, oggFolder, cbVar.get())
  File "C:\Users\Santila\Desktop\MSC_Audio_Converter.py", line 52, in Convert
    ProcessAudio(audioProc, out)
  File "C:\Users\Santila\Desktop\MSC_Audio_Converter.py", line 32, in ProcessAudio
    ffmpeg.run(stream)
  File "C:\Users\Santila\AppData\Local\Programs\Python\Python310\lib\site-packages\ffmpeg\_run.py", line 325, in run
    raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)


    


  • Python cv2 script that scans a giant image to a video. Raises error : Unknown C++ exception from OpenCV code

    26 avril 2022, par Nolrenea

    I wrote a script that scans a giant image to make a video. Normally I just post my scripts straight to my Code Review account, but this script is ugly, needs to be refactored, implements only horizontal scrolling and contains a bug that I can't get rid of.

    


    It is working but not perfect, I can't get the last line at the bottom of the image, with height of image_height % 1080. If I ignore it, the code is working fine, if I try to fix it, it throws exceptions.

    


    Example :

    


    Original image (Google Drive)

    


    Video Output (Google Drive)

    


    As you can see from the video, everything is working properly except the fact that I can't get the bottom line.

    


    Full working code

    



    

    import cv2
import numpy as np
import random
import rpack
from fractions import Fraction
from math import prod

def resize_guide(image_size, target_area):
    aspect_ratio = Fraction(*image_size).limit_denominator()
    horizontal = aspect_ratio.numerator
    vertical = aspect_ratio.denominator
    unit_length = (target_area/(horizontal*vertical))**.5
    return (int(horizontal*unit_length), int(vertical*unit_length))

fourcc = cv2.VideoWriter_fourcc(*'h264')
FRAME = np.zeros((1080, 1920, 3), dtype=np.uint8)

def new_frame():
    return np.ndarray.copy(FRAME)

def center(image):
    frame = new_frame()
    h, w = image.shape[:2]
    yoff = round((1080-h)/2)
    xoff = round((1920-w)/2)
    frame[yoff:yoff+h, xoff:xoff+w] = image
    return frame

def image_scanning(file, fps=60, pan_increment=64, horizontal_increment=8, fast_decrement=256):
    image = cv2.imread(file)
    height, width = image.shape[:2]
    assert width*height >= 1920*1080
    video_writer = cv2.VideoWriter(file+'.mp4', fourcc, fps, (1920, 1080))
    fit_height = True
    if height < 1080:
        width = width*1080/height
        image = cv2.resize(image, (width, 1080), interpolation = cv2.INTER_AREA)
    aspect_ratio = width / height
    zooming_needed = False
    if 4/9 <= aspect_ratio <= 16/9:
        new_width = round(width*1080/height)
        fit = cv2.resize(image, (new_width, 1080), interpolation = cv2.INTER_AREA)
        zooming_needed = True
    
    elif 16/9 < aspect_ratio <= 32/9:
        new_height = round(height*1920/width)
        fit = cv2.resize(image, (1920, new_height), interpolation = cv2.INTER_AREA)
        fit_height = False
        zooming_needed = True
    
    centered = center(fit)
    for i in range(fps):
        video_writer.write(centered)
    if fit_height:
        xoff = round((1920 - new_width)/2)
        while xoff:
            if xoff - pan_increment >= 0:
                xoff -= pan_increment
            else:
                xoff = 0
            frame = new_frame()
            frame[0:1080, xoff:xoff+new_width] = fit
            video_writer.write(frame)
    else:
        yoff = round((1080 - new_height)/2)
        while yoff:
            if yoff - pan_increment >= 0:
                yoff -= pan_increment
            else:
                yoff = 0
            frame = new_frame()
            frame[yoff:yoff+new_height, 0:1920] = fit
            video_writer.write(frame)
    
    if zooming_needed:
        if fit_height:
            width_1, height_1 = new_width, 1080
        else:
            width_1, height_1 = 1920, new_height
        new_area = width_1 * height_1
        original_area = width * height
        area_diff = original_area - new_area
        unit_diff = area_diff / fps
        for i in range(1, fps+1):
            zoomed = cv2.resize(image, resize_guide((width_1, height_1), new_area+unit_diff*i), interpolation=cv2.INTER_AREA)
            zheight, zwidth = zoomed.shape[:2]
            zheight = min(zheight, 1080)
            zwidth = min(zwidth, 1920)
            frame = new_frame()
            frame[0:zheight, 0:zwidth] = zoomed[0:zheight, 0:zwidth]
            video_writer.write(frame)
    y, x = 0, 0
    completed = False
    while y != height - 1080:
        x = 0
        while x != width - 1920:
            if x + horizontal_increment + 1920 <= width:
                x += horizontal_increment
                frame = image[y:y+1080, x:x+1920]
                video_writer.write(frame)
            else:
                x = width - 1920
                frame = image[y:y+1080, x:x+1920]
                for i in range(round(fps/3)):
                    video_writer.write(frame)
                if y == height - 1080:
                    completed = True
        while x != 0:
            if x - fast_decrement - 1920 >= 0:
                x -= fast_decrement
            else:
                x = 0
            frame = image[y:y+1080, x:x+1920]
            video_writer.write(frame)
        if y + 2160 <= height:
            y += 1080
        else:
            y = height - 1080
    cv2.destroyAllWindows()
    video_writer.release()
    del video_writer


    


    The above the the code needed to produce the example video. It is working but the bottom line is missing.

    


    Now if I change the last few lines to this :

    


            if y + 2160 <= height:
            y += 1080
        else:
            y = height - 1080
            x = 0
            while x != width - 1920:
                if x + horizontal_increment + 1920 <= width:
                    x += horizontal_increment
                    frame = image[y:y+1080, x:x+1920]
                    video_writer.write(frame)
    cv2.destroyAllWindows()
    video_writer.release()
    del video_writer


    


    I expect it to include the bottom line, but it just throws exceptions instead :

    


    OpenCV: FFMPEG: tag 0x34363268/&#x27;h264&#x27; is not supported with codec id 27 and format &#x27;mp4 / MP4 (MPEG-4 Part 14)&#x27;&#xA;OpenCV: FFMPEG: fallback to use tag 0x31637661/&#x27;avc1&#x27;&#xA;---------------------------------------------------------------------------&#xA;error                                     Traceback (most recent call last)&#xA; in <module>&#xA;----> 1 image_scanning("D:/collages/91f53ebcea2a.png")&#xA;&#xA; in image_scanning(file, fps, pan_increment, horizontal_increment, fast_decrement)&#xA;    122                     x &#x2B;= horizontal_increment&#xA;    123                     frame = image[y:y&#x2B;1080, x:x&#x2B;1920]&#xA;--> 124                     video_writer.write(frame)&#xA;    125     cv2.destroyAllWindows()&#xA;    126     video_writer.release()&#xA;&#xA;error: Unknown C&#x2B;&#x2B; exception from OpenCV code&#xA;</module>

    &#xA;

    (If you can't get the example code working I can't help you, but I am using Python 3.9.10 x64 on Windows 10, and I have this file : "C :\Windows\System32\openh264-1.8.0-win64.dll", the '.avi' format generates video files with Gibibytes (binary unit, not SI Gigabyte) of size)

    &#xA;

    How to get rid of the exception ?

    &#xA;

  • Having problem in video stegano, the hiden message always lost

    5 avril 2022, par user7025125

    friend, i am currently looking for a way to video stegano. I successfully in splitting frames from video file and hide messages inside them. But when i combine these frames into video and trying to extract info from the hiden video, i always failed. I guess here is problem with video compression.

    &#xA;

    Here is my code.

    &#xA;

    from stegano import lsb&#xA;from os.path import isfile, join&#xA;&#xA;import time  # install time ,opencv,numpy modules&#xA;import cv2&#xA;import numpy as np&#xA;import math&#xA;import os&#xA;import shutil&#xA;from moviepy.editor import *&#xA;from subprocess import call, STDOUT&#xA;&#xA;&#xA;def split_string(s_str, count=10):&#xA;    per_c = math.ceil(len(s_str)/count)&#xA;    c_cout = 0&#xA;    out_str = &#x27;&#x27;&#xA;    split_list = []&#xA;    for s in s_str:&#xA;        out_str &#x2B;= s&#xA;        c_cout &#x2B;= 1&#xA;        if c_cout == per_c:&#xA;            split_list.append(out_str)&#xA;            out_str = &#x27;&#x27;&#xA;            c_cout = 0&#xA;    if c_cout != 0:&#xA;        split_list.append(out_str)&#xA;    return split_list&#xA;&#xA;&#xA;def frame_extraction(video):&#xA;    if not os.path.exists("./tmp"):&#xA;        os.makedirs("tmp")    &#xA;    temp_folder = "./tmp"&#xA;    print("[INFO] tmp directory is created")&#xA;&#xA;    vidcap = cv2.VideoCapture(video)&#xA;    count = 0&#xA;&#xA;    while True:&#xA;        success, image = vidcap.read()&#xA;        if not success:&#xA;            break&#xA;        cv2.imwrite(os.path.join(temp_folder, "{:d}.png".format(count)), image)&#xA;        count &#x2B;= 1&#xA;        print("[INFO] frame {} is extracted".format(count))&#xA;&#xA;&#xA;def encode_string(input_string, root="./tmp/"):&#xA;    split_string_list = split_string(input_string)&#xA;    for i in range(0, len(split_string_list)):&#xA;        f_name = "{}{}.png".format(root, i)&#xA;        secret_enc = lsb.hide(f_name, split_string_list[i])&#xA;        secret_enc.save(f_name)&#xA;        print("[INFO] frame {} holds {}".format(f_name, lsb.reveal(f_name)))&#xA;&#xA;&#xA;def decode_string(video):&#xA;    frame_extraction(video)&#xA;    secret = []&#xA;    root = "./tmp/"&#xA;    for i in range(len(os.listdir(root))):&#xA;        f_name = "{}{}.png".format(root, i)&#xA;        print("[INFO] frame {} is decoding".format(f_name))&#xA;        secret_dec = lsb.reveal(f_name)&#xA;        if secret_dec == None:&#xA;            break&#xA;        secret.append(secret_dec)&#xA;    print("[INFO] secret is {}".format("".join(secret)))&#xA;    print(&#x27;&#x27;.join([i for i in secret]))&#xA;    # clean_tmp()&#xA;&#xA;&#xA;def clean_tmp(path="./tmp"):&#xA;    if os.path.exists(path):&#xA;        shutil.rmtree(path)&#xA;        print("[INFO] tmp files are cleaned up")&#xA;&#xA;&#xA;def main():&#xA;    input_string = input("Enter the input string: ")&#xA;    f_name = input("enter the name of video: ")&#xA;&#xA;    # 从源文件分离出帧&#xA;    frame_extraction(f_name)&#xA;    &#xA;    # 分离文件路径和扩展名&#xA;    file_path, file_extraction = os.path.splitext(f_name)&#xA;    &#xA;    # 创建输出音频文件&#xA;    audio_path = file_path &#x2B; "_temp.mp3"&#xA;    video = VideoFileClip(f_name)&#xA;    video.audio.write_audiofile(audio_path)&#xA;&#xA;    # 加密字符&#xA;    encode_string(input_string)&#xA;&#xA;    # 从tmp文件夹的图片创建没有声音的视频&#xA;    fps=30&#xA;    img_root = r"./tmp/"&#xA;    # fourcc = cv2.VideoWriter_fourcc(*&#x27;mp4v&#x27;)&#xA;    fourcc = cv2.VideoWriter_fourcc(*&#x27;XVID&#x27;)&#xA;    video_file_path = file_path &#x2B; "_temp.avi"&#xA;    # 获取tmp文件夹第一张视频的尺寸&#xA;    img = cv2.imread(img_root &#x2B; "0.png")&#xA;    height, width, layers = img.shape&#xA;    size=(width,height)&#xA;    videoWriter = cv2.VideoWriter(video_file_path,fourcc=fourcc,fps=fps,frameSize=size)&#xA;    for i in range(len(os.listdir(img_root))):&#xA;        frame = cv2.imread(img_root&#x2B;str(i)&#x2B;&#x27;.png&#x27;)&#xA;        videoWriter.write(frame)&#xA;    videoWriter.release()&#xA;&#xA;    # 合并视频和音频     audio_path   video_file_path&#xA;    video = VideoFileClip(video_file_path)&#xA;    audio_clip = AudioFileClip(audio_path)&#xA;    video = video.set_audio(audio_clip)&#xA;    video.write_videofile(file_path &#x2B; "_hide.avi")&#xA;    clean_tmp()&#xA;&#xA;&#xA;if __name__ == "__main__":&#xA;    while True:&#xA;        print("1.Hide a message in video 2.Reveal the secret from video")&#xA;        print("any other value to exit")&#xA;        choice = input()&#xA;        if choice == &#x27;1&#x27;:&#xA;            main()&#xA;        elif choice == &#x27;2&#x27;:&#xA;            decode_string(input("enter the name of video with extension: "))&#xA;        else:&#xA;            break&#xA;&#xA;

    &#xA;

    I have tried mp4, avi, wov format. But none of them worked.

    &#xA;

    IF YOU HAVE ANY IDEA OR SUGGESTION GIVEN TO ME, I WOULD BE VERY GRATEFUL

    &#xA;