Recherche avancée

Médias (91)

Autres articles (39)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

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

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

  • Thread in Thread

    28 mai 2014, par user3679963

    My company is working for visual effects and we set up an internal shot playback via a browser for our clients. For that we need to upload the video file to a FTP server.

    I want to convert a image sequence to mp4 and upload this file directly after the rendering will finish.

    For that I use :

    • one command prompt to convert
    • one command prompt to get an `md5hash
    • one for uploading the file

    I already achieved that on my local computer, where I just chained os.system('command').

    After recognizing that the program freezes very long with longer image sequences I changed the script to spawn a thread using the os.system chain.
    But on the Render Farm Server this script does not actually work.

    The RenderFarm Server runs Python 2.5

    There are some code examples :

    class CopraUpload(threading.Thread):

       # initializing Thread
       # via super constructor
       def __init__(self):
           threading.Thread.__init__(self)


       # return the size of the
       # created mp4 file
       #
       # @return: the file size in byte
       def _getFileSize(self):


       # creates a random id for organising
       # the server upload used as flag
       #
       # @return: a hash
       def _getHash(self):
               self.fileLoc = str(self.outputfileName + '.mp4')
               self.fileLoc = os.path.normpath(self.fileLoc)
               return str(os.path.getsize(self.fileLoc))

       # integrates the "missing" data for the xml file
       # generated post render from the mp4 file
       def _setPreviewDataToXML(self):
           self.xmlFile = str(self.outputfileName + '_copraUpload.xml')
           self.xmlFile = os.path.normpath(self.xmlFile)

           ett = ET.parse(self.xmlFile)
           root = ett.getroot()
           for child in root.getiterator('preview_size'):
               child.text = self._getFileSize()
           for child in root.getiterator('preview_md5hash'):
               child.text = self._getHash()
           ett.write(self.xmlFile)


       # create a connection to a ftp server
       # and copies the mp4 file and the xml file
       # on the server
       def _uploadToCopra(self):

           os.system(self.uploadCommand)
           #process = Popen(self.uploadCommand)


       # the main function of the program
       # called via start from a Thread Object
       def run(self):

           # the command which will be send to the commando shell
           # for further adjustments see ffmpeg help with ffmpeg.exe -h
           FinalCommand = self.ffmpegLocation + " -r "+ self.framerate + " -i " + self.inputPath + " -an -strict experimental -s hd720 -vcodec libx264 -preset slow -profile:v baseline -level 31 -refs 1 -maxrate 6M -bufsize 10M -vb 6M -threads 0 -g 8 -r " + self.framerate + " " + self.outputfileName + ".mp4 -y"
           FinalCommandList = FinalCommand.split(" ")


           # calling the program
           print "Start ffmpeg convertion"

           outInfo = os.path.normpath("C:\\Users\\sarender\\Desktop\\stdoutFFMPEG.txt")
           outError = os.path.normpath("C:\\Users\\sarender\\Desktop\\stderrFFMPEG.txt")
           stdoutFile = open(outInfo,"w")
           stderrFile = open(outError,"w")

           handle = subp.check_all(FinalCommandList,stdout = stdoutFile,stderr = stderrFile)
           handle.communicate()
           stdoutFile.close()
           stderrFile.close()
           print "Convertion from ffmpeg done"

           # fill the xml file with the missing data
           # - preview file size
           # - preview md5hash
           self._setPreviewDataToXML()
           self._uploadToCopra()
           print "---------------------------------->FINISHED------------------------------------------------------>"


       # Creates a callable Thread for the Copra Upload.
       # start is calling the run method which will start the Uploading

    and the main start :

       if "$(RenderSet.writenode)" == "PREVIEW":
           print "---------------------------------->Initializing Script------------------------------------------------------>"
           process = CopraUpload()
           process.start()

    What happens :

    The script starts after the rendering and ffmpeg converts the image sequence and creates an mp4. But it stops after that. It does not print "Conversion from ffmpeg complet". Just stops the script.

    It actually should create the Thread converting with ffmpeg and wait until it finishes. After it should write some stuff in an xml file and upload both to the server.

    Do I miss something ? Is subprocess within a thread not the way to go ? But I need a Thread because I can not deadlock the render management server.

  • JavaFX MediaPlayer unable to play local m3u8 file

    3 mai 2017, par Lennart

    I want to show a live stream of a web cam in my JavaFX application using the MediaPlayer/MediaView. My attempt was to use ffmpeg to record a HLS and to play the resulting m3u8 file, but that throws the following exception (VLC plays the video without problems) :

    MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
       at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
       at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
       at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
       at de.fraunhofer.iosb.ias.flow.assessment.management.monitor.MonitorViewController.testStream(MonitorViewController.java:203)
       ... 58 more
    Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
       at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274)
       at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
       at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
       ... 60 more
    </init>

    I debugged the player creation and the error occurs inside the constructor of GSTMediaPlayer when GSTMediaPlayer.gstInitPlayer() is called. This native method returns the error code 257, which javafx maps to MediaError.ERROR_MEDIA_NULL.

    I used the following ffmpeg command to record the video :

    ffmpeg -hide_banner -y -rtbufsize 250MB -f dshow -pixel_format yuv420p -video_size 960x720 -i video="Logitech HD Pro Webcam C920" -c:v libx264 -crf 20 -pix_fmt yuv420p out.m3u8

    I’m pretty sure that the encoding matches the requirements of javafx, because if I change the output container from m3u8 to mp4, the video is played without problems using the exact same ffmpeg command.

    This is the output of ffprobe for the m3u8 file :

    Input #0, hls,applehttp, from 'out.m3u8':
     Duration: 00:00:24.23, start: 1.466667, bitrate: 0 kb/s
     Program 0
       Metadata:
         variant_bitrate : 0
       Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 960x720, 30 fps, 30 tbr, 90k tbn, 60 tbc

    And for the mp4 file :

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.41.100
     Duration: 00:01:04.93, start: 0.000000, bitrate: 1676 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x720, 1673 kb/s, 30 fps, 30 tbr, 10000k tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler

    The resulting m3u8 file looks like this :

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:9
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:8.333322,
    out0.ts
    #EXTINF:8.333333,
    out1.ts
    #EXTINF:7.133322,
    out2.ts
    #EXTINF:0.433333,
    out3.ts
    #EXT-X-ENDLIST

    Update : After I found this reference m3u file, I think that the problem is that the file is stored locally and isn’t delivered via HTTP. The video plays fine with this :

    Media media = new Media("http://download.oracle.com/otndocs/products/javafx/JavaRap/prog_index.m3u8");
    MediaPlayer player = new MediaPlayer(media);
    player.setAutoPlay(true);
    mediaView.setMediaPlayer(player);

    But after I downloaded the reference m3u and all of its segments and tried to open the local file like this, the error occurred again :

    File video = new File("H://Projects//Tools//ref//prog_index.m3u8");
    Media media = new Media(video.toURI().toString());
    MediaPlayer player = new MediaPlayer(media);
    player.setAutoPlay(true);
    mediaView.setMediaPlayer(player);

    I tried to change my m3u file so that the segements are referenced with absolute paths. I tried different notations (H:\f\out0.ts, H:/f/out0.ts, H://f//out0.ts, file:/H:/f/out0.ts, file:///H:/f/out0.ts), but I couldn’t get it to work.

  • JavaFX MediaPlayer unable to play local m3u8 file

    22 février 2020, par Lennart

    I want to show a live stream of a web cam in my JavaFX application using the MediaPlayer/MediaView. My attempt was to use ffmpeg to record a HLS and to play the resulting m3u8 file, but that throws the following exception (VLC plays the video without problems) :

    MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
       at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
       at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
       at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
       at de.fraunhofer.iosb.ias.flow.assessment.management.monitor.MonitorViewController.testStream(MonitorViewController.java:203)
       ... 58 more
    Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
       at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:274)
       at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:118)
       at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
       ... 60 more
    </init>

    I debugged the player creation and the error occurs inside the constructor of GSTMediaPlayer when GSTMediaPlayer.gstInitPlayer() is called. This native method returns the error code 257, which javafx maps to MediaError.ERROR_MEDIA_NULL.

    I used the following ffmpeg command to record the video :

    ffmpeg -hide_banner -y -rtbufsize 250MB -f dshow -pixel_format yuv420p -video_size 960x720 -i video="Logitech HD Pro Webcam C920" -c:v libx264 -crf 20 -pix_fmt yuv420p out.m3u8

    I’m pretty sure that the encoding matches the requirements of javafx, because if I change the output container from m3u8 to mp4, the video is played without problems using the exact same ffmpeg command.

    This is the output of ffprobe for the m3u8 file :

    Input #0, hls,applehttp, from 'out.m3u8':
     Duration: 00:00:24.23, start: 1.466667, bitrate: 0 kb/s
     Program 0
       Metadata:
         variant_bitrate : 0
       Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 960x720, 30 fps, 30 tbr, 90k tbn, 60 tbc

    And for the mp4 file :

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.41.100
     Duration: 00:01:04.93, start: 0.000000, bitrate: 1676 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x720, 1673 kb/s, 30 fps, 30 tbr, 10000k tbn, 60 tbc (default)
       Metadata:
         handler_name    : VideoHandler

    The resulting m3u8 file looks like this :

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:9
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:8.333322,
    out0.ts
    #EXTINF:8.333333,
    out1.ts
    #EXTINF:7.133322,
    out2.ts
    #EXTINF:0.433333,
    out3.ts
    #EXT-X-ENDLIST

    Update : After I found this reference m3u file, I think that the problem is that the file is stored locally and isn’t delivered via HTTP. The video plays fine with this :

    Media media = new Media("http://download.oracle.com/otndocs/products/javafx/JavaRap/prog_index.m3u8");
    MediaPlayer player = new MediaPlayer(media);
    player.setAutoPlay(true);
    mediaView.setMediaPlayer(player);

    But after I downloaded the reference m3u and all of its segments and tried to open the local file like this, the error occurred again :

    File video = new File("H://Projects//Tools//ref//prog_index.m3u8");
    Media media = new Media(video.toURI().toString());
    MediaPlayer player = new MediaPlayer(media);
    player.setAutoPlay(true);
    mediaView.setMediaPlayer(player);

    I tried to change my m3u file so that the segements are referenced with absolute paths. I tried different notations (H:\f\out0.ts, H:/f/out0.ts, H://f//out0.ts, file:/H:/f/out0.ts, file:///H:/f/out0.ts), but I couldn’t get it to work.