Recherche avancée

Médias (91)

Autres articles (39)

  • 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 ;

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

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (8276)

  • How to display print statement from a function on GUI in Tkinter

    12 février 2021, par amarykya_ishtmella

    I am writing a GUI that takes videos and downsamples them.

    


    I have three buttons
1.Input for getting the input directory
2.Output for getting the directory to write the output files
3.Downsample : For downsampling function.

    


    I want to print "Done downsampling" after the downsampling process is over on the GUI display.

    


    I was using a label, but it's not working. Can anyone help me out with this ?

    


    

from tkinter import *
from tkinter import ttk
import mttkinter
from tkinter.filedialog import *
import tkinter as tk

froot = Tk() 
froot.title('GHC')
froot.iconbitmap()
froot.geometry('500x500') 


n = ttk.Notebook(froot)
n.pack(pady=10) #pady is giving the space at the bottom
f1 = tk.Frame(n,width=500,height=500,bg = "blue")
f2 = tk.Frame(n,width=500,height=500, bg = "red")
f1.pack(fill="both",expand=1)
f2.pack(fill="both",expand=1)

n.add(f1, text='Downsample')
n.add(f2, text='Analyze')


### button to get input path to folder

#directory = None
def open_file(): 
    file = askdirectory() 
    if file is not None:
        global directory
        directory =file
        print (directory)
btn = Button(f1, text ='Input folder', command = lambda:open_file())
btn.pack(side = TOP, pady = 10) 



### button to get output folder
#directory2 = None
def output_file(): 
    file2 = askdirectory() 
    if file2 is not None:
        global directory2
        directory2 =file2
        print (directory2)
btn2 = Button(f1, text ='Output folder', command = lambda:output_file())
btn2.pack(side=BOTTOM,pady = 10) 


root=str(directory)
outputpath=str(directory2)

btn2 = Button(f1, text ='Downsample', command =lambda:downsamplevideos(root,outputpath))
btn2.pack(pady = 10)
#####

def get_videos (root):

    files = []

    for f in os.listdir(root):

        joined = root + '/' + f

        if os.path.isdir(root + '/' + f):

            files += get_videos(joined)

        else:

            # if f.split('.')[-1] == mp4

            files += [joined]

    return files

