Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (82)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

Sur d’autres sites (10763)

  • Why does File upload for moving image and Audio to tmp PHP folder work on Windows but only image upload portion works on Mac using MAMP ?

    31 mai 2021, par Yazdan

    So according to my colleague who tested this on Windows says it works perfectly fine , but in my case when I use it on a Mac with MAMP for Moodle , the image files get uploaded to the correct destination folder without an issue whereas the audio files don't move from the tmp folder to the actual destination folder and to check if this was the case ... I just changed and gave a fixed path instead of $fileTmpLoc and the file made it to the correct destination. Sorry I know the first half of the code isn't the main issue but I still wanted to post the whole code so one could understand it easily, moreover I am just beginning to code so please "have a bit of patience with me" . Thanks in advance

    


    &#xA;// this file contains upload function &#xA;// checks if the file exists in server&#xA;include("../db/database.php");&#xA;require_once(dirname(__FILE__) . &#x27;/../../../config.php&#x27;);&#xA;global $IP;&#xA;&#xA;$ajaxdata = $_POST[&#x27;mediaUpload&#x27;];&#xA;&#xA;$FILENAME = $ajaxdata[1];&#xA;$IMAGE=$ajaxdata[0];&#xA;// an array to check which category the media belongs too&#xA;$animal= array("bird","cat","dog","horse","sheep","cow","elephant","bear","giraffe","zebra");&#xA;$allowedExts = array("mp3","wav");&#xA;$temp = explode(".", $_FILES["audio"]["name"]);&#xA;$extension = end($temp);&#xA;&#xA;&#xA;&#xA;$test = $_FILES["audio"]["type"]; &#xA;&#xA;&#xA;if (&#xA;   $_FILES["audio"]["type"] == "audio/wav"||&#xA;   $_FILES["audio"]["type"] == "audio/mp3"||&#xA;   $_FILES["audio"]["type"] == "audio/mpeg"&#xA;   &amp;&amp;&#xA;   in_array($extension, $allowedExts)&#xA;   )&#xA;   {&#xA;&#xA;       // if the name detected by object detection is present in the animal array&#xA;       // then initialize target path to animal database or to others&#xA;       if (in_array($FILENAME, $animal)) &#xA;       { &#xA;           $image_target_dir = "image_dir/";&#xA;           $audio_target_dir = "audio_dir/";&#xA;       } &#xA;       else&#xA;       { &#xA;           $image_target_dir = "other_image_dir/";&#xA;           $audio_target_dir = "other_audio_dir/";&#xA;       } &#xA;       // Get file path&#xA;       &#xA;       $img = $IMAGE;&#xA;       // decode base64 image&#xA;       $img = str_replace(&#x27;data:image/png;base64,&#x27;, &#x27;&#x27;, $img);&#xA;       $img = str_replace(&#x27; &#x27;, &#x27;&#x2B;&#x27;, $img);&#xA;       $image_data = base64_decode($img);&#xA;&#xA;       //$extension  = pathinfo( $_FILES["fileUpload"]["name"], PATHINFO_EXTENSION ); // jpg&#xA;       $image_extension = "png";&#xA;       $image_target_file =$image_target_dir . basename($FILENAME . "." . $image_extension);&#xA;       $image_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$image_target_file;&#xA;       &#xA;       &#xA;       $audio_extension ="mp3";&#xA;       $audio_target_file= $audio_target_dir . basename($FILENAME. "." . $audio_extension) ;&#xA;       $audio_file_upload = "http://localhost:8888/moodle310/blocks/testblock/classes/".$audio_target_file;&#xA;&#xA;       // file size limit&#xA;       if(($_FILES["audio"]["size"])&lt;=51242880)&#xA;       {&#xA;&#xA;           $fileName = $_FILES["audio"]["name"]; // The file name&#xA;           $fileTmpLoc = $_FILES["audio"]["tmp_name"]; // File in the PHP tmp folder&#xA;           $fileType = $_FILES["audio"]["type"]; // The type of file it is&#xA;           $fileSize = $_FILES["audio"]["size"]; // File size in bytes&#xA;           $fileErrorMsg = $_FILES["audio"]["error"]; // 0 for false... and 1 for true&#xA;           &#xA;           if (in_array($FILENAME, $animal)) &#xA;           { &#xA;               $sql = "INSERT INTO mdl_media_animal (animal_image_path,animal_name,animal_audio_path) VALUES (&#x27;$image_file_upload&#x27;,&#x27;$FILENAME&#x27;,&#x27;$audio_file_upload&#x27;)";&#xA;           } else {&#xA;               $sql = "INSERT INTO mdl_media_others (others_image_path,others_name,others_audio_path) VALUES (&#x27;$image_file_upload&#x27;,&#x27;$FILENAME&#x27;,&#x27;$audio_file_upload&#x27;)";&#xA;           }&#xA;&#xA;           // if file exists&#xA;           if (file_exists($audio_target_file) || file_exists($image_target_file)) {&#xA;               echo "alert";&#xA;           } else {&#xA;               // write image file&#xA;               if (file_put_contents($image_target_file, $image_data) ) {&#xA;                   // ffmpeg to write audio file&#xA;                   $output = shell_exec("ffmpeg -i $fileTmpLoc -ab 160k -ac 2 -ar 44100 -vn $audio_target_file");&#xA;                   echo $output;&#xA;               &#xA;                   // $stmt = $conn->prepare($sql);&#xA;                   $db = mysqli_connect("localhost", "root", "root", "moodle310"); &#xA;                   // echo $sql;&#xA;                   if (!$db) {&#xA;                       echo "nodb";&#xA;                       die("Connection failed: " . mysqli_connect_error());&#xA;                   }&#xA;                   // echo"sucess";&#xA;                   if(mysqli_query($db, $sql)){&#xA;                   // if($stmt->execute()){&#xA;                       echo $fileTmpLoc;&#xA;                       echo "sucess";  &#xA;                       echo $output;&#xA;                   }&#xA;                   else {&#xA;                       // echo "Error: " . $sql . "<br />" . mysqli_error($conn);&#xA;                       echo "failed";&#xA;                   }&#xA;&#xA;               }else {&#xA;                   echo "failed";&#xA;               }&#xA;&#xA;               &#xA;           &#xA;           &#xA;           }&#xA;   &#xA;    // $test = "ffmpeg -i $outputfile -ab 160k -ac 2 -ar 44100 -vn bub.wav";&#xA;       } else&#xA;       {&#xA;         echo "File size exceeds 5 MB! Please try again!";&#xA;       }&#xA;}&#xA;else&#xA;{&#xA;   echo "PHP! Not a video! ";//.$extension." ".$_FILES["uploadimage"]["type"];&#xA;   }&#xA;&#xA;?>&#xA;

    &#xA;

    I am a student learning frontend but a project of mine requires a fair bit of backend. So forgive me if my question sounds silly.

    &#xA;

    What I meant by manually overriding it was creating another folder and a index.php file with echo "hello"; $output = shell_exec("ffmpeg -i Elephant.mp3 -ab 160k -ac 2 -ar 44100 -vn bub.mp3"); echo $output; so only yes in this case Elephant.mp3 was changed as the initial tmp path so in this case as suggested by Mr.CBroe the permissons shouldn't be an issue.

    &#xA;

    Okay I checked my Apache_error.logonly to find out ffmpeg is indeed the culprit ... I had installed ffmpeg globally so I am not sure if it is an access problem but here is a snippet of the log

    &#xA;

    I checked my php logs and found out that FFmpeg is the culprit.&#xA;Attached is a short log file

    &#xA;

    [Mon May 31 18:11:33 2021] [notice] caught SIGTERM, shutting down&#xA;[Mon May 31 18:11:40 2021] [notice] Digest: generating secret for digest authentication ...&#xA;[Mon May 31 18:11:40 2021] [notice] Digest: done&#xA;[Mon May 31 18:11:40 2021] [notice] Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/1.0.2o PHP/7.2.10 configured -- resuming normal operations&#xA;sh: ffmpeg: command not found&#xA;sh: ffmpeg: command not found&#xA;sh: ffmpeg: command not found&#xA;

    &#xA;

  • ffmpeg pipe Invalid data found when processing input

    28 mars 2021, par Ankit Maheshwari
    Here is my configuration.&#xA;

    &#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    const ffmpegPath = require(&#x27;@ffmpeg-installer/ffmpeg&#x27;).path;&#xA;const spawn = require(&#x27;child_process&#x27;).spawn;&#xA;&#xA;ffmpeg = spawn(ffmpegPath, [&#xA;      &#xA;// Remove this line, as well as `-shortest`, if you send audio from the browser.&#xA;      // &#x27;-f&#x27;, &#x27;lavfi&#x27;, &#x27;-i&#x27;, &#x27;anullsrc&#x27;,&#xA;&#xA;      // FFmpeg will read input video from STDIN&#xA;      &#x27;-i&#x27;, &#x27;-&#x27;,&#xA;&#xA;      // -re flag means to Read input at native frame rate.&#xA;      &#x27;-re&#x27;, &#x27;-y&#x27;,&#xA;&#xA;      // thread_queue_size added to avoid err: Thread message queue blocking; consider raising the thread_queue_size option, required before each input - this is for image2&#xA;      // &#x27;-thread_queue_size&#x27;, &#x27;2048&#x27;,&#xA;&#xA;      // REF TO OVERLAY &#xA;      // https://stackoverflow.com/questions/10438713/overlay-animated-images-with-transparency-over-a-static-background-image-using-f?rq=1&#xA;      // -loop loops the background image input so that we don&#x27;t just have one frame, crucial!&#xA;&#xA;      // The image file muxer writes video frames to image files, http://underpop.online.fr/f/ffmpeg/help/image2-1.htm.gz&#xA;      &#x27;-f&#x27;, &#x27;image2&#x27;,&#xA;&#xA;      // The -loop option is specific to the image file demuxer and gif muxer, so it can&#x27;t be used for typical video files, but it can be used to infinitely loop a series of input images.&#xA;      &#x27;-loop&#x27;, &#x27;1&#x27;,&#xA;&#xA;      // pattern_type is used to determine the format of the images contained in the files.&#xA;      // Read images matching the "*.png" glob pattern, that is files terminating with the ".png" suffix&#xA;      &#x27;-pattern_type&#x27;, &#x27;glob&#x27;,&#xA;&#xA;      // &#x27;-i&#x27;, `images/${streamConfigData.youtube_key}/destination/image-*.png`,&#xA;&#xA;      &#x27;-i&#x27;, `images/${streamConfigData.youtube_key}/overlay/abc.png`,&#xA;&#xA;      // &#x27;-vf&#x27;, &#x27;scale=1920x1080:flags=lanczos&#x27;,&#xA;      &#xA;      // -shortest ends encoding when the shortest input ends, which is necessary as looping the background means that that input will never end.&#xA;      // &#x27;overlay=shortest=1&#x27;,&#xA;&#xA;      "-filter_complex", "[1:v]format=rgba,colorchannelmixer=aa=1[fg];[0][fg]overlay",&#xA;      &#xA;      // Because we&#x27;re using a generated audio source which never ends,&#xA;      // specify that we&#x27;ll stop at end of other input.  Remove this line if you&#xA;      // send audio from the browser.&#xA;      // &#x27;-shortest&#x27;,&#xA;      &#xA;      // If we&#x27;re encoding H.264 in-browser, we can set the video codec to &#x27;copy&#x27;&#xA;      // so that we don&#x27;t waste any CPU and quality with unnecessary transcoding.&#xA;      // If the browser doesn&#x27;t support H.264, set the video codec to &#x27;libx264&#x27;&#xA;      // or similar to transcode it to H.264 here on the server.&#xA;      // &#x27;-vcodec&#x27;, &#x27;libx264&#x27;,&#xA;      // it is not possible to filter and stream copy the same stream at the same time. https://stackoverflow.com/a/53526514/4057143&#xA;      &#x27;-vcodec&#x27;, &#x27;copy&#x27;,&#xA;      &#xA;      // if browser not supports encoding AAC, we must transcode the audio to AAC here on the server.&#xA;      // &#x27;-acodec&#x27;, &#x27;aac&#x27;,&#xA;&#xA;      // Use this rate control mode if you want to keep the best quality and care less about the file size. CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, https://trac.ffmpeg.org/wiki/Encode/H.264&#xA;      &#x27;-crf&#x27;, &#x27;23&#x27;,&#xA;&#xA;      // preset provide a certain encoding speed to compression ratio. A slower preset will provide better compression. medium – default preset, https://trac.ffmpeg.org/wiki/Encode/H.264&#xA;      &#x27;-preset&#x27;, &#x27;ultrafast&#x27;,&#xA;&#xA;      // -r set the frame rate. Generally, -r. Use the filter when you need to change framerate before applying further filters.&#xA;      // &#x27;-r&#x27;, &#x27;30&#x27;,&#xA;      // &#x27;-framerate&#x27;, &#x27;30&#x27;,&#xA;&#xA;      //debug level logs&#xA;      &#x27;-loglevel&#x27;, &#x27;debug&#x27;,&#xA;      &#x27;-v&#x27;, &#x27;verbose&#x27;,&#xA;&#xA;      // -g GOP_LEN_IN_FRAMES, -g sets the keyframe interval. https://superuser.com/a/908325&#xA;      &#x27;-g&#x27;, &#x27;60&#x27;,&#xA;&#xA;      // video timescale, not sure what it is!&#xA;      &#x27;-video_track_timescale&#x27;, &#x27;1000&#x27;,&#xA;&#xA;      // a live stream with more/less constant bit rate, to be able to control the bandwidth used.&#xA;      // a live stream with limited bit rate&#xA;      &#x27;-b:v&#x27;, &#x27;15000k&#x27;,&#xA;      // &#x27;-maxrate&#x27;, &#x27;4000k&#x27;,&#xA;      // &#x27;-bufsize&#x27;, &#x27;8000k&#x27;,&#xA;&#xA;      // FLV is the container format used in conjunction with RTMP&#xA;      &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;      &#xA;      // The output RTMP URL.&#xA;      // For debugging, you could set this to a filename like &#x27;test.flv&#x27;, and play&#xA;      // the resulting file with VLC.&#xA;      rtmpUrl &#xA;    ], {&#xA;      env: {&#xA;          NODE_ENV: &#x27;production&#x27;,&#xA;          PATH: process.env.PATH&#xA;      }&#xA;    });

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

  • Issues with encoded video in Chrome playback

    4 novembre 2022, par Michael Joseph Aubry

    Chrome is very particular about how a video is encoded. An issue I am facing with a specific type of video is seeked either does not get called at all or at least within a 20s period of time within certain frames.

    &#xA;

    I can consistently repeat this issue using this muxer https://github.com/redbrain/ytdl-core-muxer/blob/main/index.js

    &#xA;

    When I paint each frame in puppeteer Lambda there are certain frames where either seeked never gets called or the 20s timeout is called before the frame can resolve.

    &#xA;

    Here is an example of a log sequence for this particular frame that fails enter image description here

    &#xA;

    When I re-encode this video, simply by running ffmpeg -i VIDEO_URL then try with the new one there are no issues.

    &#xA;

    In order to see the differences on a frame level I run ffprobe -show_frames goodvideo.mp4 > good.txt && ffprobe -show_frames badvideo.mp4 > bad.txt and here is what I see with the frames around the 117s mark where the first sign of corruption occurs

    &#xA;

    Good Frame @ 117s

    &#xA;

    [FRAME]&#xA;media_type=video&#xA;stream_index=0&#xA;key_frame=0&#xA;pts=7020013&#xA;pts_time=117.000217&#xA;pkt_dts=7020013&#xA;pkt_dts_time=117.000217&#xA;best_effort_timestamp=7020013&#xA;best_effort_timestamp_time=117.000217&#xA;pkt_duration=1001&#xA;pkt_duration_time=0.016683&#xA;pkt_pos=27029408&#xA;pkt_size=1741&#xA;width=1920&#xA;height=1080&#xA;pix_fmt=yuv420p&#xA;sample_aspect_ratio=1:1&#xA;pict_type=B&#xA;coded_picture_number=7014&#xA;display_picture_number=0&#xA;interlaced_frame=0&#xA;top_field_first=0&#xA;repeat_pict=0&#xA;color_range=tv&#xA;color_space=bt709&#xA;color_primaries=bt709&#xA;color_transfer=bt709&#xA;chroma_location=left&#xA;[/FRAME]&#xA;

    &#xA;

    Bad Frame @ 117s

    &#xA;

    [FRAME]&#xA;media_type=video&#xA;stream_index=0&#xA;key_frame=0&#xA;pts=117000&#xA;pts_time=117.000000&#xA;pkt_dts=117000&#xA;pkt_dts_time=117.000000&#xA;best_effort_timestamp=117000&#xA;best_effort_timestamp_time=117.000000&#xA;pkt_duration=16&#xA;pkt_duration_time=0.016000&#xA;pkt_pos=20592998&#xA;pkt_size=18067&#xA;width=1920&#xA;height=1080&#xA;pix_fmt=yuv420p&#xA;sample_aspect_ratio=1:1&#xA;pict_type=P&#xA;coded_picture_number=7011&#xA;display_picture_number=0&#xA;interlaced_frame=0&#xA;top_field_first=0&#xA;repeat_pict=0&#xA;color_range=tv&#xA;color_space=bt709&#xA;color_primaries=bt709&#xA;color_transfer=bt709&#xA;chroma_location=left&#xA;[/FRAME]&#xA;

    &#xA;

    Does anyone know the differences and why the bad frame is causing my rendering function to have issues seeking ?

    &#xA;

    This is how I am muxing the bad video, Im trying to avoid re-encoding, but by re-encoding it seems to fix the issue. Are there any settings I can apply to avoid re-encoding while making the video more durable on Chrome ?

    &#xA;

    // default export: the ffmpeg muxer&#xA;const ytmux = (link, options: any = {}) => {&#xA;  const result = new stream.PassThrough({&#xA;    highWaterMark: options.highWaterMark || 1024 * 512&#xA;  });&#xA;&#xA;  ytdl.getInfo(link, options).then((info: videoInfo) => {&#xA;    let audioStream: Readable = ytdl.downloadFromInfo(info, {&#xA;      ...options,&#xA;      quality: "highestaudio"&#xA;    });&#xA;    let videoStream: Readable = ytdl.downloadFromInfo(info, {&#xA;      ...options,&#xA;      quality: "highestvideo"&#xA;    });&#xA;    // create the ffmpeg process for muxing&#xA;    let ffmpegProcess: any = cp.spawn(&#xA;      ffmpegPath.path,&#xA;      [&#xA;        // supress non-crucial messages&#xA;        "-loglevel",&#xA;        "8",&#xA;        "-hide_banner",&#xA;        // input audio and video by pipe&#xA;        "-i",&#xA;        "pipe:3",&#xA;&#xA;        "-i",&#xA;        "pipe:4",&#xA;&#xA;        // map audio and video correspondingly&#xA;        "-map",&#xA;        "0:v",&#xA;        "-map",&#xA;        "1:a",&#xA;&#xA;        // no need to change the codec&#xA;        "-c",&#xA;        "copy",&#xA;&#xA;        // Allow output to be seekable, which is needed for mp4 output&#xA;        "-movflags",&#xA;        "frag_keyframe&#x2B;empty_moov",&#xA;&#xA;        "-fflags",&#xA;        "&#x2B;genpts",&#xA;&#xA;        "-f",&#xA;        "matroska",&#xA;&#xA;        "pipe:5"&#xA;      ],&#xA;      {&#xA;        // no popup window for Windows users&#xA;        windowsHide: true,&#xA;        stdio: [&#xA;          // silence stdin/out, forward stderr,&#xA;          "inherit",&#xA;          "inherit",&#xA;          "inherit",&#xA;          // and pipe audio, video, output&#xA;          "pipe",&#xA;          "pipe",&#xA;          "pipe"&#xA;        ]&#xA;      }&#xA;    );&#xA;&#xA;    audioStream.pipe(ffmpegProcess.stdio[4]);&#xA;    videoStream.pipe(ffmpegProcess.stdio[3]);&#xA;    ffmpegProcess.stdio[5].pipe(result);&#xA;  });&#xA;  return result;&#xA;};&#xA;

    &#xA;