Recherche avancée

Médias (91)

Autres articles (55)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

  • Sélection de projets utilisant MediaSPIP

    29 avril 2011, par

    Les exemples cités ci-dessous sont des éléments représentatifs d’usages spécifiques de MediaSPIP pour certains projets.
    Vous pensez avoir un site "remarquable" réalisé avec MediaSPIP ? Faites le nous savoir ici.
    Ferme MediaSPIP @ Infini
    L’Association Infini développe des activités d’accueil, de point d’accès internet, de formation, de conduite de projets innovants dans le domaine des Technologies de l’Information et de la Communication, et l’hébergement de sites. Elle joue en la matière un rôle unique (...)

Sur d’autres sites (3822)

  • Increase the bitrate tolerance of ffmpeg for creating screenshots of a movie

    21 septembre 2012, par rekire

    I'm getting the error bitrate tolerance too small for bitrate so far no problem. I know that there are several switches to increase that but nothing works.

    ffmpeg -y -r 1/30 -b:v 999999k -bt 999999k -maxrate 999999k -i in.flv out%03d.jpg

    The source of that commandline is directly from ffmpeg. But that crashes :

    ffmpeg version N-44123-g5d55830 Copyright (c) 2000-2012 the FFmpeg developers
     built on Sep  2 2012 20:23:29 with gcc 4.7.1 (GCC)
     [...]
    Input #0, flv, from 'in.flv':
     Duration: 00:05:00.13, start: 0.000000, bitrate: 259 kb/s
       Stream #0:0: Video: flv1, yuv420p, 320x240, 1k tbr, 1k tbn, 1k tbc
       Stream #0:1: Audio: nellymoser, 22050 Hz, mono, s16
    [mjpeg @ 04356860] bitrate tolerance too small for bitrate
    [mjpeg @ 04317540] ff_frame_thread_encoder_init failed
    Output #0, image2, to 'out%03d.jpg':
       Stream #0:0: Video: mjpeg, yuvj420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 0.03 tbc
    Stream mapping:
     Stream #0:0 -> #0:0 (flv -> mjpeg)
    Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

    Some ideas what I'm doing wrong ?

  • Django api returns Gif as JPG despite a function to add it as video

    7 septembre 2023, par Earthling

    I'm trying to upload a .gif to my django 3.2 api. I have already ran troubleshoots through Postman and came to the conclusion that my flutter app sends it as a .gif and it gets returned as a .jpg. The problem is on the backend. Here is my relevant code which checks for file_meme subtype and then the function should convert the incoming .gif to a video :

    


    

    

    def add_media(self, file, order=None):
    check_can_add_media(post=self)

    is_in_memory_file = isinstance(file, InMemoryUploadedFile) or isinstance(file, SimpleUploadedFile)

    if is_in_memory_file:
        file_mime = magic.from_buffer(file.read())
    elif isinstance(file, TemporaryUploadedFile):
        file_mime = magic.from_file(file.temporary_file_path())
    else:
        file_mime = magic.from_file(file.name)

    check_mimetype_is_supported_media_mimetypes(file_mime)
    # Mime check moved pointer
    file.seek(0)

    file_mime_types = file_mime.split('/')

    file_mime_type = file_mime_types[0]
    file_mime_subtype = file_mime_types[1]

    temp_files_to_close = []

    if file_mime_subtype == 'gif':
                if is_in_memory_file:
                    file = write_in_memory_file_to_disk(file)

                temp_dir = tempfile.gettempdir()
                converted_gif_file_name = os.path.join(temp_dir, str(uuid.uuid4()) + '.mp4')

                ff = ffmpy.FFmpeg(
                    inputs={file.temporary_file_path() if hasattr(file, 'temporary_file_path') else file.name: None},
                    outputs={converted_gif_file_name: None})
                ff.run()
                converted_gif_file = open(converted_gif_file_name, 'rb')
                temp_files_to_close.append(converted_gif_file)
                file = File(file=converted_gif_file)
                file_mime_type = 'video'

            has_other_media = self.media.exists()
    
    if file_mime_type == 'image':
        post_image = self._add_media_image(image=file, order=order)
        if not has_other_media:
            self.media_width = post_image.width
            self.media_height = post_image.height
            self.media_thumbnail = file

    elif file_mime_type == 'video':
        post_video = self._add_media_video(video=file, order=order)
        if not has_other_media:
            self.media_width = post_video.width
            self.media_height = post_video.height
            self.media_thumbnail = post_video.thumbnail.file
    else:
        raise ValidationError(
            _('Unsupported media file type')
        )

    for file_to_close in temp_files_to_close:
        file_to_close.close()
            
            
    self.save()        

    


    


    



    def _add_media_image(self, image, order):
    return PostImage.create_post_media_image(image=image, post_id=self.pk, order=order)

