Recherche avancée

Médias (1)

Mot : - Tags -/artwork

Autres articles (71)

  • Modifier la date de publication

    21 juin 2013, par

    Comment changer la date de publication d’un média ?
    Il faut au préalable rajouter un champ "Date de publication" dans le masque de formulaire adéquat :
    Administrer > Configuration des masques de formulaires > Sélectionner "Un média"
    Dans la rubrique "Champs à ajouter, cocher "Date de publication "
    Cliquer en bas de la page sur Enregistrer

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

Sur d’autres sites (5851)

  • Returning shell_exec as string PHP detecting BPM with soundtouch/soundstrech

    23 janvier 2016, par Jeff

    I am working on a php function used to upload a .wav to server (along with converting to mp3 and creating waveform image png) , and within the function I would like it to use soundtouch / soundstrech to detect the B.P.M. (Beats Per Minute). I know it will not be the most accurate but for my purposes it will be all I need.

    I was able to get the B.P.M. of a .wav file using soundtouch / soundstrech along with ffmpeg within a test.php file using deven’s php-bpm-detect wrapper But When I try to integrate it within my PHP function it returns the B.P.M. as zero.

    I am wondering if there is a simpler way to get the bpm as a string from the following shell exec without having to use a separate php library ?

    I would like to perform this and have it return as a string :

    $song_bpm = shell_exec('soundstretch ' . $file_path . ' -bpm');

    test.php (This works and returns the proper bpm :)

    <?php
    require "class.bpm.php";
    $wavfile = "38a2819c20.wav";
    $bpm_detect = new bpm_detect($wavfile);  
    $test = $bpm_detect->detectBPM();
    echo ' bpm of ' . $wavfile . ' is: ' . $test . ' ';
    ?>

    PHP Function : (returns bpm as zero)

    function upload_a_sound($user_id, $file_temp, $file_extn, $name, $uploader, $keywords) {
       $timecode = substr(md5(time()), 0, 10);
       $mp3name = 'beats/' . $timecode . '.mp3';
       $file_path = 'beats/' . $timecode . '.wav';
       move_uploaded_file($file_temp, $file_path);
       shell_exec('ffmpeg -i ' . $file_path . ' -vn -ar 44100 -ac 2 -ab 192k -f mp3 ' . $mp3name . '');
       require ('classAudioFile.php'); // This creates a spectogram .png file of .wav
       $AF = new AudioFile;
       $AF->loadFile($file_path);
       $AF->visual_width=200;
       $AF->visual_height=200;
       $AF->visual_graph_color="#c491db";
       $AF->visual_background_color="#000000";
       $AF->visual_grid=false;
       $AF->visual_border=false;
       $AF->visual_graph_mode=0;
       $AF->getVisualization ('images/song/' . $timecode . '.png');
       $imageloc = 'images/song/' . $timecode . '.png';
       require ('class.bpm.php'); //Deseven's class to get bpm,
       $bpm_detect = new bpm_detect($file_path);  
       $song_bpm = $bpm_detect->detectBPM(); //when used here this returns 0
       mysql_query("INSERT INTO `content` VALUES ('', '', '$name', '$uploader', '$keywords', '$file_path', '$imageloc', '$mp3name', '$song_bpm')"); // I will update this to mysqli soon, for now it works
    }

    I also found this which works, but not when I integrate it into my function :

    // create new files, because we don't want to override the old files
    $wavFile = $filename . ".wav";
    $bpmFile = $filename . ".bpm";

    //convert to wav file with ffmpeg
    $exec = "ffmpeg -loglevel quiet -i \"" . $filename . "\" -ar 32000 -ac 1 \"" . $wavFile . "\"";
    $output = shell_exec($exec);

    // now execute soundstretch with the newly generated wav file, write the result into a file
    $exec = "soundstretch \"" . $wavFile . "\" -bpm  2> " . $bpmFile;
    shell_exec($exec);

    // read and parse the file
    $output = file_get_contents($bpmFile);
    preg_match_all("!(?:^|(?<=\s))[0-9]*\.?[0-9](?=\s|$)!is", $output, $match);

    // don't forget to delete the new generated files
    unlink($wavFile);
    unlink($bpmFile);

    // here we have the bpm
    echo $match[0][2];
  • Audio Files downloaded from YouTube-DL are corrupted

    1er juin 2022, par Sushil

    I have written a small piece of code that downloads audios and videos from YouTube using YouTube-DL. Here is my code :

    


    from __future__ import unicode_literals
import youtube_dl

link = input("Enter the video link:")

while True:
    choice = input("Enter a for audio file, v for video file:")
    if choice == "a" or choice == "v":
        break

ydl_opts = {}

if choice == "a":
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
    }
else:
    ydl_opts = {'format':137}
    
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    info_dict = ydl.extract_info(link, download=False)
    video_title = info_dict.get('title', None)

if choice == "a":
    path = f'D:\\DwnldsYT\\{video_title}.mp3'
if choice == "v":
    path = f'D:\\DwnldsYT\\{video_title}.mp4'

ydl_opts.update({'outtmpl':path})

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([link])


    


    This works fine. I am able to play the downloaded audio. But when I try to read the same audio file, it shows me an error.

    


    Code :

    


    from pydub import AudioSegment

song = AudioSegment.from_mp3("D:\\DwnldsYT\\Cartoon - On & On (feat. Daniel Levi) [NCS Release].mp3")


    


    Output :

    


    Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[mp3float @ 000001f2425c2500] Header missing
Error while decoding stream #0:0: Invalid data found when processing input
[abuffer @ 000001f242280300] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 3 times
[abuffer @ 000001f242280300] Error setting option time_base to value 1/0.
[graph_0_in_0_0 @ 000001f242280e80] Error applying options to the filter.
Error reinitializing filters!
Error while filtering: Result too large
Finishing stream 0:0 without any data written to it.
[abuffer @ 000001f242280300] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 3 times
[abuffer @ 000001f242280300] Error setting option time_base to value 1/0.
[graph_0_in_0_0 @ 000001f242280e80] Error applying options to the filter.
Error configuring filter graph
Conversion failed!


    


    Is this because the audio downloaded is corrupted ? And how to solve this problem ? Any help would be appreciated. Thanks !

    


  • How can I segment a ts file on scene change detection using FFmpeg ?

    20 septembre 2020, par Mike Davis

    I am either not asking the question in a way Google can understand, or no one has asked this, as every issue I can find is in regards to outputting images of each scene. I want to output video segments…

    


    I have an input video that is basically a slide show, except the slides coincide with songs, so they are not at regular intervals. I would like to segment and create a sequence of ts files that are split based on a scene change threshold, and have a separate ts file for each song.