Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (13)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

Sur d’autres sites (4031)

  • Low latency video player on android

    20 mai 2021, par Louis Blenner

    I'd like to be able to stream the video from my webcam to an Android app with a latency below 500ms, on my local network.

    


    To capture and send the video over the network, I use ffmpeg.

    


    ffmpeg -f v4l2 -i /dev/video0 -preset ultrafast -tune zerolatency -vcodec libx264 -an -vf format=yuv420p -f mpegts  udp://192.168.1.155:5000


    


    This command takes the webcam as an input, convert it and send it to a device using the mpegts protocol.
    
This is not a requirement, if another technique could work, I could change the way I send the video.

    


    I am able to read the video on another PC from the local network with a latency below 500 ms, using commands like

    


    gst-launch-1.0 -v udpsrc port=5000 ! video/mpegts ! tsdemux ! h264parse ! avdec_h264 ! fpsdisplaysink sync=false


    


    or

    


    mpv udp://0.0.0.0:5000 --no-cache --untimed --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 


    


    So it is possible to have this range of latency.
    
I'd like to have the same thing on Android.

    


    Here are my tries to do that.

    


    Exoplayer

    


    After looking at the different players available on Android studio, it seems like Exoplayer is the go-to choice.
    
I tried different options indicated in the live-streaming documentation, but I always end up with a stream taking seconds to start and with a latency of seconds.
    
I tried to add a Button to seek to the default position of the windows, but it results in a loading of several seconds.

    


    DefaultExtractorsFactory extractorsFactory =
                new DefaultExtractorsFactory()
                        .setTsExtractorFlags(DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM);

        player = new SimpleExoPlayer.Builder(this)
                .setMediaSourceFactory(
                        new DefaultMediaSourceFactory(this, extractorsFactory))
                .setLoadControl(new DefaultLoadControl.Builder()
                        .setBufferDurationsMs(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS, DefaultLoadControl.DEFAULT_MAX_BUFFER_MS, 200, 200)
                        .build())
                .build();
        MyPlayerView playerView = findViewById(R.id.player_view);
        // Bind the player to the view.
        playerView.setPlayer(player);
        // Build the media item.
        MediaItem mediaItem = new MediaItem.Builder()
                .setUri(Uri.parse("udp://0.0.0.0:5000"))
                .setLiveMaxOffsetMs(500)
                .setLiveTargetOffsetMs(0)
                .setLiveMinOffsetMs(0)
                .build();
        // Set the media item to be played.
        player.setMediaItem(mediaItem);
        // Prepare the player.
        player.setPlayWhenReady(true);
        player.prepare();
        //player.seekToDefaultPosition();


    


    This issue is about the same issue and the conclusion was that Exoplayer was not fit for this use case.

    


    


    I'll be honest, ultra low-latency like this isn't ExoPlayer's main use-case

    


    


    Vlc

    


    Another try was to use the Vlc library.
    
But I was unable to have the same low latency stream as with the two previous players with Vlc.
    
I tried changing the preferences of Vlc to stream as fast as possible as described here

    


    Input/Codecs -> x264 preset: ultrafast - zerolatency
Input/Codecs -> Access Module: UDP input
Input/Codecs -> Clock Jitter: 500
Audio: disable audio


    


    I also tried reducing the different buffers.
    
However, I still have a latency of more than 1 seconds with that.

    


    Gstreamer

    


    Another try was to create a react-native project to use the different players available here.
    
One player that seemed promising was react-native-gstreamer because it uses gstreamer which is able to stream with low latency (gst-launch command).
    
But the library is now outdated.

    


    Question

    


    There were other tries, but none were successful.
    
Is there a problem with one of my approaches ?
    
And if not, Is there a player on Android (that I missed) which is able to achieve low latency stream like gstream or mpv on linux ?

    


  • Python subprocess. Linux vs Windows

    23 mai 2021, par Chris

    I wonder if someone can help explain what is happening ?

    


    I run 2 subprocesses, 1 for ffprobe and 1 for ffmpeg.

    


    popen = subprocess.Popen(ffprobecmd, stderr=subprocess.PIPE, shell=True)


    


    And

    


    popen = subprocess.Popen(ffmpegcmd, shell=True, stdout=subprocess.PIPE)


    


    On both Windows and Linux the ffprobe command fires, finishes and gets removed from taskmanager/htop. But only on Windows does the same happen to ffmpeg. On Linux the command remains in htop...

    


    enter image description here

    


    Can anyone explain what is going on, if it matters and how I can stop it from happening please ?

    


    EDIT : Here are the commands...

    


    ffprobecmd = 'ffprobe' + \
' -user_agent "' + request.headers['User-Agent'] + '"' + \
' -headers "Referer: ' + request.headers['Referer'] + '"' + \
' -timeout "5000000"' + \
' -v error -select_streams v -show_entries stream=height -of default=nw=1:nk=1' + \
' -i "' + request.url + '"'


    


    and

    


    ffmpegcmd = 'ffmpeg' + \