def _add_media_video(self, video, order):
    return PostVideo.create_post_media_video(file=video, post_id=self.pk, order=order)


@classmethod
    def create_post_media_image(cls, image, post_id, order):
        hash = sha256sum(file=image.file)
        post_image = cls.objects.create(image=image, post_id=post_id, hash=hash, thumbnail=image)
        PostMedia.create_post_media(type=PostMedia.MEDIA_TYPE_IMAGE,
                                    content_object=post_image,
                                    post_id=post_id, order=order)
        return post_image


@classmethod
    def create_post_media_video(cls, file, post_id, order):
        hash = sha256sum(file=file.file)
        video_backend = get_backend()

        if isinstance(file, InMemoryUploadedFile):
            # If its in memory, doing read shouldn't be an issue as the file should be small.
            in_disk_file = write_in_memory_file_to_disk(file)
            thumbnail_path = video_backend.get_thumbnail(video_path=in_disk_file.name, at_time=0.0)
        else:
            thumbnail_path = video_backend.get_thumbnail(video_path=file.file.name, at_time=0.0)

        with open(thumbnail_path, 'rb+') as thumbnail_file:
            post_video = cls.objects.create(file=file, post_id=post_id, hash=hash, thumbnail=File(thumbnail_file), )
        PostMedia.create_post_media(type=PostMedia.MEDIA_TYPE_VIDEO,
                                    content_object=post_video,
                                    post_id=post_id, order=order)
        return post_video
        
    


    


    I'm not sure where the problem is. From my limited understanding, it is taking only the first frame of the .gif and uploading it as an image.

    


  • Python & OpenCV - VideoCapture.read() always returns false

    21 août 2017, par Julen

    I need to extract frames from a video at a given time, and I’m using OpenCV for it. I’m using Linux Mint 18.1, but it must also run on Ubuntu.

    This code example is not working for me :

    import cv2

    print('making screenshot from {0}'.format('/tmp/big_buck_bunny_720p_5mb.mp4'))

    cap = cv2.VideoCapture(video_path)
    cap.set(cv2.CAP_PROP_POS_MSEC,1000)
    ret,frame = cap.read()
    print(ret)                      # This is false
    cv2.imwrite("image.jpg", frame) # Creates an empty file

    (I’ve checked that the path of the video is correct and that the file is not corrupted).

    I have installed the Python OpenCV 3.3.0 version :

    >>> import cv2
    >>> cv2.__version__
    '3.3.0'

    I’ve compiled and installed the source for OpenCV (with the WITH_FFMPEG=ON option) :

    git clone https://github.com/Itseez/opencv.git /tmp/opencv-3                                                                                                                                                                                
    /tmp/opencv-3                                                                                                                                                                                                                            
    mkdir -p release                                                                                                                                                                                                                            
    cd release                                                                                                                                                                                                                                  
    cmake -D WITH_FFMPEG=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..                                                                                                                                                  
    make                                                                                                                                                                                                                                        
    sudo make install    

    The output of ffmpeg -version is the following :

    ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
    configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
    libavutil      54. 31.100 / 54. 31.100
    libavcodec     56. 60.100 / 56. 60.100
    libavformat    56. 40.101 / 56. 40.101
    libavdevice    56.  4.100 / 56.  4.100
    libavfilter     5. 40.101 /  5. 40.101
    libavresample   2.  1.  0 /  2.  1.  0
    libswscale      3.  1.101 /  3.  1.101
    libswresample   1.  2.101 /  1.  2.101
    libpostproc    53.  3.100 / 53.  3.100

    What am I missing ?