Recherche avancée

Médias (0)

Mot : - Tags -/auteurs

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

Autres articles (49)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

Sur d’autres sites (10995)

  • TypeError : must be real number, not NoneType using spyder anaconda

    13 août 2023, par faisal2k
    import moviepy.editor as mp
import tkinter as tk
from tkinter import filedialog
import math
from PIL import Image
import numpy


def zoom_in_effect(clip, zoom_ratio=0.02):
    def effect(get_frame, t):
        img = Image.fromarray(get_frame(t))
        base_size = img.size

        new_size = [
            math.ceil(img.size[0] * (1 + (zoom_ratio * t))),
            math.ceil(img.size[1] * (1 + (zoom_ratio * t)))
        ]

        # The new dimensions must be even.
        new_size[0] = new_size[0] + (new_size[0] % 2)
        new_size[1] = new_size[1] + (new_size[1] % 2)

        img = img.resize(new_size, Image.LANCZOS)

        x = math.ceil((new_size[0] - base_size[0]) / 2)
        y = math.ceil((new_size[1] - base_size[1]) / 2)

        img = img.crop([
            x, y, new_size[0] - x, new_size[1] - y
        ]).resize(base_size, Image.LANCZOS)

        #result = numpy.array(img)
        result = numpy.array(img, dtype=numpy.uint8)

        img.close()

        return result

    return clip.fl(effect)


    

def make_center_video():
    
    size = (1080, 1080)

    audio_file = '/home/faisal/pythonfiles/audio/tts_voice.wav'
    audio = mp.AudioFileClip(audio_file)
   
    root = tk.Tk()
    root.withdraw()
     
    print("waiting for Image Selection....")

    img = filedialog.askopenfilename()


    slide = mp.ImageClip(img).set_fps(29).set_duration(audio.duration).resize(size)
    slide = zoom_in_effect(slide, 0.02)
    slide.write_videofile('/home/faisal/pythonfiles/videos/zoom-short.mp4',codec='libx264',  fps=29)
    
    
    size = (600, 600)

 


    slide = mp.ImageClip(img).set_fps(29).set_duration(audio.duration).resize(size)
    slide = zoom_in_effect(slide, 0.02)
    slide.write_videofile('/home/faisal/pythonfiles/videos/zoom-wide.mp4',codec='libx264', fps=29)
    
import traceback

try:
    make_center_video()
