Recherche avancée

Médias (0)

Mot : - Tags -/upload

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

Autres articles (48)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (11145)

  • How to process h264 formatted video, modify each frame & create the another h264 formatted video with the processed images using openCV/ffmpeg

    29 décembre 2019, par Rahul Talole

    I want to process a "h264" formatted video frame by frame. Process the frame to add some kind of noise in the same (for ex. salt & pepper noise) & recreate the "h264" formatted video from the processed images (noisy images) with the same sequence as the original "h264" video.

    I tried the same using the openCV but I am not getting any workable specific codec (required by cv2.VideoWriter) to create the h264 formatted video. So, I have created the mp4 video of the noisy images & then converted the same from mp4 to h264 format using ffmpeg. But I guess I am loosing too much information from the original frame due to h264 -> mp4 -> h264 conversion. Below is the code written by me for the same.

    import numpy as np
    import os
    from skimage.util import random_noise


    def processVideo(videoPath, noiseType="", outVideoPath=""):
       """
       Add the specified noise in the provided video.

       videoPath: Video file path
       noiseType: noise type which needs to be added in the video.
                   Supported noise types: gaussian, localvar, poisson, salt, pepper, s&p, speckle
       Returns:
           Noisy video path, in case of success
           None, in case of failure
       """
       if noiseType not in ['gaussian', 'localvar', 'poisson', 'salt', 'pepper', 's&p']:
           print "noiseType is not specified."
           return None
       videoPath = os.path.abspath(videoPath)
       print "The video path under process: {}".format(videoPath)
       if outVideoPath:
           outVideoPath = os.path.abspath(outVideoPath)
       else:
           outVideoPath = os.path.abspath(os.path.dirname(videoPath))

       if os.path.exists(videoPath):
           video = cv2.VideoCapture(videoPath)

           if os.path.isdir(outVideoPath):
               outVideoPath = os.path.join(outVideoPath, os.path.splitext(
                   os.path.basename(videoPath))[0] + "_Noisy" + ".mp4")
           elif os.path.exists(outVideoPath):
               print "The given location already contains the file named {}.\nPlease delete the same.".format(outVideoPath)
               return None
           elif os.path.exists(os.path.dirname(outVideoPath)):
               outVideoPath = os.path.splitext(outVideoPath)[0] + ".mp4"
           else:
               print "The given location {} does not exists".format(os.path.dirname(outVideoPath))
               return None

           fourcc = cv2.VideoWriter_fourcc(*'MP4V')
           frame_width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
           frame_height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
           video_fps = int(video.get(cv2.CAP_PROP_FPS))
           totalFrames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
           print "Total Frames in video = ", totalFrames
           out = cv2.VideoWriter(outVideoPath, fourcc, video_fps, (frame_width, frame_height))

           while (video.isOpened()):
               ret, frame = video.read()
               if ret is True:
                   noise_img = random_noise(frame, mode=noiseType)
                   noise_img = np.array(255 * noise_img, dtype='uint8')
                   out.write(frame)
               else:
                   video.release()
                   out.release()
                   break
           return outVideoPath
       else:
           print "Provided Video Path: {} is not present in the specified location.".format(videoPath)
           return None


    def mp4Toh264VideoConv(mp4VideoPath, h264VideoPath=""):
       mp4VideoPath = os.path.abspath(mp4VideoPath)
       print "h264 video:", os.path.abspath(h264VideoPath)
       if h264VideoPath:
           h264VideoPath = os.path.abspath(h264VideoPath)
       else:
           h264VideoPath = os.path.abspath(os.path.dirname(mp4VideoPath))

       if os.path.isdir(os.path.abspath(h264VideoPath)):
           h264VideoPath = os.path.join(h264VideoPath, os.path.splitext(os.path.basename(mp4VideoPath))[0] + ".h264")
       elif os.path.exists(h264VideoPath):
           print "The given location already contains the file named {}.\nPlease delete the same.".format(h264VideoPath)
           return None
       elif os.path.exists(os.path.dirname(h264VideoPath)):
           h264VideoPath = os.path.splitext(h264VideoPath)[0] + ".h264"
       else:
           print "The given location {} does not exists.".format(os.path.dirname(h264VideoPath))
           return None
       print "The h264 video path: ", h264VideoPath
       os.system('ffmpeg -i ' + mp4VideoPath + ' -an -vcodec libx264 -crf 23 ' + h264VideoPath)
       return h264VideoPath


    if __name__ == "__main__":
       import argparse
       parser = argparse.ArgumentParser(description='This script will add the specified noise in the given h264 video.')
       parser.add_argument('-i', '--inputVideo', help='Input h264 formated Video Path', required=True)
       parser.add_argument('-o', '--outputVideo', help='Output video path location', default="", required=False)
       parser.add_argument('-n', '--noiseType', help='Type of noise to add in the video', default='', required=True)

       args = vars(parser.parse_args())
       inputVideo = os.path.expanduser(args['inputVideo'])
       outputVideo = os.path.expanduser(args['outputVideo'])
       noiseType = args['noiseType']

       if os.path.splitext(inputVideo)[1].upper() != ".H264":
           print os.path.splitext(inputVideo)[1].upper()
           print "Noise Addition in {} formated video is not supported".format(os.path.splitext(inputVideo)[1])
           exit(-1)
       else:
           noisymp4Video = processVideo(videoPath=inputVideo, noiseType=noiseType, outVideoPath=outputVideo)
           if noisymp4Video:
               mp4Toh264VideoConv = mp4Toh264VideoConv(mp4VideoPath=noisymp4Video, h264VideoPath=outputVideo)
               exit(0)
           else:
               exit(-1)

    I need some better way to directly process the h264 video, do some modifications in frame & create a h264 video. I am OK if this can be possible with the ffmpeg & openCV combinations. I just need some better way to prevent the loss due to h264 -> mp4 -> h264 conversion.

    Help will be appreciated.

  • ffmpeg commands not working in micromax android

    10 février 2014, par pavan

    I am able to execute ffmpeg commands on android devices like Samsung,LG and Sony but in Micromax it's not working. I have built ffmpeg library for arm processor. I could not collect the log because I am not able to connect the device. I have following questions on this,
    1) Why it's not working on Micromax ?
    2) I do not want to show my app on other device apart from ARM based android device, is it possible to control ?

    The below configuration I have used while building ffmpeg,

     !/bin/bash

    cd ffmpeg

    export TMPDIR=tmp
    mkdir -p $TMPDIR

    Android NDK Location

    NDK=/Users/sunitha/Downloads/android-ndk-r9c

    ANDROID_API=android-9
    SYSROOT=$NDK/platforms/$ANDROID_API/arch-arm
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86
    CROSS_PREFIX=$PREBUILT/bin/arm-linux-androideabi-
    ARM_INCLUDE=$SYSROOT/usr/include
    ARM_LIB=$SYSROOT/usr/lib
    PREFIX=../build
    OPTIMIZE_CFLAGS=" -marm -march=armv6 "
    ADDITIONAL_CONFIGURE_FLAG=

    Location of lame's static installation

    MP3LAME=../libmp3lame
    X264=../libx264

    ./configure \
    —arch=arm \
    —target-os=linux \
    —enable-cross-compile \
    —cross-prefix=$CROSS_PREFIX \
    —prefix=$PREFIX \
    —sysroot=$SYSROOT \
    —extra-cflags=" -I$ARM_INCLUDE -I$MP3LAME/include -I$X264/include -DANDROID $OPTIMIZE_CFLAGS" \
    —extra-ldflags=" -L$ARM_LIB -L$MP3LAME/lib -L$X264/lib" \
    —disable-debug \
    —enable-libmp3lame \
    —enable-libx264 \
    —disable-ffplay \
    —disable-ffprobe \
    —disable-ffserver \
    —enable-avfilter \
    —enable-decoders \
    —enable-demuxers \
    —enable-encoders \
    —enable-filters \
    —enable-indevs \
    —enable-network \
    —enable-parsers \
    —enable-protocols \
    —enable-swscale \
    —enable-gpl \
    —enable-nonfree \
    $ADDITIONAL_CONFIGURE_FLAG

    cd ..

  • Opening and reading a media file in android using ffmpeg

    29 octobre 2013, par ssrp

    I am developing an android project which has to open and read a MVC video file and save the streams separately in another location. I have done the basic steps for building ffmpeg for android and calling a c function through JNI. I want to know where do I have to put media files for doing above operations to it calling a C function in the C source file where I have all the Native function's implementations.