Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (80)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

Sur d’autres sites (12306)

  • How to use FFmpeg to live HLS stream with subtitle ?

    17 août 2023, par iHad 169

    I want to use FFmpeg to live HLS stream with subtitle.
I have a Media. The Media have one video track, two audio track, four subtitle.
But, I tryed this command :

    



    ffmpeg -i input0.mkv \
-map 0:v:0 -c:v libx264 -strict -2 -s 426x240   -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack240p_%d.ts      video/videoTrack240p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1280x720  -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack720p_%d.ts      video/videoTrack720p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1920x1080 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack1080p_%d.ts     video/videoTrack1080p.m3u8 \
-map 0:a:0 -c:a aac                             -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack1_%d.aac        audio/audioTrack0.m3u8 \
-map 0:a:1 -c:a aac                             -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack0_%d.aac        audio/audioTrack1.m3u8 \
-map 0:s:0 -c:s webvtt                          -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack0_%d.vtt  subtitle/subtitleTrack0.m3u8 \
-map 0:s:1 -c:s webvtt                          -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack1_%d.vtt  subtitle/subtitleTrack1.m3u8 \
-map 0:s:2 -c:s webvtt                          -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack2_%d.vtt  subtitle/subtitleTrack2.m3u8 \
-map 0:s:3 -c:s webvtt                          -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename subtitle/subtitleTrack3_%d.vtt  subtitle/subtitleTrack3.m3u8


    



    It show this Error :

    



    ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[matroska,webm @ 0x5631128c1460] Could not find codec parameters for stream 5 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[matroska,webm @ 0x5631128c1460] Could not find codec parameters for stream 6 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'input0.mkv':
  Metadata:
    title           : GRAVITY DAZE The Animation Ouverture
    encoder         : libebml v1.2.3 + libmatroska v1.3.0
    creation_time   : 2017-03-30T06:22:52.000000Z
  Duration: 00:17:23.58, start: 0.000000, bitrate: 2155 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
    Stream #0:1(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Stream #0:2(jpn): Audio: aac (LC), 48000 Hz, stereo, fltp
    Stream #0:3(chi): Subtitle: ass (default)
    Metadata:
      title           : CHT
    Stream #0:4(chi): Subtitle: ass
    Metadata:
      title           : CHS
    Stream #0:5(jpn): Subtitle: hdmv_pgs_subtitle
    Stream #0:6(eng): Subtitle: hdmv_pgs_subtitle
[hls @ 0x5631128fc840] Opening 'subtitle/subtitleTrack0_0.vtt' for writing
[hls @ 0x5631128fc840] Opening 'subtitle/subtitleTrack00.vtt' for writing
[mpegts @ 0x56311296bda0] No streams to mux were specified
Could not write header for output file #5 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #1:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #2:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #3:0 (aac (native) -> aac (native))
  Stream #0:2 -> #4:0 (aac (native) -> aac (native))
  Stream #0:3 -> #5:0 (ass (ssa) -> webvtt (native))
  Stream #0:4 -> #6:0 (ass (ssa) -> webvtt (native))
  Stream #0:5 -> #7:0 (hdmv_pgs_subtitle (pgssub) -> webvtt (native))
  Stream #0:6 -> #8:0 (hdmv_pgs_subtitle (pgssub) -> webvtt (native))
    Last message repeated 1 times


    



    If the command not add subtitle :

    



    ffmpeg -i input0.mkv \
-map 0:v:0 -c:v libx264 -strict -2 -s 426x240   -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack240p_%d.ts      video/videoTrack240p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1280x720  -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack720p_%d.ts      video/videoTrack720p.m3u8 \
-map 0:v:0 -c:v libx264 -strict -2 -s 1920x1080 -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename video/videoTrack1080p_%d.ts     video/videoTrack1080p.m3u8 \
-map 0:a:0 -c:a aac                             -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack1_%d.aac        audio/audioTrack0.m3u8 \
-map 0:a:1 -c:a aac                             -f hls -hls_time 10 -hls_list_size 6 -hls_wrap 10 -hls_segment_filename audio/audioTrack0_%d.aac        audio/audioTrack1.m3u8


    



    The streaming is work without error.