except Exception as e:
    traceback.print_exc()
    print(f"An error occurred: {e}")


    


    I'm trying to make the zoom video using image but facing

    


    TypeError: must be real number, not NoneType.


    


    It used was to run but I don't remember if I might have updated numpy, ffmpeg, or any thing else that is now causing the error. I have tried the code on python 3.10 and 3.11 and get the same error in both. I was previously running it on python 3.10.

    


    An error occurred: must be real number, not NoneType&#xA;Traceback (most recent call last):&#xA;  File "/home/faisal/pythonfiles/code/zoom_video.py", line 76, in <module>&#xA;    make_center_video()&#xA;  File "/home/faisal/pythonfiles/code/zoom_video.py", line 61, in make_center_video&#xA;    slide.write_videofile(&#x27;/home/faisal/pythonfiles/videos/zoom-short.mp4&#x27;,codec=&#x27;libx264&#x27;,  fps=29)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/decorator.py", line 232, in fun&#xA;    return caller(func, *(extras &#x2B; args), **kw)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/decorators.py", line 54, in requires_duration&#xA;    return f(clip, *a, **k)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/decorator.py", line 232, in fun&#xA;    return caller(func, *(extras &#x2B; args), **kw)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/decorators.py", line 135, in use_clip_fps_by_default&#xA;    return f(clip, *new_a, **new_kw)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/decorator.py", line 232, in fun&#xA;    return caller(func, *(extras &#x2B; args), **kw)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/decorators.py", line 22, in convert_masks_to_RGB&#xA;    return f(clip, *a, **k)&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/video/VideoClip.py", line 300, in write_videofile&#xA;    ffmpeg_write_video(self, filename, fps, codec,&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", line 213, in ffmpeg_write_video&#xA;    with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,&#xA;  File "/home/faisal/anaconda3/envs/py-310/lib/python3.10/site-packages/moviepy/video/io/ffmpeg_writer.py", line 88, in __init__&#xA;    &#x27;-r&#x27;, &#x27;%.02f&#x27; % fps,&#xA;TypeError: must be real number, not NoneType&#xA;</module>

    &#xA;

  • ffmpeg "End mismatch 1" warning, jpeg2000 to avi

    11 avril 2023, par jklebes

    Trying to convert a directory of jpeg2000 grayscale images to a video with ffmpeg, I get warnings

    &#xA;

    [0;36m[jpeg2000 @ 0x55d8fa1b68c0] [0m[0;33mEnd mismatch 1&#xA;

    &#xA;

    (and lots of

    &#xA;

    Last message repeated <n> times&#xA;</n>

    &#xA;

    )

    &#xA;

    The command was

    &#xA;

    ffmpeg -y -r 10 -start_number 1 -i <path>/surface_30///img_000%01d.jp2 -vcodec msmpeg4 -vf scale=1920:-1 -q:v 8 <path>//surface_30///surface_30.avi&#xA;</path></path>

    &#xA;

    The output is

    &#xA;

    ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers&#xA;  built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0)&#xA;  configuration: --prefix=/home/jklebes001/miniconda3 --cc=/tmp/build/80754af9/ffmpeg_1587154242452/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-avresample --enable-gmp --enable-hardcoded-tables --enable-libfreetype --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame --disable-nonfree --enable-gpl --enable-gnutls --disable-openssl --enable-libopenh264 --enable-libx264&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;[0;36m[jpeg2000 @ 0x55cb44144480] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0m    Last message repeated 1 times&#xA;    Last message repeated 2 times&#xA;    Last message repeated 3 times&#xA;

    &#xA;

    ...

    &#xA;

    Last message repeated 73 times&#xA;&#xA;Input #0, image2, from &#x27;<path>//surface_30///img_000%01d.jp2&#x27;:&#xA;&#xA;  Duration: 00:00:00.20, start: 0.000000, bitrate: N/A&#xA;&#xA;    Stream #0:0: Video: jpeg2000, gray, 6737x4869, 25 tbr, 25 tbn, 25 tbc&#xA;&#xA;Stream mapping:&#xA;&#xA;  Stream #0:0 -> #0:0 (jpeg2000 (native) -> msmpeg4v3 (msmpeg4))&#xA;&#xA;Press [q] to stop, [?] for help&#xA;&#xA;[0;36m[jpeg2000 @ 0x55cb4418e200] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0m[0;36m[jpeg2000 @ 0x55cb441900c0] [0m[0;33mEnd mismatch 1&#xA;</path>

    &#xA;

    ...

    &#xA;

    (about 600 lines of "end mismatch" and "last message repeated" cut)

    &#xA;

    ...

    &#xA;

    [0m[0;36m[jpeg2000 @ 0x55cb4418e8c0] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0mOutput #0, avi, to &#x27;<path>/surface_30///surface_30.avi&#x27;:&#xA;&#xA;  Metadata:&#xA;&#xA;    ISFT            : Lavf58.29.100&#xA;&#xA;    Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 1920x1388, q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc&#xA;&#xA;    Metadata:&#xA;&#xA;      encoder         : Lavc58.54.100 msmpeg4&#xA;&#xA;    Side data:&#xA;&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1&#xA;&#xA;frame=    2 fps=0.8 q=8.0 size=       6kB time=00:00:00.20 bitrate= 227.1kbits/s speed=0.0844x    &#xA;frame=    5 fps=1.7 q=8.0 size=       6kB time=00:00:00.50 bitrate=  90.8kbits/s speed=0.172x    &#xA;frame=    5 fps=1.7 q=8.0 Lsize=     213kB time=00:00:00.50 bitrate=3494.7kbits/s speed=0.172x    &#xA;video:208kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.732246%&#xA;</path>

    &#xA;

    What is the meaning of characters like [0 ;33m here ?

    &#xA;

    I thought it might have something to do with bit depth and color format. Setting -pix_fmt gray had no effect, and indeed the format of the jp2 images is already detected as 8-bit gray.

    &#xA;

    The output .avi exists and seems fine.

    &#xA;

    The line was previously used on jpeg files and works fine on jpeg. With jpeg, the output has the line

    &#xA;

    Input #0, image2, from &#x27;<path>/surface_30///img_000%01d.jpeg&#x27;:&#xA;&#xA;  Duration: 00:00:00.16, start: 0.000000, bitrate: N/A&#xA;&#xA;    Stream #0:0: Video: mjpeg (Baseline), gray(bt470bg/unknown/unknown), 6737x4869 [SAR 1:1 DAR 6737:4869], 25 tbr, 25 tbn, 25 tbc&#xA;&#xA;Stream mapping:&#xA;&#xA;  Stream #0:0 -> #0:0 (mjpeg (native) -> msmpeg4v3 (msmpeg4))&#xA;&#xA;Press [q] to stop, [?] for help&#xA;&#xA;Output #0, avi, to &#x27;<path>/surface_30///surface_30.avi&#x27;:&#xA;&#xA;  Metadata:&#xA;&#xA;    ISFT            : Lavf58.29.100&#xA;&#xA;    Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 6737x4869 [SAR 1:1 DAR 6737:4869], q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc&#xA;&#xA;    Metadata:&#xA;&#xA;      encoder         : Lavc58.54.100 msmpeg4&#xA;&#xA;    Side data:&#xA;&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1&#xA;&#xA;frame=    2 fps=0.0 q=8.0 size=    6662kB time=00:00:00.20 bitrate=272859.9kbits/s speed=0.334x    &#xA;frame=    3 fps=2.2 q=10.0 size=   10502kB time=00:00:00.30 bitrate=286764.2kbits/s speed=0.22x    &#xA;frame=    4 fps=1.9 q=12.3 size=   13574kB time=00:00:00.40 bitrate=277987.7kbits/s speed=0.19x    &#xA;frame=    4 fps=1.4 q=12.3 size=   13574kB time=00:00:00.40 bitrate=277987.7kbits/s speed=0.145x    &#xA;frame=    4 fps=1.4 q=12.3 Lsize=   13657kB time=00:00:00.40 bitrate=279702.3kbits/s speed=0.145x    &#xA;video:13652kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.041926%&#xA;</path></path>

    &#xA;

    detecting mjpeg format and similar, but more detailed format gray(bt470bg/unknown/unknown), 6737x4869 [SAR 1:1 DAR 6737:4869].

    &#xA;

    What is the difference when switching input to jp2 ?

    &#xA;

  • Python asyncio subprocess code returns "pipe closed by peer or os.write(pipe, data) raised exception."

    4 novembre 2022, par Duke Dougal

    I am trying to convert a synchronous Python process to asyncio. Any ideas what I am doing wrong ?

    &#xA;

    This is the synchronous code which successfully starts ffmpeg and converts a directory of webp files into a video.

    &#xA;

    import subprocess&#xA;import shlex&#xA;from os import listdir&#xA;from os.path import isfile, join&#xA;&#xA;output_filename = &#x27;output.mp4&#x27;&#xA;process = subprocess.Popen(shlex.split(f&#x27;ffmpeg -y -framerate 60 -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 output.mp4&#x27;), stdin=subprocess.PIPE)&#xA;&#xA;thepath = &#x27;/home/ubuntu/webpfiles/&#x27;&#xA;thefiles = [f for f in listdir(thepath) if isfile(join(thepath, f))]&#xA;for filename in thefiles:&#xA;    absolute_path = f&#x27;{thepath}{filename}&#x27;&#xA;    with open(absolute_path, &#x27;rb&#x27;) as f:&#xA;        process.stdin.write(f.read())&#xA;&#xA;process.stdin.close()&#xA;process.wait()&#xA;process.terminate()&#xA;

    &#xA;

    This async code fails :

    &#xA;

    from os import listdir&#xA;from os.path import isfile, join&#xA;import shlex&#xA;import asyncio&#xA;&#xA;outputfilename = &#x27;output.mp4&#x27;&#xA;&#xA;async def write_stdin(proc):&#xA;    thepath = &#x27;/home/ubuntu/webpfiles/&#x27;&#xA;    thefiles = [f for f in listdir(thepath) if isfile(join(thepath, f))]&#xA;    thefiles.sort()&#xA;    for filename in thefiles:&#xA;        absolute_path = f&#x27;{thepath}{filename}&#x27;&#xA;        with open(absolute_path, &#x27;rb&#x27;) as f:&#xA;            await proc.communicate(input=f.read())&#xA;&#xA;async def create_ffmpeg_subprocess():&#xA;    bin = f&#x27;/home/ubuntu/bin/ffmpeg&#x27;&#xA;    params = f&#x27;-y -framerate 60 -i pipe: -vcodec libx265 -pix_fmt yuv420p -crf 24 {outputfilename}&#x27;&#xA;    proc = await asyncio.create_subprocess_exec(&#xA;        bin,&#xA;        *shlex.split(params),&#xA;        stdin=asyncio.subprocess.PIPE,&#xA;        stdout=asyncio.subprocess.PIPE,&#xA;        stderr=asyncio.subprocess.PIPE,&#xA;    )&#xA;    return proc&#xA;&#xA;async def start():&#xA;    loop = asyncio.get_event_loop()&#xA;    proc = await create_ffmpeg_subprocess()&#xA;    task_stdout = loop.create_task(write_stdin(proc))&#xA;    await asyncio.gather(task_stdout)&#xA;&#xA;if __name__ == &#x27;__main__&#x27;:&#xA;    asyncio.run(start())&#xA;

    &#xA;

    The output for the async code is :

    &#xA;

    pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;pipe closed by peer or os.write(pipe, data) raised exception.&#xA;

    &#xA;

    etc - one line for each webp file

    &#xA;