Recherche avancée

Médias (91)

Autres articles (63)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

Sur d’autres sites (5770)

  • How to buffer videojs so preload won't show ?

    9 septembre 2015, par toy

    I’m building video cutting tool using videojs. In order to give the feedback to user right away instead of using ffmpeg to merge the video right away. I just swap the videos instead. However, during the swapping you would see the loading icon when the second video is being loaded. Is there any tricks that would tell videojs to load the video before so when the video plays it would just play right away.

    http://jsfiddle.net/noppanit/odwqqoss/2/

    Here’s my code

    <div>
       <video preload="auto" class="vjs-tech" src="http://www.w3schools.com/html/mov_bbb.mp4">
           <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
       </source></video>
    </div>
    <div>
       <div>
           <label>From</label>
           <input type="text" class="start-time" />
       </div>
       <div>
           <label>To</label>
           <input type="text" class="stop-time" />
       </div>
       <div>
           <input type="button" value="Select" />
       </div>
    </div>
    <div>
       <video preload="auto" class="vjs-tech" src="http://www.w3schools.com/html/mov_bbb.mp4">
           <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
       </source></video>
    </div>
    <div>
       <div>
           <label>From</label>
           <input type="text" class="start-time-video1" />
       </div>
       <div>
           <label>To</label>
           <input type="text" class="stop-time-video1" />
       </div>
       <div>
           <input type="button" value="Select" />
       </div>
    </div>
    <div>
       <input type="button" value="Cut!" />
    </div>
    <div></div>




       (function ($) {
       $('#cut-video').on('click', function () {
           var video = videojs("example_video_1");
           var startTime = $('.start-time');
           var stopTime = $('.stop-time');
           video.currentTime(startTime.val());
           video.play();
           video.on('timeupdate', function (e) {
               if (video.currentTime() >= stopTime.val()) {
                   video.pause();
               }
           });

       });

       $('#cut-video1').on('click', function () {
           var video = videojs("example_video_2");
           var startTime = $('.start-time-video1');
           var stopTime = $('.stop-time-video1');
           video.currentTime(startTime.val());
           video.play();
           video.on('timeupdate', function (e) {
               if (video.currentTime() >= stopTime.val()) {
                   video.pause();
               }
           });
       });

       $('#cut').on('click', function () {
           var video = $('<video></video>');
           video.attr('id', 'result1');
           video.addClass('video-js vjs-default-skin');
           video.attr('width', 300);

           var source = $('<source></source>');
           source.attr('src', 'http://www.w3schools.com/html/mov_bbb.mp4');
           source.attr('type', 'video/mp4');

           video.append(source);
           $('#result').append(video);

           var player = videojs("result1");
           var startTime = $('.start-time');
           var stopTime = $('.stop-time');

           player.currentTime(startTime.val());
           player.play();

           player.on('timeupdate', function (e) {
               if (player.currentTime() >= stopTime.val()) {
                   player.src({
                       "type": "video/mp4",
                       src: 'http://www.w3schools.com/html/mov_bbb.mp4'
                   });
                   var startTime1 = $('.start-time-video1');
                   var stopTime1 = $('.stop-time-video1');

                   player.currentTime(startTime1.val());
                   player.play();
                   player.on('timeupdate', function (e1) {
                       if (player.currentTime() >= stopTime1.val()) {
                           player.pause();
                       }
                   });
               }
           });




       });

    })(jQuery);
  • Python buffered IO ending early streaming with multiple pipes

    5 octobre 2022, par Malibu

    I'm trying to make a continuous livestream of videos downloaded via yt-dlp. I need to port this (working) bash command into Python.

    &#xA;

    (&#xA;    youtube-dl -v --buffer-size 16k https://youtube.com/watch?v=QiInzFHIDp4 -o - | ffmpeg -i - -f mpegts -c copy - ;&#xA;    youtube-dl -v --buffer-size 16k https://youtube.com/watch?v=QiInzFHIDp4 -o - | ffmpeg -i - -f mpegts -c copy - ;&#xA;) | ffmpeg -re -i - -c:v libx264 -f flv rtmp://127.0.0.1/live/H1P_x5WPF&#xA;

    &#xA;

    My Python attempt is cutting off the last 2 seconds of each video. My suspicion is that although the first pipe, yt-dlp, has an empty stdout, there is still data travelling between the second and third pipe. I haven't been able to figure out a way to properly handle the data between those two pipes at the end of the video.

    &#xA;

    from subprocess import Popen, PIPE, DEVNULL&#xA;&#xA;COPY_BUFSIZE = 65424&#xA;&#xA;playlist = [&#xA;    {&#xA;        # 15 second video&#xA;        "url": "https://youtube.com/watch?v=QiInzFHIDp4"&#xA;    },&#xA;    {&#xA;        # 15 second video&#xA;        "url": "https://youtube.com/watch?v=QiInzFHIDp4"&#xA;    },&#xA;    {&#xA;        # 15 second video&#xA;        "url": "https://youtube.com/watch?v=QiInzFHIDp4"&#xA;    },&#xA;]&#xA;&#xA;if __name__ == "__main__":&#xA;    stream_cmd = [&#xA;        "ffmpeg", "-loglevel", "error",&#xA;        "-hide_banner", "-re", "-i", "-",&#xA;        "-c:v", "libx264",&#xA;        "-f", "flv",&#xA;        "-b:v", "3000k", "-minrate", "3000k",&#xA;        "-maxrate", "3000k", "-bufsize", "3000k",&#xA;        "-r", "25", "-pix_fmt", "yuv420p",&#xA;        "rtmp://127.0.0.1/live/H1P_x5WPF"&#xA;    ]&#xA;    print(f&#x27;Stream command:\n"{" ".join(stream_cmd)}"&#x27;)&#xA;&#xA;    encoder_cmd = [&#xA;        "ffmpeg", "-re", "-i", "-", "-f", "mpegts",&#xA;        "-c", "copy", "-"&#xA;    ]&#xA;    print(f&#x27;Encoder command:\n"{" ".join(encoder_cmd)}"&#x27;)&#xA;&#xA;    stream_p = Popen(stream_cmd, stdin=PIPE, stderr=DEVNULL)&#xA;&#xA;    for video in playlist:&#xA;        yt_dlp_cmd = [&#xA;            "yt-dlp", "-q",&#xA;            video["url"],&#xA;            "-o", "-"&#xA;        ]&#xA;&#xA;        print("Now playing: " &#x2B; video["url"])&#xA;&#xA;        with Popen(yt_dlp_cmd, stdout=PIPE) as yt_dlp_p:&#xA;            with Popen(encoder_cmd, stdin=PIPE, stdout=PIPE, stderr=DEVNULL) as encoder_p:&#xA;                while True:&#xA;                    yt_dlp_buf = yt_dlp_p.stdout.read(COPY_BUFSIZE)&#xA;                    print("READ: yt_dlp")&#xA;                    if not yt_dlp_buf:&#xA;                        print("yt-dlp buffer empty")&#xA;                        # Handle any data in 2nd/3rd pipes before breaking?&#xA;                        break&#xA;&#xA;                    written = encoder_p.stdin.write(yt_dlp_buf)&#xA;                    print("WRITE: encoder. Bytes: " &#x2B; str(written))&#xA;&#xA;                    encoder_buf = encoder_p.stdout.read(COPY_BUFSIZE)&#xA;                    # if not encoder_buf:&#xA;                    #     print("encoder_buf empty")&#xA;                    #     break&#xA;                    print("READ: encoder")&#xA;&#xA;                    stream_bytes_written = stream_p.stdin.write(encoder_buf)&#xA;                    print("WRITE: stream, Bytes: " &#x2B; str(stream_bytes_written))&#xA;

    &#xA;

    Running Python 3.6.9 on MacOS.

    &#xA;

  • FFmpeg python doesn't merge

    24 avril 2021, par MaLoLHDX

    I was making this youtube downloader GUI with Python : it asks for the URL, gives you a list with the possible quality settings and downloads the selected video file and the best audio file with youtube-dl. However, when I tell ffmpeg to merge the two separate downloaded files, it doesn't do anything and it doesn't say anything in the console either. Is there anything I'm missing ?

    &#xA;

    Here's the relevant part of the code (starts at line 153) :

    &#xA;

                #Adding input arguments for ffmpeg&#xA;            ffmpeg_video = ffmpeg.input(self.video_title)&#xA;            ffmpeg_audio = ffmpeg.input(self.audio_title)&#xA;            output_ffmpeg_title = &#x27;./videos/&#x27; &#x2B; self.youtube_title&#xA;            #Merging with ffmpeg&#xA;            out = ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec=&#x27;copy&#x27;, acodec=&#x27;aac&#x27;)&#xA;            out.run&#xA;

    &#xA;

    Here's the full code :

    &#xA;

    import youtube_dl&#xA;import tkinter as tk&#xA;import operator&#xA;import ffmpeg&#xA;class GUI:&#xA;    def __init__(self):&#xA;        #Creating initial window&#xA;        self.window = tk.Tk()&#xA;        self.window.title(&#x27;YTDL&#x27;)&#xA;        self.window.geometry(&#x27;300x70&#x27;)&#xA;        &#xA;        self.urlbox = tk.Entry(self.window)&#xA;        self.urlbox.pack(padx=5,pady=5)&#xA;        #Creating download button, which will open the format selection window&#xA;        downbutton = tk.Button(self.window, text="Download", command= self.check_url)&#xA;        downbutton.pack(padx=5, pady=5)&#xA;        #Creating a variable to keep track of the point in the GUI options selection&#xA;        self.format_select_process = False&#xA;        &#xA;        self.window.mainloop()&#xA;    def check_url(self):&#xA;        #Saving selected URL to variable&#xA;        self.selected_url = self.urlbox.get()&#xA;        self.urlbox.delete(0, &#x27;end&#x27;)&#xA;        #If something was written in the URL box, try to go the next step&#xA;        if len(self.selected_url) != 0:&#xA;            self.get_formats(self.selected_url)&#xA;        else:&#xA;            print(&#x27;URL box is empty!&#x27;)&#xA;    def get_formats(self, x):&#xA;        with youtube_dl.YoutubeDL() as ydl:&#xA;            meta = ydl.extract_info(x, download=False)&#xA;            #Save formats from &#x27;meta&#x27; to &#x27;self.formats&#x27;&#xA;            self.formats = meta.get(&#x27;formats&#x27;, [meta])&#xA;            self.youtube_title = meta.get(&#x27;title&#x27;, [meta])&#xA;            #Creating two dictionaries for the list of format sizes and extensions&#xA;            self.f_list_size_dict = {}&#xA;            self.f_list_ext_dict = {}&#xA;            #Creating audio format list&#xA;            self.audio_format_list = []&#xA;        #For every format in self.formats, add its format, extension, fps and filesize to self.f_list&#xA;        for f in self.formats:&#xA;            self.f_list = &#x27;-&#x27; &#x2B; f[&#x27;format&#x27;]&#x2B; &#x27; -&#x27; &#x2B; f[&#x27;ext&#x27;] &#x2B; &#x27; -&#x27; &#x2B; str(f[&#x27;fps&#x27;]) &#x2B; &#x27; &#x27; &#x2B; str(f[&#x27;filesize&#x27;])&#xA;            if &#x27;audio only&#x27; in f[&#x27;format&#x27;]:&#xA;                #Add an element to each dictonary whose name is the format ID and whose value is its filesize/extension&#xA;                self.f_list_size_dict[f[&#x27;format&#x27;].split(&#x27; -&#x27;)[0]] = f[&#x27;filesize&#x27;]&#xA;                self.f_list_ext_dict[f[&#x27;format&#x27;].split(&#x27; -&#x27;)[0]] = f[&#x27;ext&#x27;]&#xA;                #Add to the audio format list the current audio format ID&#xA;                self.audio_format_list.append(f[&#x27;format&#x27;].split(&#x27; -&#x27;)[0])&#xA;        print(&#x27;Audio format list:&#x27;)&#xA;        print(self.audio_format_list)&#xA;        print(&#x27;Size list dict:&#x27;)&#xA;        print(self.f_list_size_dict)&#xA;        print(&#x27;Ext list size dict:&#x27;)&#xA;        print(self.f_list_ext_dict)&#xA;        """&#xA;        #Making a new list which only contains the audio format IDs&#xA;        self.audio_format_list = str(self.f_list_size_dict.keys()).split(&#x27;([&#x27;)[1]&#xA;        self.audio_format_list = self.audio_format_list.split(&#x27;])&#x27;)[0]&#xA;        self.audio_format_list = self.audio_format_list.replace("&#x27;", "")&#xA;        self.audio_format_list = self.audio_format_list.split(&#x27;, &#x27;)&#xA;        print(&#x27;Cleaned up audio format list:&#x27;)&#xA;        print(self.audio_format_list)&#xA;        """&#xA;        #Here the program starts looking for the best audio format&#xA;        #In the try block, the program gets the best audio format&#x27;s ID from the size dict and extension from the ext dict&#xA;        #In the except block, the program gets the ID from the audio format list and the extension from the ext dict&#xA;        try:&#xA;            self.highest_audio = max(self.f_list_size_dict.items(), key=operator.itemgetter(1))[0]&#xA;            self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)&#xA;            print(&#x27;Best audio format ID: &#x27; &#x2B; self.highest_audio)&#xA;            print(&#x27;Best audio format extension: &#x27; &#x2B; self.highest_audio_ext)&#xA;        except:&#xA;            self.highest_audio = max(self.audio_format_list)&#xA;            self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)&#xA;            print(self.highest_audio)&#xA;            print(self.highest_audio_ext)&#xA;        #Going to next sted of the code, which renders the format choice window&#xA;        self.format_select()&#xA;    def format_select(self):&#xA;        self.window.withdraw()&#xA;        format_select_window = tk.Toplevel()&#xA;        format_select_window.attributes(&#x27;-topmost&#x27;, True)&#xA;        format_select_window.geometry("300x350")&#xA;        format_select_window_label = tk.Label(format_select_window, text="Select the video format")&#xA;        format_select_window_label.pack(padx=5, pady=5)&#xA;        format_select_window.protocol(&#x27;WM_DELETE_WINDOW&#x27;, lambda: exit())&#xA;&#xA;        self.format_listbox = tk.Listbox(format_select_window, height=15, width=40, yscrollcommand=1)&#xA;        self.format_listbox.pack(padx=10, pady=10)&#xA;        for index, item in enumerate(self.f_list):&#xA;            self.f_list_lenght = index&#xA;        download_button = tk.Button(format_select_window, text=&#x27;Download&#x27;, command=self.download)&#xA;        download_button.pack(padx=10, pady=10)&#xA;        #Adding options to the listbox&#xA;        for f in self.formats:&#xA;            #If it is adding an audio only format, it will add the ID, filesize (if possible with try block) and extension&#xA;            if &#x27;audio only&#x27; in f[&#x27;format&#x27;] &#x2B; &#x27; &#x27; &#x2B; str(f[&#x27;fps&#x27;]) &#x2B; &#x27; FPS &#x27; &#x2B; f[&#x27;ext&#x27;]:&#xA;                try:&#xA;                    mb_filesize = round(f[&#x27;filesize&#x27;] / 1024 / 1024, 2)&#xA;                    self.format_listbox.insert(self.f_list_lenght, f[&#x27;format&#x27;] &#x2B; &#x27; &#x27; &#x2B; str(mb_filesize) &#x2B; &#x27; MiB  &#x27; &#x2B; f[&#x27;ext&#x27;]) &#xA;                except:&#xA;                    self.format_listbox.insert(self.f_list_lenght, f[&#x27;format&#x27;] &#x2B; &#x27;  &#x27; &#x2B; f[&#x27;ext&#x27;])&#xA;            #If it is adding a video format, it will add the ID, FPS, filesize (if possible with the try block) and extension&#xA;            else:&#xA;                try:&#xA;                    mb_filesize = round(f[&#x27;filesize&#x27;] / 1024 / 1024, 2)&#xA;                    self.format_listbox.insert(self.f_list_lenght, f[&#x27;format&#x27;] &#x2B; &#x27; &#x27; &#x2B; str(f[&#x27;fps&#x27;]) &#x2B; &#x27; FPS&#x27; &#x2B; &#x27; &#x27; &#x2B; str(mb_filesize) &#x2B; &#x27; MiB  &#x27; &#x2B; f[&#x27;ext&#x27;])&#xA;                except:&#xA;                    self.format_listbox.insert(self.f_list_lenght, f[&#x27;format&#x27;] &#x2B; &#x27; &#x27; &#x2B; str(f[&#x27;fps&#x27;]) &#x2B; &#x27; FPS  &#x27; &#x2B; f[&#x27;ext&#x27;])&#xA;    def download(self):&#xA;        #Getting the list position of the selected format&#xA;        selected_format_list_position = self.format_listbox.curselection()&#xA;        #Getting the text of the selected format list item&#xA;        selected_format = self.format_listbox.get(selected_format_list_position)&#xA;        print(&#x27;Selected format: &#x27; &#x2B; selected_format)&#xA;        #Cutting from the selected format list item text everything past &#x27; -&#x27; to only get the format&#x27;s ID&#xA;        selected_format_id = selected_format.split(&#x27; -&#x27;)[0]&#xA;        print(&#x27;Selected format ID: &#x27; &#x2B; selected_format_id)&#xA;        #Converting the ID to string&#xA;        final_selected_format_id = str(selected_format_id)&#xA;        print(&#x27;Final selected format: &#x27; &#x2B; final_selected_format_id)&#xA;        #Cutting from the selected format list item text everything before &#x27;  &#x27; to only get the extension&#xA;        final_ext = selected_format.split(&#x27;  &#x27;)[1]&#xA;        print(&#x27;Final video extension: &#x27; &#x2B; final_ext)&#xA;        if &#x27;audio only&#x27; in selected_format:&#xA;            #Creating the download options dictionary (not working):&#xA;            #Setting the download location to the videos folder,&#xA;            #preventing the program from downloading a whole playlist,&#xA;            #telling youtube-dl to extract audio (&#x27;x&#x27;),&#xA;            #giving youtube-dl the requested format (which is only audio).&#xA;            self.ydl_opts = {&#x27;outtmpl&#x27;:&#x27;./videos/%(title)s.%(ext)s&#x27;, &#x27;noplaylist&#x27;: True, &#x27;x&#x27;: True, &#x27;format&#x27;: final_selected_format_id}&#xA;            #Downloading&#xA;            with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:&#xA;                ydl.download([self.selected_url])&#xA;        elif &#x27;audio only&#x27; not in selected_format:&#xA;            #Adding &#x27;&#x2B;bestaudio&#x27; to the selected format ID (which is only a video ID in this case)&#xA;            final_selected_format_id_video_audio = str(selected_format_id) &#x2B; &#x27;&#x2B;bestaudio&#x27;&#xA;            #Creating the download options dictionary:&#xA;            #Setting the download location to the videos folder,&#xA;            #preventing the program from downloading a whole playlist,&#xA;            #giving youtube-dl the requested format with audio.&#xA;            self.ydl_opts = {&#x27;outtmpl&#x27;:&#x27;./videos/%(title)s.%(ext)s&#x27;, &#x27;noplaylist&#x27;: True, &#x27;format&#x27;: final_selected_format_id_video_audio}&#xA;            #Predicting the video file title and location for future ffmpeg merge&#xA;            self.video_title = &#x27;./videos/&#x27; &#x2B; self.youtube_title &#x2B; &#x27;.f&#x27; &#x2B; str(selected_format_id) &#x2B; &#x27;.&#x27; &#x2B; final_ext&#xA;            print(&#x27;Video file title: &#x27; &#x2B; self.video_title)&#xA;            #Predicting the audio file title and location for future ffmpeg merge&#xA;            self.audio_title = &#x27;./videos/&#x27; &#x2B; self.youtube_title &#x2B; &#x27;.f&#x27; &#x2B; str(self.highest_audio) &#x2B; &#x27;.&#x27; &#x2B; self.highest_audio_ext&#xA;            print(&#x27;Audio file title: &#x27; &#x2B; self.audio_title)&#xA;            #Downloading with youtube-dl&#xA;            with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:&#xA;                ydl.download([self.selected_url])&#xA;            #Adding input arguments for ffmpeg&#xA;            ffmpeg_video = ffmpeg.input(self.video_title)&#xA;            ffmpeg_audio = ffmpeg.input(self.audio_title)&#xA;            output_ffmpeg_title = &#x27;./videos/&#x27; &#x2B; self.youtube_title&#xA;            #Merging with ffmpeg&#xA;            ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec=&#x27;copy&#x27;, acodec=&#x27;aac&#x27;)&#xA;GUI()&#xA;

    &#xA;

    If there is a better way of integrating ffmpeg with youtube-dl in Python, please tell me.

    &#xA;