def downsamplevideos(root,ouputpath):
    for files in get_videos(root):
        dirpath=files.split('/')[-2]
        filename=files.split('/')[-1]
        outputvideofile= dirpath +filename
        process=(   
        ffmpeg
        .input(files)
        .filter_('scale', 532, 300)
        .output(os.path.join(outputpath,"{}".format(outputvideofile))
        .overwrite_output()
        .run(capture_stdout=True, capture_stderr=False)
        )
    global labelprint
    labelprint=ttk.Label(f1,text="Downsampling Done") ##also tried here Label(), tk.Label()...did not work
    labelprint.pack()

#########


    


    I am getting the following error :

    


    
  File "", line 85
    labelprint=ttk.Label(f1,text="Downsampling Done")
             ^
SyntaxError: invalid syntax


    


  • writeImages and renaming the images using PHP

    3 mai 2015, par Kiran Kumar Dash

    I am working on a multimedia project. So, I am having a case where I am producing a sequence of images from a string input using he code below :

    <?php

       /*** a new Imagick object ***/
       $aniGif = new Imagick();

       /*** set the image format to gif ***/
       $aniGif->setFormat( "gif" );

       /*** a new ImagickPixel object for the colors ***/
       $color = new ImagickPixel( "white" );

       /*** set color to white ***/
       $color->setColor( "white" );

       $colorarray =array("white", "red", "blue" , "aqua", "fuchsia", "gray", "lime", "maroon", "navy", "orange", "purple", "silver", "teal", "yellow",  "green", "maroon", "green", "olive");

       /*** the text for the image ***/
       $string = "Hello Kiran Kumar";


       /*** a new draw object ***/
       $draw = new ImagickDraw();

       /*** set the draw font to helvetica ***/
       $draw->setFont( "./SociaLAnimaL.ttf" );

       /*** set the draw font to helvetica ***/
       $draw->setFontSize( "100" );

       /*** loop over the text ***/
       for ( $i = 0; $i <= strlen( $string ); $i++ )
       {
           /*** grab a character ***/
           $part = substr( $string, 0, $i );

           /*** a new ImagickPixel object for the colors ***/
           $color = new ImagickPixel( "white" );

           /*Generate random number for random color*/
           $randomNumber = rand(0,16);

           /*** create a new gif frame ***/
           $aniGif->newImage( 1920, 1200, $colorarray[$randomNumber] );

           /*** add the character to the image ***/
           $aniGif->annotateImage( $draw, 960, 600, 0, $part );

           /*** set the frame delay to 30 ***/
           $aniGif->setImageDelay( 30 );

       }
        /*** write the file ***/
           $aniGif->writeImages($directory.'kiran.jpg', $out);




       echo 'all done';

    ?>

    Now the problem is the writeimages object is generating images as kiran-0.jpg, kiran-1.jpg, kiran-2.jpg and so on. but what I am expecting is kiran001.jpg, kiran002.jpg, kiran003.jpg...and so on so that I can create a video out of it in while maintaining the sequence.Here is the code for video creation :

    <?php
    $ffmpeg= "/home/kiran/bin/ffmpeg";
       echo exec("$ffmpeg -f image2 -framerate 2/1 -pattern_type glob -i \"/var/www/html/fftest/getthumbnail/tmp/animate/est/*.jpg\" -i \"/var/www/html/fftest/getthumbnail/audios/audio1.mp3\" -c:v libx264 -c:a copy -shortest  -s 1920x1080 -r 60 -vf \"format=yuv420p\" \"/var/www/html/fftest/getthumbnail/output/animatedaudiocolor21.avi\" 2>&1" , $output, $return);
    ?>

    As you can see I am using -pattern type glob to select all the images, but this is getting confused with he naming sequence of kiran-0, kiran-1.

    So, what I am expecting here is how can I use writeimage object o name my images as the way mentioned above. so that I can use kiran%03d.jpg in my ffmpeg command instead of *.jpg.

    Or if any one can help me providing a code so that I can rename all the images in the expected manner.I tried the below code to rename all images :

    <?php
    $fileFolder="/fftest/getthumbnail/tmp/animate/test";
    $directory = $_SERVER['DOCUMENT_ROOT'].$fileFolder.'/';

    $i = 001;
    $handler = opendir($directory);
    while ($file = readdir($handler)) {
       if ($file != "." && $file != "..") {
           $newName = 'kiran'.$i ;
           rename($directory.$file, $directory.$newName); // here; prepended a $directory
           $i++;
       }
    }
    closedir($handler);

    ?>

    But the code is unable to rename the images in sequence.

    Help please...

  • continuous record/recognize audio with pocketsphinx/ffmpeg

    10 novembre 2017, par Michael

    as the title already says, I want to continuous record raw audio through my microphone.
    So the idea was running a simple C program in the background as service that would create chunks of audio and send those files through the sphinx speech recognition.

    After that I can do some processing with the recognized words.

    The problem is the (continuous) recognition. I can’t just record audio chunks containing 10 seconds what i’ve said, because maybe chunk[33] -> chunk[34] belong together and then sphinx would output something like :

    recognized chunk[33] -> ["enable light"]
    recognized chunk[34] -> ["5 with 50 percent"]

    Another approach would be to continuous record audio but then I can’t process big audio files with sphinx.

    I’m using the basic example from pocketsphinx :

    #include

    int main(int argc, char *argv[])
    {
    ps_decoder_t *ps;
    cmd_ln_t *config;
    FILE *fh;
    char const *hyp, *uttid;
    int16 buf[512];
    int rv;
    int32 score;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm", MODELDIR "/en-us/en-us",
                "-lm", MODELDIR "/en-us/en-us.lm.bin",
                "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
                NULL);
    if (config == NULL) {
    fprintf(stderr, "Failed to create config object, see log for details\n");
    return -1;
    }

    ps = ps_init(config);
    if (ps == NULL) {
    fprintf(stderr, "Failed to create recognizer, see log for details\n");
    return -1;
    }

    fh = fopen("audiochunk_33.raw", "rb");
    if (fh == NULL) {
    fprintf(stderr, "Unable to open input file goforward.raw\n");
    return -1;
    }

    rv = ps_start_utt(ps);

    while (!feof(fh)) {
    size_t nsamp;
    nsamp = fread(buf, 2, 512, fh);
    rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
    }

    rv = ps_end_utt(ps);
    hyp = ps_get_hyp(ps, &score);
    printf("Recognized: %s\n", hyp);

    fclose(fh);
    ps_free(ps);
    cmd_ln_free_r(config);

    return 0;

    }

    And here is a basic example using ffmpeg to create a simple audio file/chunk :

    #include
    #include
    #include

    #define N 44100

    void main()
    {
    // Create audio buffer
    int16_t buf[N] = {0}; // buffer
    int n;                // buffer index
    double Fs = 44100.0;  // sampling frequency

    // Generate 1 second of audio data - it's just a 1 kHz sine wave
    for (n=0 ; n<n></n>Fs);

    // Pipe the audio data to ffmpeg, which writes it to a wav file
    FILE *pipeout;
    pipeout = popen("ffmpeg -y -f s16le -ar 44100 -ac 1 -i - beep.wav", "w");
    fwrite(buf, 2, N, pipeout);
    pclose(pipeout);
    }

    BR
    Michael