' -re' + \
' -user_agent "' + r.headers['User-Agent'] + '"' + \
' -headers "Referer: ' + r.headers['Referer'] + '"' + \
' -timeout "10"' + \
' -i "' + r.url + '"' + \
' -c copy' + \
' -f mpegts' + \
' pipe:'


    


    EDIT : Here is a example that behaves as described...

    


    import flask
from flask import Response
import subprocess

app = flask.Flask(__name__)

@app.route('/', methods=['GET'])
def go():
    def stream(ffmpegcmd):
        popen = subprocess.Popen(ffmpegcmd, stdout=subprocess.PIPE, shell=True)
        try:
            for stdout_line in iter(popen.stdout.readline, ""):
                yield stdout_line
        except GeneratorExit:
            raise

    url = "https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8"

    ffmpegcmd = 'ffmpeg' + \
                ' -re' + \
                ' -timeout "10"' + \
                ' -i "' + url + '"' + \
                ' -c copy' + \
                ' -f mpegts' + \
                ' pipe:'
    return Response(stream(ffmpegcmd))

if __name__ == '__main__':
    app.run(host= '0.0.0.0', port=5000)


    


  • Low latency video streaming on android

    17 mai 2021, par Louis Blenner

    I'd like to be able to stream the video from my webcam to an Android app with a latency below 500ms, on my local network.

    


    To capture and send the video over the network, I use ffmpeg.

    


    ffmpeg -f v4l2 -i /dev/video0 -preset ultrafast -tune zerolatency -vcodec libx264 -an -vf format=yuv420p -f mpegts  udp://192.168.1.155:5000


    


    This command takes the webcam as an input, convert it and send it to a device using the mpegts protocol.

    


    I am able to read the video on another PC with a latency below 500 ms, using commands like

    


    gst-launch-1.0 -v udpsrc port=5000 ! video/mpegts ! tsdemux ! h264parse ! avdec_h264 ! fpsdisplaysink sync=false


    


    or

    


    mpv udp://0.0.0.0:5000 --no-cache --untimed --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 


    


    So it is possible to have this range of latency.
    
I'd like to have the same thing on Android.

    


    Here are my tries to do that.

    


    Exoplayer

    


    After looking at the different players available on Android studio, it seems like Exoplayer is the go-to choice.
    
I tried different options indicated in the live-streaming documentation, but I always end up with a stream taking seconds to start and with a latency of seconds.
    
I tried to add a Button to seek to the default position of the windows, but it results in a loading of several seconds.

    


    DefaultExtractorsFactory extractorsFactory =
                new DefaultExtractorsFactory()
                        .setTsExtractorFlags(DefaultTsPayloadReaderFactory.FLAG_IGNORE_AAC_STREAM);

        player = new SimpleExoPlayer.Builder(this)
                .setMediaSourceFactory(
                        new DefaultMediaSourceFactory(this, extractorsFactory))
                .setLoadControl(new DefaultLoadControl.Builder()
                        .setBufferDurationsMs(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS, DefaultLoadControl.DEFAULT_MAX_BUFFER_MS, 200, 200)
                        .build())
                .build();
        MyPlayerView playerView = findViewById(R.id.player_view);
        // Bind the player to the view.
        playerView.setPlayer(player);
        // Build the media item.
        MediaItem mediaItem = new MediaItem.Builder()
                .setUri(Uri.parse("udp://0.0.0.0:5000"))
                .setLiveMaxOffsetMs(500)
                .setLiveTargetOffsetMs(0)
                .setLiveMinOffsetMs(0)
                .build();
        // Set the media item to be played.
        player.setMediaItem(mediaItem);
        // Prepare the player.
        player.setPlayWhenReady(true);
        player.prepare();
        //player.seekToDefaultPosition();


    


    This issue is about the same issue and the conclusion was that Exoplayer was not fit for this use case.

    


    


    I'll be honest, ultra low-latency like this isn't ExoPlayer's main use-case

    


    


    Vlc

    


    Another try was to use the Vlc library.
    
But I was unable to have the same low latency stream as with the two previous example with Vlc.
    
I tried changing the preferences of Vlc to stream as fast as possible.

    


    Input/Codecs -> x264 preset: ultrafast - zerolatency
Input/Codecs -> Access Module: UDP input
Input/Codecs -> Clock Jitter: 500
Audio: disable audio


    


    I also tried reducing the different buffers.
    
However, I still have a latency of more than 1 seconds with that.

    


    Gstreamer

    


    Another try was to create a react-native project to use the different players available here.
    
One player that seemed promising was react-native-gstreamer because it uses gstreamer which is able to stream with low latency (gst-launch command).
    
But the library is now outdated.

    


    Question

    


    There were other tries, but none were successful.
    
Is there a problem with one of my approaches ?
    
And if not, Is there a player on Android (that I missed) which is able to achieve low latency stream like gstream or mpv on linux ?