I cannot find FFmpeg streaming with subtitle example on long time.

    


  • Perl and ffmpeg script

    21 novembre 2016, par armight29

    The first part of my script that asks whether to check for cinavia doesn’t work. That is, if I type in ’y’ or ’Y’ it doesn’t proceed to the CNVIACHk function but goes instead to the MVIEPARAMs function.

    # GET FILE INPUT..

    print "Enter Filename..";
    my $MOVIe = <stdin>;

    print "Check For Cinavia? Enter y or n\n";
    my $CNVIAQUESt = <stdin>;

    if ( $CNVIAQUESt eq "y" || $CNVIAQUESt eq "Y" ) {
       CNVIACHk( $MOVIe );
    }
    else {
       MVIEPARAMs( $MOVIe );
    }


    sub MVIEPARAMs {

       system(
           "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $MOVIe"
       );

       print "Duration In Seconds..";
       $DURATIOn = <stdin>;

       system(
           'ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width "$MOVIe"'
       );

       print "Movie Width? ";
       $MOVIEWIDTh = <stdin>;

       print "Movie Height? ";
       $MOVIEHEIGHt = <stdin>;

       print "Enter Target Width.. ";
       $TARGETWIDTh = <stdin>;

       print "Enter Target Height.. ";
       $TARGETHEIGHt = <stdin>;

       system(
           'ffprobe -show_entries stream=index,codec_type:stream_tags=language -of compact "$MOVIe" -v 0 | grep eng'
       );

       print "Enter number of English Audio Track.. ";
       $ENGAUDTRk = <stdin>;

       print "English Audio Track Number Is ", $ENGAUDTRk, ".";
       $BTRTe = 31875072 / $DURATIOn;

       DETRMNEPAd;
    }


    sub DETRMNEPAd {

       if ( $MOVIEWIDTh &lt; $TARGETWIDTh ) {
           $X = $TARGETWIDTh - $MOVIEWIDTh / 2;
       }
       elsif ( $MOVIEHEIGHt &lt; $TARGETHEIGHt ) {
           $Y = $TARGETHEIGHt - $MOVIEHEIGHt / 2;
           $X = 0;
           print $Y;
       }
       else {
           print "Padding Not Needed Moving On...";
           CNVRTWOPAd();
       }

       CNVRTWPAd();
    }


    sub CNVIACHk {

       print "Checking Movie For Cinavia.. ";
       system( "cinde -i $MOVIe -q high -l" );

       print "Enter Track To Check.. ";
       $TRKTOCHEk = <stdin>;

       system( "cinde -i $MOVIe -q high -t $TRKTOCHEk" );

       print "Was Cinavia Detected?";
       $CNVIACHKANSr = <stdin>;

       if ( $CNVIACHKANSr eq "y" ) {
           exit;
       }
       else {

           print "Would You Like To Check Another Track?";
           $CHKANTHRTRk = <stdin>;

           if ( $CHKANTHRTRk eq "y" ) {
               CNVIACHk();
           }
           else {
               MVIEPARAMs();
           }
       }
    }


    sub CNVRTWOPAd {

       print "BEGINNING CONVERSION...\n";

       print "What Preset Would You Like To Use?";
       $PRESEt = <stdin>;

       system(
           "ffmpeg -i $MOVIe -map 0:0 -map 0:$ENGAUDTRk -c:v libx264 -b:v $BTRTe -preset $PRESEt -strict -2 -c:a ac3 -b:a 192k -threads 12 -pass 1 -f matroska dummy &amp;&amp; ",
           "ffmpeg -i $MOVIe -map 0:0 -map 0:$ENGAUDTRk -c:v libx264 -b:v $BTRTe -preset $PRESEt -strict -2 -c:a ac3 -b:a 192k -threads 12 -pass 2 -f matroska ENCODE1.mkv"
       );
    }


    sub CNVRTWPAd {

       print "BEGINNING CONVERSION...\n";

       print "What Preset Would You Like To Use?";
       my $PRESEt = <stdin>;

       system(
           "ffmpeg -i $MOVIe -map 0:0 -map 0:$ENGAUDTRk -c:v libx264 -b:v $BTRTe -preset $PRESEt -vf \"pad=$TARGETWIDTh:$TARGETHEIGHt:$X:$Y:black\" -strict -2 -c:a ac3 -b:a 192k ",
           " -threads 12 -pass 1 -f matroska dummy &amp;&amp; ffmpeg -i $MOVIe -map 0:0 -map 0:$ENDAUDTRk -c:v libx264 -b:v $BTRTe -preset $PRESEt -vf \"pad=$TARGETWIDTh:$TARGETHEIGHt:$X:$Y:black\"",
           " -strict -2 -c:a ac3 -b:a 192k -threads 12 -pass 2 -f matroska ENCODE1.mkv"
       );
    }
    </stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin></stdin>
  • RUN FFMPEG IN PYTHON

    7 janvier 2023, par SMART

    I have 1 video & 1 audio.

    &#xA;

    video's duration : 4s

    &#xA;

    audio's duration : 7.48 s

    &#xA;

    i wrote python function to combine these files

    &#xA;

    MY CODE :

    &#xA;

     import subprocess as sp&#xA;&#xA;    def runffmpeg(cmd):&#xA;        try:&#xA;            pipe = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT,&#xA;                            universal_newlines=True)&#xA;    &#xA;            ffmpeg_output, _ = pipe.communicate()&#xA;    &#xA;            print(ffmpeg_output)&#xA;            return (ffmpeg_output)&#xA;    &#xA;        except sp.CalledProcessError as err:&#xA;            print("FFmpeg stdout output on error:\n" &#x2B; err.output)&#xA;    &#xA;    def get_duration(fn):&#xA;        cmd = (&#xA;            f"ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {fn}")&#xA;    &#xA;        cmd1 = (&#xA;            f"ffprobe -v error -of flat=s_ -select_streams 1 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 {fn}")&#xA;        try:&#xA;            pipe = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT,&#xA;                            universal_newlines=True)&#xA;    &#xA;            viddur, _ = pipe.communicate()&#xA;    &#xA;            print(viddur)&#xA;    &#xA;            pipe = sp.Popen(cmd1, stdout=sp.PIPE, stderr=sp.STDOUT,&#xA;                            universal_newlines=True)&#xA;    &#xA;            auddur, _ = pipe.communicate()&#xA;    &#xA;            try:&#xA;                auddur = float(auddur.strip())&#xA;            except:&#xA;                auddur = 0&#xA;    &#xA;            print(auddur)&#xA;    &#xA;            # if (len(auddur) == 0):&#xA;            #     auddur = 0&#xA;    &#xA;            return float(viddur.strip()), (auddur)&#xA;    &#xA;        except sp.CalledProcessError as err:&#xA;            print("FFmpeg stdout output on error:\n" &#x2B; err.output)&#xA;    &#xA;&#xA;def set_audio_to_video(vn, an, output):&#xA;&#xA;    vdur, adur = get_duration(fn=vn)&#xA;    print(f" video duration is  {vdur}")&#xA;&#xA;    auddur, adur = get_duration(fn=an)&#xA;    print(f" audio duration is  {auddur}")&#xA;&#xA;   #cmd = (f" ffmpeg -i {vn} -i {an} -filter_complex \"[0:v]setpts=PTS*{auddur}/{vdur}     [v];atempo={auddur}/{vdur} [a]\" -map \"[v]\" -map 1:a -shortest -y {output}")&#xA;&#xA;cmd = (&#xA;    f" ffmpeg -i {vn} -i {an} -filter_complex \"[0:v]setpts=PTS*{auddur}/{vdur} [v]\" -map \"[v]\" -map 1:a -shortest -pix_fmt yuv420p -y {output}")&#xA;print(cmd)&#xA;&#xA;x = runffmpeg(cmd=cmd)&#xA;

    &#xA;

    to call the function :&#xA;set_audio_to_video(vn="cremovie.mp4", an="a1.wav", output="output.mp4")

    &#xA;

    i'm getting error :

    &#xA;

        Traceback (most recent call last):&#xA;      File "e:\MOVIEPY\FFMPEG-PYTHON.py", line 439, in <module>&#xA;    set_audio_to_video(vn="cremovie.mp4", an="a1.wav", output="output.mp4")&#xA;      File "e:\MOVIEPY\FFMPEG-PYTHON.py", line 424, in set_audio_to_video&#xA;    x = runffmpeg(cmd=cmd)&#xA;  File "e:\MOVIEPY\FFMPEG-PYTHON.py", line 399, in runffmpeg&#xA;    pipe = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.STDOUT,&#xA;      File "C:\Python39\lib\subprocess.py", line 947, in __init__&#xA;    self._execute_child(args, executable, preexec_fn, close_fds,&#xA;      File "C:\Python39\lib\subprocess.py", line 1416, in _execute_child&#xA;    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,&#xA;    OSError: [WinError 87] The parameter is incorrect&#xA;</module>

    &#xA;

    final command generated by function will look like :

    &#xA;

    ffmpeg -i cremovie.mp4 -i a1.wav -filter_complex "[0:v]setpts=PTS*7.489116/4.0 [v]" -map "[v]" -map 1:a -shortest -pix_fmt yuv420p -y output.mp4&#xA;

    &#xA;

    i want to extend the video's duration to audio's duration ( video's duration increased to from 4s to 7.48 s)

    &#xA;

    while running this ffmpeg command in command prompt (CMD) , its working , got no errors but in python , i'm getting errors.

    &#xA;

    SYSTEM DETAILS :&#xA;WINDOWS 10 64 BITS&#xA;PYTHON 3.9 64 BITS

    &#xA;

    WHAT TO DO ?

    &#xA;