Recherche avancée

Médias (91)

Autres articles (31)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (4510)

  • How to use (django-celery,RQ) worker to execute a video filetype conversion (ffmpeg) in django on heroku (My code works locally)

    15 janvier 2013, par GetItDone

    One part of my website includes a form that allows users to upload video. I use ffmpeg to convert the video to flv. My media and static files are stored on Amazon S3. I can get everything to work perfectly locally, however I can't seem to figure out how to use a worker to run the video conversion subprocess in production. I have dj-celery and rq installed in my app. The code in my view that I was able to get to work locally is :

    #views.py
    def upload_broadcast(request):
       if request.method == 'POST':
           form = VideoUploadForm(request.POST, request.FILES)
           if form.is_valid():
               new_video=form.save()
               def convert_to_flv(video):
                   filename = video.video_upload
                   sourcefile = "%s%s" % (settings.MEDIA_ROOT, filename)
                   flvfilename = "%s.flv" % video.id
                   imagefilename = "%s.png" % video.id
                   thumbnailfilename = "%svideos/flv/%s" % (settings.MEDIA_ROOT, imagefilename)
                   targetfile = "%svideos/flv/%s" % (settings.MEDIA_ROOT, flvfilename)
                   ffmpeg = "ffmpeg -i %s -acodec mp3 -ar 22050 -f flv -s 320x240 %s" % (sourcefile, targetfile)
                   grabimage = "ffmpeg -y -i %s -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo -s 320x240 %s" % (sourcefile, thumbnailfilename)
                   print ("SOURCE: %s" % sourcefile)
                   print ("TARGET: %s" % targetfile)
                   print ("TARGET IMAGE: %s" % thumbnailfilename)
                   print ("FFMPEG TASK CODE: %s" % ffmpeg)
                   print ("IMAGE TASK CODE: %s" % grabimage)
                   try:
                       ffmpegresult = subprocess.call(ffmpeg)
                       print "---------------FFMPEG---------------"
                       print ffmpegresult
                   except:
                       print "Not working."
                   try:
                       videothumbnail = subprocess.call(grabimage)
                       print "---------------IMAGE---------------"
                       print videothumbnail
                   except:
                       print "Not working."
                   video.flvfilename = flvfilename
                   video.videothumbnail = imagefilename
                   video.save()

               convert_to_flv(new_video)

               return HttpResponseRedirect('/video_list/')
       else:
    ...

    This is my first time trying to use a worker (or ever pushing a project to production), so even with the documentation it is still unclear to me what I need to do. I have tried several different things but nothing seems to work. Is there just a simple way to tell celery to run the ffmpegresult = subprocess.call(ffmpeg) ? Thanks in advance for any help or insight.

    EDIT- Added heroku logs

    2013-01-10T20:58:57+00:00 app[web.1]: TARGET: /media/videos/flv/8.flv
    2013-01-10T20:58:57+00:00 app[web.1]: IMAGE TASK CODE: ffmpeg -y -i /media/videos/practice.wmv -vframes 1 -ss 00:00:02 - an -vcodec png -f rawvideo -s 320x240 /media/videos/flv/8.png
    2013-01-10T20:58:57+00:00 app[web.1]: SOURCE: /media/videos/practice.wmv
    2013-01-10T20:58:57+00:00 app[web.1]: FFMPEG TASK CODE: ffmpeg -i /media/videos/practice.wmv -acodec mp3 -ar 22050 -f fl v -s 320x240 /media/videos/flv/8.flv
    2013-01-10T20:58:57+00:00 app[web.1]: TARGET IMAGE: /media/videos/flv/8.png
    2013-01-10T20:58:57+00:00 app[web.1]: Not working.
    2013-01-10T20:58:57+00:00 app[web.1]: Not working.

    NEWER EDIT

    I tried adding a tasks.py and added the task :

    celery = Celery('tasks', broker='redis://guest@localhost//')

    @celery.task
    def ffmpeg_task(video):
       converted_file = subprocess.call(video)
       return converted_file

    then I changed the relevant section of my view to :

    ...
    try:
       ffmpeg_task.delay(ffmpeg)
       print "---------------FFMPEG---------------"
       print ffmpegresult
    except:
       print "Not working."
    ...

    My new logs are :

    2013-01-15T13:19:52+00:00 app[web.1]: TARGET IMAGE: /media/videos/flv/12.png
    2013-01-15T13:19:52+00:00 app[web.1]: SOURCE: /media/videos/practice.wmv
    2013-01-15T13:19:52+00:00 app[web.1]: FFMPEG TASK CODE: ffmpeg -i /media/videos/practice.wmv -acodec mp3 -ar 22050 -f fl v -s 320x240 /media/videos/flv/12.flv
    2013-01-15T13:19:52+00:00 app[web.1]: IMAGE TASK CODE: ffmpeg -y -i /media/videos/practice.wmv -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo -s 320x240 /media/videos/flv/12.png
    2013-01-15T13:19:52+00:00 app[web.1]: TARGET: /media/videos/flv/12.flv
    2013-01-15T13:20:17+00:00 app[web.1]: 2013-01-15 13:20:17 [2] [CRITICAL] WORKER TIMEOUT (pid:12)
    2013-01-15T13:20:17+00:00 app[web.1]: 2013-01-15 13:20:17 [2] [CRITICAL] WORKER TIMEOUT (pid:12)
    2013-01-15T13:20:17+00:00 app[web.1]: 2013-01-15 13:20:17 [19] [INFO] Booting worker with pid: 19

    Am I completely missing something ? I'll keep trying, but will be very appreciative of any direction or assistance.

  • Creating a convertAll() function that converts all .filetype in working directory

    5 janvier 2019, par Risviltsov

    I seem to not know proper bash syntax ; despite this, I’ve tried to create a tool that changes the dimensions of all files of a ffmpeg-accepted filetype in the working directory and converts it to another ffmpeg-accepted filetype. In this instance, this tool converts all .webm files over 1080x720 into 1080x-1 or -1x720 .mp4 files. If the .webm file is under 1080x720, the new .mp4 file will have the same dimensions.

    However, there’s a wrench in the tool.

    convertAll () {
    local wantedWidth = 1080
    local wantedHeight = 720
    for i in *.webm; do
    local newWidth = $i.width
    local newHeight = $i.height
    until [$newWidth <= $wantedWidth && $newHeight <= $wantedHeight]; do
    if [$videoWidth > $wantedWidth]; then
    newHeight = $newWidth*($wantedWidth/$newWidth)
    newWidth = $newWidth*($wantedWidth/$newWidth)
    fi
    if [$videoHeight > $wantedHeight]; then
    newWidth = $newWidth*($wantedHeight/$newHeight)
    newHeight = $newHeight*($wantedHeight/$newHeight)
    fi
    done
    ffmpeg -i "$i" -vf scale=$newWidth:$newHeight "${i%.*}.mp4";
    done
    echo "All files have been converted."
    }

    What this returns is a bunch of lines that look like this :

    bash: [: missing ']'
    bash: [: missing ']'
    bash: =: No such file or directory

    My best guess is that BASH can’t do mathematics, and that I’m declaring and editing my variables incorrectly.

    I’d like some input on this --- my lack of experience is really getting me here.

  • look for a specific filetype in a directory in php and send it to a different directory after conversion

    12 juin 2019, par flash

    I have a directory in which there is a mp4 file (including other files as well) which I want to convert into mp3 and then send it to different directory. I have used the following command line command to covert into mp3 and its working perfectly fine.

    ffmpeg -i 36031P.mp4 -map 0:2 -ac 1 floor_english.mp3

    mp4 file is inside in_folder. Using ffmpeg, I want to convert mp4 file into mp3 and send it to out_folder.

    <?php
    $dir    = 'in_folder';
    $files1 = scandir($dir);
    print_r($files1);    /* It lists all the files in a directory including mp4 file*/
    ?>

    print_r($files1) lists all the file in a directory including mp4file.

    Problem Statement :

    I am wondering what php code I need to write so that it looks for only mp4 file inside the directory and send it to different directory (let say out_folder) after converting into mp3.

    The pictorial representation of what I want :

    enter image description here