Recherche avancée

Médias (91)

Autres articles (17)

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

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

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (2799)

  • Cannot get mp4 video to play in JavaFX app

    23 juin 2016, par CelestialCoyote

    I am trying to use the media player in Java FX to play an mp4 video. I am using the example code from the Oracle. Here is the link.

    http://docs.oracle.com/javafx/2/media/simpleplayer.htm

    I am using the same code with the exception that I want to play the video from my computer rather than going to the internet to get it. I also changed the size of the window to match the size of my video. The video was rendered using FFMPEG with the following parameters.

    ffmpeg -y -r 30 -i ’CellCellCell_Trailer_%05d.jpg’ -r 30 -pix_fmt yuv420p -s 512x512 -vcodec libx264 ’CellCellCell.mp4’

    Could not attach the video to post.

    The video plays in Quicktime and VLC without problems. In the Java App it appears to load, but does not start playing. If I move the time slider, it throws an error, otherwise it just sits there and nothing happens. The file is in a folder called ’media’.

    I have tried several mp4 videos, all with the same results. The player opens, but then does nothing. Any help would be appreciated.

    Here is the code for MediaControl.java file. It is unmodified from the Oracle example.

    package embeddedmediaplayer;

    import javafx.application.Platform;
    import javafx.beans.InvalidationListener;
    import javafx.beans.Observable;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.layout.Priority;
    import javafx.scene.layout.Region;
    import javafx.geometry.Insets;
    import javafx.geometry.Pos;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.Slider;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.Pane;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaPlayer.Status;
    import javafx.scene.media.MediaView;
    import javafx.util.Duration;

    public class MediaControl extends BorderPane {

    private MediaPlayer mp;
    private MediaView mediaView;
    private final boolean repeat = false;
    private boolean stopRequested = false;
    private boolean atEndOfMedia = false;
    private Duration duration;
    private Slider timeSlider;
    private Label playTime;
    private Slider volumeSlider;
    private HBox mediaBar;

    public MediaControl(final MediaPlayer mp) {
       this.mp = mp;
       setStyle("-fx-background-color: #bfc2c7;");
       mediaView = new MediaView(mp);
       Pane mvPane = new Pane() {
       };
       mvPane.getChildren().add(mediaView);
       mvPane.setStyle("-fx-background-color: black;");
       setCenter(mvPane);

       mediaBar = new HBox();
       mediaBar.setAlignment(Pos.CENTER);
       mediaBar.setPadding(new Insets(5, 10, 5, 10));
       BorderPane.setAlignment(mediaBar, Pos.CENTER);

       final Button playButton = new Button(">");

       playButton.setOnAction(new EventHandler<actionevent>() {
           public void handle(ActionEvent e) {
               Status status = mp.getStatus();

               if (status == Status.UNKNOWN || status == Status.HALTED) {
                   // don't do anything in these states
                   return;
               }

               if (status == Status.PAUSED
                       || status == Status.READY
                       || status == Status.STOPPED) {
                   // rewind the movie if we're sitting at the end
                   if (atEndOfMedia) {
                       mp.seek(mp.getStartTime());
                       atEndOfMedia = false;
                   }
                   mp.play();
               } else {
                   mp.pause();
               }
           }
       });
       mp.currentTimeProperty().addListener(new InvalidationListener() {
           public void invalidated(Observable ov) {
               updateValues();
           }
       });

       mp.setOnPlaying(new Runnable() {
           public void run() {
               if (stopRequested) {
                   mp.pause();
                   stopRequested = false;
               } else {
                   playButton.setText("||");
               }
           }
       });

       mp.setOnPaused(new Runnable() {
           public void run() {
               System.out.println("onPaused");
               playButton.setText(">");
           }
       });

       mp.setOnReady(new Runnable() {
           public void run() {
               duration = mp.getMedia().getDuration();
               updateValues();
           }
       });

       mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
       mp.setOnEndOfMedia(new Runnable() {
           public void run() {
               if (!repeat) {
                   playButton.setText(">");
                   stopRequested = true;
                   atEndOfMedia = true;
               }
           }
       });

       mediaBar.getChildren().add(playButton);
       // Add spacer
       Label spacer = new Label("   ");
       mediaBar.getChildren().add(spacer);

       // Add Time label
       Label timeLabel = new Label("Time: ");
       mediaBar.getChildren().add(timeLabel);

       // Add time slider
       timeSlider = new Slider();
       HBox.setHgrow(timeSlider, Priority.ALWAYS);
       timeSlider.setMinWidth(50);
       timeSlider.setMaxWidth(Double.MAX_VALUE);
       timeSlider.valueProperty().addListener(new InvalidationListener() {
           public void invalidated(Observable ov) {
               if (timeSlider.isValueChanging()) {
                   // multiply duration by percentage calculated by slider position
                   mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
               }
           }
       });
       mediaBar.getChildren().add(timeSlider);

       // Add Play label
       playTime = new Label();
       playTime.setPrefWidth(130);
       playTime.setMinWidth(50);
       mediaBar.getChildren().add(playTime);

       // Add the volume label
       Label volumeLabel = new Label("Vol: ");
       mediaBar.getChildren().add(volumeLabel);

       // Add Volume slider
       volumeSlider = new Slider();
       volumeSlider.setPrefWidth(70);
       volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
       volumeSlider.setMinWidth(30);
       volumeSlider.valueProperty().addListener(new InvalidationListener() {
           public void invalidated(Observable ov) {
               if (volumeSlider.isValueChanging()) {
                   mp.setVolume(volumeSlider.getValue() / 100.0);
               }
           }
       });
       mediaBar.getChildren().add(volumeSlider);

       setBottom(mediaBar);
    }

    protected void updateValues() {
       if (playTime != null &amp;&amp; timeSlider != null &amp;&amp; volumeSlider != null) {
           Platform.runLater(new Runnable() {
               public void run() {
                   Duration currentTime = mp.getCurrentTime();
                   playTime.setText(formatTime(currentTime, duration));
                   timeSlider.setDisable(duration.isUnknown());
                   if (!timeSlider.isDisabled()
                           &amp;&amp; duration.greaterThan(Duration.ZERO)
                           &amp;&amp; !timeSlider.isValueChanging()) {
                       timeSlider.setValue(currentTime.divide(duration).toMillis()
                               * 100.0);
                   }
                   if (!volumeSlider.isValueChanging()) {
                       volumeSlider.setValue((int) Math.round(mp.getVolume()
                               * 100));
                   }
               }
           });
       }
    }

    private static String formatTime(Duration elapsed, Duration duration) {
       int intElapsed = (int) Math.floor(elapsed.toSeconds());
       int elapsedHours = intElapsed / (60 * 60);
       if (elapsedHours > 0) {
           intElapsed -= elapsedHours * 60 * 60;
       }
       int elapsedMinutes = intElapsed / 60;
       int elapsedSeconds = intElapsed - elapsedHours * 60 * 60
               - elapsedMinutes * 60;

       if (duration.greaterThan(Duration.ZERO)) {
           int intDuration = (int) Math.floor(duration.toSeconds());
           int durationHours = intDuration / (60 * 60);
           if (durationHours > 0) {
               intDuration -= durationHours * 60 * 60;
           }
           int durationMinutes = intDuration / 60;
           int durationSeconds = intDuration - durationHours * 60 * 60
                   - durationMinutes * 60;
           if (durationHours > 0) {
               return String.format("%d:%02d:%02d/%d:%02d:%02d",
                       elapsedHours, elapsedMinutes, elapsedSeconds,
                       durationHours, durationMinutes, durationSeconds);
           } else {
               return String.format("%02d:%02d/%02d:%02d",
                       elapsedMinutes, elapsedSeconds, durationMinutes,
                       durationSeconds);
           }
       } else {
           if (elapsedHours > 0) {
               return String.format("%d:%02d:%02d", elapsedHours,
                       elapsedMinutes, elapsedSeconds);
           } else {
               return String.format("%02d:%02d", elapsedMinutes,
                       elapsedSeconds);
           }
       }
    }
    }
    </actionevent>

    Here is the code for the EmbeddedMediaPlayer.java file. Only modifications are the file to be played and the size of the window.

    package embeddedmediaplayer;

    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.media.MediaView;
    import javafx.scene.Scene;
    import javafx.stage.Stage;

    public class EmbeddedMediaPlayer extends Application {

    //    private static final String MEDIA_URL =
    //            "http://download.oracle.com/otndocs/products/javafx/oow2010-  2.flv";

    private static final String MEDIA_URL =
           "file:./media/CellCellCell.mp4";

    @Override
    public void start(Stage primaryStage) {
       primaryStage.setTitle("Embedded Media Player");
       Group root = new Group();
       Scene scene = new Scene(root, 512, 512);

       // create media player
       Media media = new Media (MEDIA_URL);
       MediaPlayer mediaPlayer = new MediaPlayer(media);
       mediaPlayer.setAutoPlay(true);
       MediaControl mediaControl = new MediaControl(mediaPlayer);
       scene.setRoot(mediaControl);

       primaryStage.setScene(scene);
       primaryStage.show();
    }


    public static void main(String[] args) {
       launch(args);
    }
    }
  • WebRTC Stream Freezes When Picture Complexity Increases

    12 octobre 2021, par user1259576

    I am developing an application that uses WebRTC to display a live video stream being captured from a V4L2 source. The stream originates from a Linux box that has a DVI-USB capture card, is encoded to H264 by ffmpeg and sent to RTP, received by a Janus WebRTC server which is accessed by the web interface.

    &#xA;

    Here is my current ffmpeg command - pretty simple :&#xA;ffmpeg -f v4l2 -i /dev/video0 -vf "transpose=1,scale=768:1024" -vcodec libx264 -profile:v baseline -pix_fmt yuv420p -f rtp rtp ://10.116.80.86:8004

    &#xA;

    I can't go into details, but the DVI source generates a portrait 768x1024 image that initially is a simple image where the only movement is a small clock near the center that increments every second. At this stage, everything appears to work great. The image is high-quality and continuous/smooth in the browser.

    &#xA;

    Once I interact with the DVI source, a more complex image is generated, with some text/lines in the upper half. Still not very complex - only 2 colors involved and some basic 1px line shapes, and only the little clock is moving. At this point, the video starts to freeze frequently, and only updates once in a while for a few seconds. Bandwidth should not be an issue here, and the bitrate appears to stay high. However, many fewer frames are decoded.

    &#xA;

    I have also tried scaling the video down to 480x640 from 768x1024 and with that change the issue does not occur. However, I really need the full resolution and, again, there should not be a bandwidth issue here.

    &#xA;

    I have also tried capturing the output of ffmpeg to a file rather than streaming to RTP and in the file everything is good.

    &#xA;

    Here is a screenshot of the WebRTC internals (in Edge) for this stream. You can clearly see when the video image changes from the simple clock to including more shapes & text (nothing is changed here other than the image from the DVI source) :

    &#xA;

    WebRTC internals plots

    &#xA;

    In Firefox, the video just freezes whenever frames are not decoded. In Edge, the video goes black after a moment with no frames decoded.

    &#xA;

    Any ideas as to what might be causing this ?

    &#xA;

  • How to make a batch file wait for all processes of another call to finish before continuing

    1er juillet 2020, par Roman Stadler

    The idea of this script is to take a (lecture) video, split it into smaller pieces, remove the silence for each one, and merge them back together, for increased performance, since the silence-removing script does not scale that well for larger videos.

    &#xA;

    The 3 batch scripts below work perfectly when started manually after eachother, but when trying to launch them from a single .bat file, I can't prevent them from starting at the same time, which creates errors at the merging stage.

    &#xA;

    These are the 3 batch files :

    &#xA;

      &#xA;
    1. split.bat
    2. &#xA;

    3. startall.bat
    4. &#xA;

    5. merge.bat
    6. &#xA;

    &#xA;

    Split.bat creates 10 minute long segments, afterwards, startall.bat starts one Video-Remove-Silence task for every segment. At the end, merge.bat creates one single mp4 file with all the segments.

    &#xA;

    split.bat does the following :

    &#xA;

    ffmpeg -i in.mp4 -c copy -map 0 -segment_time 00:10:00 -f segment out%%03d.mp4&#xA;exit&#xA;

    &#xA;

    startall.bat :

    &#xA;

    start start000.bat&#xA;start start001.bat&#xA;start start002.bat&#xA;start start003.bat&#xA;...&#xA;

    &#xA;

    The start000.bat call looks like this :

    &#xA;

    python video-remove-silence out000.mp4 --linear 0.0005&#xA;exit&#xA;

    &#xA;

    And merge.bat :

    &#xA;

    :: Create File List&#xA;for %%i in (*_result.mp4) do echo file &#x27;%%i&#x27;>> mylist.txt&#xA;:: Concatenate Files&#xA;ffmpeg -f concat -safe 0 -i mylist.txt -c copy shortened.mp4&#xA;&#xA;del "C:\Users\Roman\Desktop\download\mylist.txt"&#xA;del "C:\Users\Roman\Desktop\download\out*.mp4"&#xA;exit&#xA;

    &#xA;

    When trying either call, or start /wait, errors occur due to simultaneous execution :

    &#xA;

    START /wait split.bat&#xA;START /wait startall2.bat&#xA;START /wait merge.bat&#xA;

    &#xA;

    So basically my question is, how can I call these 3 scripts and prevent merge.bat from starting, until all processes inside startall.bat have finished ?

    &#xA;