Recherche avancée

Médias (91)

Autres articles (99)

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

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

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

  • Save FFMpeg conversion to PHP variable vs. File System for use with Whisper API ?

    13 avril 2023, par SScotti

    I just started working on a little demo to transalte audio captured from the front-end as audio/webm using JS and then sent the back-end in a Laravel App. I guess there are JS libraries that can handle the conversion, but I'd rather use a server side solution with FFMPEG, which I am doing.

    


    The backend code is below. It seems to be working after playing around with the PHP composer package that I'm using vs. one for Laravel that is also there. I'd rather use this one because I have other PHP apps that are not Laravel.

    


    Questions :

    


      

    1. With the FFMpeg library, is there a way to capture the converted .mp3 file to a PHP variable in the script rather than saving it to the file system and then reading it back in later ?

      


    2. 


    3. For the OpenAI call, I'd like to catch exceptions there also. I just sort of have a placeholder there for now.

      


      protected function whisper(Request $request) {

    $yourApiKey = getenv('OPENAI_API_KEY');
    $client = OpenAI::client($yourApiKey);

    $file = $request->file('file');
    $mimeType = $request->file('file')->getMimeType();
    $audioContents = $file->getContent();

    try {

        FFMpeg::open($file)
        ->export()
        ->toDisk('public')
        ->inFormat(new \FFMpeg\Format\Audio\Mp3)
        ->save('song_converted.mp3');
    }
    catch (EncodingException $exception) {
        $command = $exception->getCommand();
        $errorLog = $exception->getErrorOutput();
    }

    $mp3 = Storage::disk('public')->path('song_converted.mp3');
    try {
    $response = $client->audio()->transcribe([
    'model' => 'whisper-1',
    'file' =>  fopen($mp3, 'r'),
    'response_format' => 'verbose_json',
    ]);
    }
    catch (EncodingException $exception) {
        $command = $exception->getCommand();
        $errorLog = $exception->getErrorOutput();
    }

 echo json_encode($response);

}


      


    4. 


    


  • Getting a lot of Tail Silence when combining an image and audio into mp4 movie

    1er avril 2023, par Meryan

    As it can be seen from this snapshot the audio HELLO.mp3 combined with bitmap HELLO.jpg produced a movie HELLO_aac.mp4 that has a huge amount of tail silence

    


    enter image description here

    


    The command line I was helped to put together is the following

    


    ======================== 
IN_FILES=-i ".\HELLO.JPG" -i ".\HELLO.MP3"    
OUT_FILE=".\HELLO_aac.MP4"   
EXE="S:\_BINS\FFmpeg 4.2.1 20200112\bin\ffmpeg.exe"  
OPTIONS= -loop 1   -i ".\HELLO.JPG" -i ".\HELLO.MP3"    -vf "scale=-1:1080,pad=1920:1080:(1920-iw)/2:(1080-ih)/2,setsar=1"  -c:v libx264 -profile:v main -pix_fmt yuv420p -r 24 -video_track_timescale 24000    -c:a aac    -shortest -y ".\HELLO_aac.MP4"     
======================== 



    


    Here is the captured output from FFmpeg

    


    ffmpeg version git-2020-01-10-3d894db Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 65.103 / 58. 65.103
  libavformat    58. 35.101 / 58. 35.101
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 70.101 /  7. 70.101
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, image2, from '.\HELLO.JPG':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 23923 kb/s
    Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1600x1200 [SAR 120:120 DAR 4:3], 25 fps, 25 tbr, 25 tbn, 25 tbc
[mp3 @ 000002019015d4c0] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from '.\HELLO.MP3':
  Metadata:
    genre           : Blues
    id3v2_priv.XMP  : <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?>\x0a\x0a \x0a  s
    Stream #1:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0000020190b10380] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000020190b10380] Warning: data is not aligned! This can lead to a speed loss
[libx264 @ 0000020190759300] using SAR=1/1
[libx264 @ 0000020190759300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000020190759300] profile Main, level 4.0, 4:2:0, 8-bit
[libx264 @ 0000020190759300] 264 - core 158 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=34 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '.\HELLO_aac.MP4':
  Metadata:
    encoder         : Lavf58.35.101
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 24k tbn, 24 tbc
    Metadata:
      encoder         : Lavc58.65.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 24000 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc58.65.103 aac
