Recherche avancée

Médias (9)

Mot : - Tags -/soundtrack

Autres articles (103)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (7085)

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

  • ffmpeg : video to images with pts in filename

    12 février 2016, par ntg

    I am trying to extract images of exact times (say every second) from a mp4 video of an experiment. There are a lot of methods to do that using ffmpeg out there, but surprisingly enough the time accuracy is off.

    To measure accuracy, I have first time-stamped the video using pts, e.g. :

    -vf "[in] scale=640:-2 , drawtext=fontcolor=white:fontsize=22:fontfile='times.ttf':timecode='22\:10\:55\:00:text='03/12/15__':r=23.976023976:x=0:y=0 [out]"

    And as a result I got a millisecond precision time-stamp on the video. I checked the video and it seems the time-stamps are very accurate. I then tried all the methods I could find out there including :

    -Using -ss [timestamp] to go to an exact time and -vframes 1 to get the first frame at that time : this method is extremely slow since it involves calling ffmpeg once for each second of the video. Furthermore, seems to work fine for the first minutes, but then gets out of sync.

    -Using fps=1 and using out_%05d.jpg as the output. This was probably the most inaccurate, as it went off by whole seconds, plus it never got exactly the 0th millisecond.

    -Using a fast fps, and then selecting only the ones I need, e.g. -vf "fps=10, framestep=10, select=not(mod(n\,40))" was promising for the first minutes, but also became inaccurate after that.

    -I tried writing the pts/date as metadata, but (do not know how to /cannot) write to the metadata of a .jpg from ffmpeg...

    The problem is that after some time, if we are using out_%05d.jpg, the numbers get completely out of sinc, while the -ss gets inaccurate, and takes forever.

    Ideally there should be a way to write the %pts or the date as part of the filename... Does anyone know a method to extract images from an .mp4 file with millisecond precision, preferably using ffmpeg (or its library ? I am using python and getting desperate...)

    [Edit : as explained in the comment by Mulvya, the pts is calculated by using the fps of the video, ffmpeg can give it to you. In my case some of the videos have 30 and others 24*(100/1001) fps. Bellow is an example, which was produced by :

    args = ['ffmpeg',
    '-i',
    'c:\\Temp\\scr_cam.mp4',
    '-y',
    '-vf',
    "[in] drawtext=fontcolor=black:fontsize=22:fontfile='times.ttf':timecode='17\\:00\\:29\\:00':text='09/02/16__':r=30.0:x=0:y=0, drawtext=fontcolor=black:fontsize=22:fontfile='times.ttf':timecode='00\\:00\\:00\\:00':text='':r=30.0 :x=0:y=30, drawtext=fontcolor=black:fontsize=22:fontfile='times.ttf':text='n\\: %{n}   pts\\:%{pts}':r=30.0:x=0:y=60 [out]",
    '-c:a',
    'copy',
    '-metadata',
    'creation_time=2016-02-09T17:00:29',
    '-preset',
    'ultrafast',
    '-threads',
    '3',
    'c:\\Temp\\stamped_scr_cam.mp4']
    subprocess.call(args)

    In it we see that indeed pts = n/30 (n is the frame no). I have tried many combinations of the params of the commands I talk in the beginning, so listing all my efforts would take too much space. As we see, the drawtext seems to be very accurate, so it does not seem to be a problem of incorrect fps.

    sample of drawtext

    To get the fps I am using :

    def get_frame_rate_and_duration(filename):
       if not os.path.exists(filename):
           sys.stderr.write("ERROR: filename %r was not found!" % (filename,))
           return -1
       args = ["ffprobe",filename,"-v","0","-select_streams","v","-print_format","flat"]
       args.extend(["-show_entries","stream=r_frame_rate"])
       args.extend(["-show_entries","format=duration"])
       out = subprocess.check_output(args).split("\n")
       rate = out[0].split('=')[1].strip()[1:-1].split('/')
       duration = pd.Timedelta("{0} sec".format(out[1].split('=')[1].strip()[1:-1]))
       if len(rate)==1:
           rate = float(rate[0])
       if len(rate)==2:
           rate =  float(rate[0])/float(rate[1])
       else:
           rate = -1
       return rate, duration