Recherche avancée

Médias (91)

Autres articles (77)

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

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

  • Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur

    8 février 2011, par

    La visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
    Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
    Configuration de la boite multimédia
    Dès (...)

Sur d’autres sites (5356)

  • Unable to Play Video Stream on Flask-FFmpeg Media Server on Subsequent Requests

    12 juin 2024, par yternal

    Problem Description :

    


    I am trying to create a media server using Flask and FFmpeg. The server converts an RTSP stream to FLV format for playback in a web browser, and I am testing it using ffplay. The server starts successfully, and the data returned from the first request can be played using ffplay. However, when I interrupt the ffplay request and make it again, ffplay is unable to play the video and displays an "Invalid data found when processing input" error.

    


    I am using the following command to test with ffplay :

    


    ffplay http://127.0.0.1:8000/flv/0


    


    My current Flask code:

    


    import queue
import subprocess
import threading

from flask import Flask, Response, stream_with_context
from gevent import monkey
from gevent.pool import Pool
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from loguru import logger

monkey.patch_all()
app = Flask(__name__)

stream_queue = queue.Queue(maxsize=10000)


def update_stream():
    process = subprocess.Popen(
        ['ffmpeg', '-i', 'rtsp://192.168.1.168/0', '-f', 'flv', '-'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE
    )
    while True:
        data = process.stdout.read(4096)
        if not data:
            break
        if stream_queue.full():
            stream_queue.get()
        stream_queue.put(data)
        logger.debug(f"stream_queue size: {stream_queue.qsize()}")


@app.route('/flv/')
def flv_stream(stream_id):
    @stream_with_context
    def generate():

        while True:
            data = stream_queue.get()
            yield data

    return Response(generate(), mimetype='video/x-flv')


if __name__ == '__main__':
    HOST = "0.0.0.0"
    PORT = 8000

    threading.Thread(target=update_stream, daemon=True).start()

    logger.info(f"listen in: {HOST}:{PORT}")
    pool = Pool(10000)
    http_serve = WSGIServer((HOST, PORT), app, handler_class=WebSocketHandler, spawn=pool)
    http_serve.max_accept = 30000
    http_serve.serve_forever()


    


    The error message when attempting to play the stream again with ffplay is :

    


    http://127.0.0.1:8000/flv/0: Invalid data found when processing input


    


    I tried adding some parameters to FFmpeg, such as analyzeduration and probesize, but it had no effect.

    


  • I could not encode using the Intel® Media Server Studio on the ZOTAC ZBOX PI225

    22 avril 2018, par Ubunkun

    I’ve succeeded to install the Intel® Media Server Studio to the
    ZOTAC ZBOX PI225. And, I’ve built the ffmepg as following.

    $ ffmpeg -codecs | grep qsv
    ffmpeg version N-90764-g396c019 Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
     configuration: --enable-libmfx
     libavutil      56. 15.100 / 56. 15.100
     libavcodec     58. 19.100 / 58. 19.100
     libavformat    58. 13.100 / 58. 13.100
     libavdevice    58.  4.100 / 58.  4.100
     libavfilter     7. 18.100 /  7. 18.100
     libswscale      5.  2.100 /  5.  2.100
     libswresample   3.  2.100 /  3.  2.100
    DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv ) (encoders: h264_qsv h264_vaapi )
    DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv ) (encoders: hevc_qsv hevc_vaapi )
    DEVIL. mjpeg                Motion JPEG (encoders: mjpeg mjpeg_qsv mjpeg_vaapi )
    DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv ) (encoders: mpeg2video mpeg2_qsv mpeg2_vaapi )
    D.V.L. vc1                  SMPTE VC-1 (decoders: vc1 vc1_qsv )
    DEV.L. vp8                  On2 VP8 (decoders: vp8 vp8_qsv ) (encoders: vp8_vaapi )

    When I’ve tried to encode using ffmpeg, but It occurred error as below.

    $ ffmpeg -i original.avi -c:v h264_qsv -profile:v main -b:v 2000k -r 30 -s 1280x720  -look_ahead 0 qsv.mp4
    ffmpeg version N-90764-g396c019 Copyright (c) 2000-2018 the FFmpeg developers
     built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
     configuration: --enable-libmfx
     libavutil      56. 15.100 / 56. 15.100
     libavcodec     58. 19.100 / 58. 19.100
     libavformat    58. 13.100 / 58. 13.100
     libavdevice    58.  4.100 / 58.  4.100
     libavfilter     7. 18.100 /  7. 18.100
     libswscale      5.  2.100 /  5.  2.100
     libswresample   3.  2.100 /  3.  2.100
    Input #0, avi, from 'original.avi':
     Metadata:
       encoder         : FairUse Wizard - http://fairusewizard.com
     Duration: 01:41:12.11, start: 0.000000, bitrate: 965 kb/s
       Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 592x304 [SAR 1:1 DAR 37:19], 828 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
       Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 128 kb/s
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_qsv))
     Stream #0:1 -> #0:1 (mp3 (mp3float) -> aac (native))
    Press [q] to stop, [?] for help
    [mpeg4 @ 0x2fe5700] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it.
    [h264_qsv @ 0x2fce7c0] Encoder will work with partial HW acceleration
    [h264_qsv @ 0x2fce7c0] Error initializing the encoder: invalid video parameters (-15)
    Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    [aac @ 0x2ff0e00] Qavg: 14764.986
    [aac @ 0x2ff0e00] 2 frames left in the queue on closing
    Conversion failed!

    It seems like that something of parameter missing, I think.

    If you have an idea to solve this, let me know.

    Bests,

  • Record video with Media Recorder in WEBM format

    21 mai 2017, par Matho

    I need to record two videos via media recorder and process them with ffmpeg in Android. I want to read videos via pipe in ffmpeg command string. From what I have read, I could not use 3GPP/MP4 format, because these formats contains header at the end of video. Because of it, I want to use WEBM video format, but my app is crashing, when I use webm/vp8 setting in media recorder. Ffmpeg I’m using is : com.writingminds:FFmpegAndroid:0.3.2. Could you help me please ?

    RecorderPrepareTask :

    class RecorderPrepareTask extends AsyncTask {
    private Context mContext;

    public RecorderPrepareTask(Context context) {
       mContext = context;
    }

    @Override
    protected Boolean doInBackground(Void... voids) {
       Timber.d("Starting screen recording...");

       if (!outputRoot.exists() && !outputRoot.mkdirs()) {
           Timber.e("Unable to create output directory '%s'.", outputRoot.getAbsolutePath());
           return false;
       }

       recorder = new MediaRecorder();
       recorder.setVideoSource(SURFACE);
       recorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
       recorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8);
       recorder.setVideoSize(Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H);
       recorder.setVideoFrameRate(Config.FRAME_RATE);

       Timber.i("Output file '%s'.", outputFileName);
       recorder.setOutputFile(RecordingActivity.pipe[1].getFileDescriptor());


       try {
           recorder.prepare();
       } catch (IOException e) {
           throw new RuntimeException("Unable to prepare MediaRecorder.", e);
       }


       projection = projectionManager.getMediaProjection(resultCode, data);

       Surface surface = recorder.getSurface();
       display = projection.createVirtualDisplay(DISPLAY_NAME, Config.VIDEO_SIZE_W, Config.VIDEO_SIZE_H, 560, VIRTUAL_DISPLAY_FLAG_PRESENTATION, surface, null, null);

       recorder.start();

       return true;
    }

    @Override
    protected void onPostExecute(Boolean result) {

    }

    }

    getConvertCmd :

    private String getConvertCmd(){
       return "-re -r 30 -f webm -c:v vp8 -i pipe:"+ RecordingActivity.pipe[0].getFd() + " -threads 2 -preset ultrafast -profile:v main -level 3.1 -b:v 440k -ar 44100 -ab 128k -s "+ Config.CAMERA_VIDEO_SIZE_W + "x" + Config.CAMERA_VIDEO_SIZE_H + " -vcodec vp8 -acodec vorbis " + outputFileName3;
    }

    Logs :

    D/SoftVPXEncoder: VP8: internalSetAndroidVp8Params. BRMode: 0. TS: 0. KF: 24. QP: 0 - 0 BR0: 100. BR1: 0. BR2: 0
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1a:google.vp8.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    W/ACodec: do not know color format 0x7f000789 = 2130708361
    I/SoftMPEG4Encoder: Construct SoftMPEG4Encoder
    I/MediaCodec: MediaCodec will operate in async mode
    E/OMXNodeInstance: getParameter(1b:google.mpeg4.encoder, ParamVideoErrorCorrection(0x6000007)) ERROR: NotImplemented(0x80001006)
    I/ACodec: setupVideoEncoder succeeded
    E/OMXNodeInstance: setConfig(1b:google.mpeg4.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    D/SoftVPXEncoder: VP8: initEncoder. BRMode: 0. TSLayers: 0. KF: 24. QP: 0 - 0
    I/AudioFlinger: AudioFlinger's thread 0xb2440000 ready to run
    xW/AudioFlinger: acquireAudioSessionId() unknown client 10079 for session 7
    I/MediaCodec: MediaCodec will operate in async mode
    /system_process I/DisplayManagerService: Display device added: DisplayDeviceInfo{"RMR": uniqueId="virtual:sk.matho.rocket_monkeys.rocketmonkeysrecorder,10052,RMR,0", 480 x 640, modeId 6, defaultModeId 6, supportedModes [{id=6, width=480, height=640, fps=60.0}], density 560, 560.0 x 560.0 dpi, appVsyncOff 0, presDeadline 16666666, touch NONE, rotation 0, type VIRTUAL, state ON, owner sk.matho.rocket_monkeys.rocketmonkeysrecorder (uid 10052), FLAG_PRIVATE, FLAG_PRESENTATION}
    E/OMXNodeInstance: setConfig(1c:google.amrnb.encoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
    I/ACodec: codec does not support config priority (err -2147483648)
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    E/WebmElement: mmap64 failed; errno = 22
    E/WebmElement: fd 18; flags: 1
    D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x10003 imply creation of host color buffer
    I/MediaCodecSource: MediaCodecSource (video) starting
    I/MediaCodecSource: MediaCodecSource (video) started
    D/MPEG4Writer: Video track stopping
    E/MPEG4Writer: Stop() called but track is not started
    D/MPEG4Writer: Audio track stopping
    E/MPEG4Writer: Stop() called but track is not started

    [ 05-21 13:03:44.101  9757: 9766 D/         ]
    HostConnection::get() New Host Connection established 0xb344f140, tid 9766
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/MediaRecorder: start failed: -2147483648                                                                                                  
    /sk.matho.rocket_monkeys.rocketmonkeysrecorder E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
    Process: sk.matho.rocket_monkeys.rocketmonkeysrecorder, PID: 10079
    java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:309)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)
    Caused by: java.lang.RuntimeException: start failed.
    at android.media.MediaRecorder.start(Native Method)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:181)
    at sk.matho.rocket_monkeys.rocketmonkeysrecorder.recording.CameraRecordingSession$MediaPrepareTask.doInBackground(CameraRecordingSession.java:173)
    at android.os.AsyncTask$2.call(AsyncTask.java:295)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
    at java.lang.Thread.run(Thread.java:818) 

    [ 05-21 13:03:44.109  9757:10315 D/         ]
    HostConnection::get() New Host Connection established 0xb307c1c0, tid 10315