frame=   69 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=0 drop=1 speed=   0x    
frame=   97 fps=0.0 q=-1.0 Lsize=     128kB time=00:00:03.91 bitrate= 267.1kbits/s dup=0 drop=2 speed=5.04x    
video:119kB audio:6kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.208101%
[libx264 @ 0000020190759300] frame I:1     Avg QP:12.88  size:103994
[libx264 @ 0000020190759300] frame P:24    Avg QP:14.05  size:   224
[libx264 @ 0000020190759300] frame B:72    Avg QP:12.67  size:   160
[libx264 @ 0000020190759300] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
[libx264 @ 0000020190759300] mb I  I16..4: 61.7%  0.0% 38.3%
[libx264 @ 0000020190759300] mb P  I16..4:  0.1%  0.0%  0.0%  P16..4:  0.5%  0.1%  0.0%  0.0%  0.0%    skip:99.3%
[libx264 @ 0000020190759300] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.6%  0.0%  0.0%  direct: 0.0%  skip:98.4%  L0:81.1% L1:18.9% BI: 0.0%
[libx264 @ 0000020190759300] coded y,uvDC,uvAC intra: 34.5% 17.3% 15.6% inter: 0.0% 0.1% 0.0%
[libx264 @ 0000020190759300] i16 v,h,dc,p: 70% 19%  7%  3%
[libx264 @ 0000020190759300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 22% 12%  4%  5%  5%  3%  5%  4%
[libx264 @ 0000020190759300] i8c dc,h,v,p: 80%  8% 10%  2%
[libx264 @ 0000020190759300] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000020190759300] ref P L0: 97.6%  0.3%  1.5%  0.6%
[libx264 @ 0000020190759300] ref B L0:  1.8% 98.2%
[libx264 @ 0000020190759300] ref B L1: 99.9%  0.1%
[libx264 @ 0000020190759300] kb/s:239.28
[aac @ 000002019075bf40] Qavg: 8004.814
======================== 


    


    I have also tried the following command line

    


    "S:\_BINS\ffmpeg-2023-03-20\bin\ffmpeg.exe" -loop 1 -i "HELLO.JPG" -i "HELLO.MP3" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -y -shortest "HELLO_aac.mp4"    


    


    With similar long dead tail silence ???

    


  • FFMPEG-PHP Windows "Can't open movie file"

    23 janvier 2014, par bah

    ffmpeg extension is loaded as it is shown at phpinfo(), my file and script are at the same location, but I'm still getting this error.

    Warning: Can't open movie file Untitled.avi in C:\xampp\htdocs\skelbiu\fetch.php  on line 4

    Fatal error: Call to a member function getDuration() on a non-object in C:\xampp\htdocs\skelbiu\fetch.php on line 5

    My script :

    extension_loaded('ffmpeg') or die('Error in loading ffmpeg');

    $ffmpegInstance = new ffmpeg_movie('Untitled.avi');
    echo "getDuration: " . $ffmpegInstance->getDuration() .
    "getFrameCount: " . $ffmpegInstance->getFrameCount() .
    "getFrameRate: " . $ffmpegInstance->getFrameRate() .
    "getFilename: " . $ffmpegInstance->getFilename() .
    "getComment: " . $ffmpegInstance->getComment() .
    "getTitle: " . $ffmpegInstance->getTitle() .
    "getAuthor: " . $ffmpegInstance->getAuthor() .
    "getCopyright: " . $ffmpegInstance->getCopyright() .
    "getArtist: " . $ffmpegInstance->getArtist() .
    "getGenre: " . $ffmpegInstance->getGenre() .
    "getTrackNumber: " . $ffmpegInstance->getTrackNumber() .
    "getYear: " . $ffmpegInstance->getYear() .
    "getFrameHeight: " . $ffmpegInstance->getFrameHeight() .
    "getFrameWidth: " . $ffmpegInstance->getFrameWidth() .
    "getPixelFormat: " . $ffmpegInstance->getPixelFormat() .
    "getBitRate: " . $ffmpegInstance->getBitRate() .
    "getVideoBitRate: " . $ffmpegInstance->getVideoBitRate() .
    "getAudioBitRate: " . $ffmpegInstance->getAudioBitRate() .
    "getAudioSampleRate: " . $ffmpegInstance->getAudioSampleRate() .
    "getVideoCodec: " . $ffmpegInstance->getVideoCodec() .
    "getAudioCodec: " . $ffmpegInstance->getAudioCodec() .
    "getAudioChannels: " . $ffmpegInstance->getAudioChannels() .
    "hasAudio: " . $ffmpegInstance->hasAudio();

    I'm using php 5.2.9 (XAMPP 1.7.1), Windows 7.
    Thanks in advance !