Recherche avancée

Médias (1)

Mot : - Tags -/biographie

Autres articles (57)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

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

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (4384)

  • Minimal sample of muxing two streams with no reencoding (av_interleaved_write_frame fails)

    19 juillet 2022, par Alvein

    What I'm trying to do : having two files, one is video-only and the other is audio-only, with identical durations, I want to "join" them in a single container.

    


    I previously made a routine which just copied all the streams inside a container to another one. No reencoding, etc. This works perfectly :

    


    while(true) {
    pkIn=av_packet_alloc();
    if(NULL==pkIn) {
        fprintf(stderr,"av_packet_alloc() failed");
        break;
    }
    iError=av_read_frame(fcIn,pkIn);
    if(0>iError)
        if(AVERROR_EOF==iError)
            break;
        else {
            fprintf(stderr,"av_read_frame() failed");
            break;
        }
    stIn=fcIn->streams[pkIn->stream_index];
    stOut=fcOut->streams[pkIn->stream_index];
    log_packet(fcIn,pkIn,"in");
    av_packet_rescale_ts(pkIn,stIn->time_base,stOut->time_base);
    pkIn->pos=-1;
    log_packet(fcOut,pkIn,"out");
    iError=av_interleaved_write_frame(fcOut,pkIn);
    if(0>iError) {
        fprintf(stderr,"av_interleaved_write_frame() failed");
        break;
    }
    av_packet_free(&pkIn);
}


    


    I just did the analogy and tried to do the same, but taking each stream from a distinct container, like this :

    


    while(true) {
    if(!bVideoInEOF) {
        pkVideoIn=av_packet_alloc();
        if(NULL==pkVideoIn) {
            fprintf(stderr,"av_packet_alloc(video in) failed");
            break;
        }
        iError=av_read_frame(fcVideoIn,pkVideoIn);
        if(0>iError)
            if(AVERROR_EOF==iError)
                bVideoInEOF=true;
            else {
                fprintf(stderr,"av_read_frame(video in) failed");
                break;
            }
        if(!bVideoInEOF) {
            log_packet(fcVideoIn,pkVideoIn,"video in");
            av_packet_rescale_ts(pkVideoIn,stVideoIn->time_base,stVideoOut->time_base);
            pkVideoIn->pos=-1;
            pkVideoIn->stream_index=stVideoOut->index; // Edit (2022-07-19)
            log_packet(fcVideoIn,pkVideoIn,"video out");
            iError=av_interleaved_write_frame(fcOut,pkVideoIn);
            if(0>iError) {
                fprintf(stderr,"av_interleaved_write_frame(video out) failed");
                break;
            }
        }
        av_packet_free(&pkVideoIn);
    }
    if(!bAudioInEOF) {
        pkAudioIn=av_packet_alloc();
        if(NULL==pkAudioIn) {
            fprintf(stderr,"av_packet_alloc(audio in) failed");
            break;
        }
        iError=av_read_frame(fcAudioIn,pkAudioIn);
        if(0>iError)
            if(AVERROR_EOF==iError)
                bAudioInEOF=true;
            else {
                fprintf(stderr,"av_read_frame(audio in) failed");
                break;
            }
        if(!bAudioInEOF) {
            log_packet(fcAudioIn,pkAudioIn,"audio in");
            av_packet_rescale_ts(pkAudioIn,stAudioIn->time_base,stAudioOut->time_base);
            pkAudioIn->pos=-1;
            pkAudioIn->stream_index=stAudioOut->index; // Edit (2022-07-19)
            log_packet(fcAudioIn,pkAudioIn,"audio out");
            iError=av_interleaved_write_frame(fcOut,pkAudioIn);
            if(0>iError) {
                fprintf(stderr,"av_interleaved_write_frame(audio out) failed");
                break;
            }
        }
        av_packet_free(&pkAudioIn);
    }
    if(bVideoInEOF&&bAudioInEOF)
        break;
}


    


    I know the previous code looks like redundant but I wanted to leave both streams "processing" separated the way you understand my plans.

    


    Anyway, that code ends quickly with "av_interleaved_write_frame(audio out) failed".

    


    The error detail is "Invalid argument", and the debugger shows this :

    


    


    Application provided invalid, non monotonically increasing dts to
muxer in stream 0.

    


    


    If I disable any of the main blocks "if(!bVideoInEOF)" / "if(!bAudioInEOF)", the file is written successfully, with the obvious lack of the disabled stream.

    


    I'm new into using this library so probably I'm doing something really stupid, or missing something obvious.

    


    Suggestions ?

    


    Edit (2022-07-19) :

    


    By checking the logs, I noticed I was writing every frame to the stream #0. Hence, the horrible jumps in PTS/DTS.

    


    Code edited by adding the corresponding "...->stream_index=" before each call to av_interleaved_write_frame().

    


    ...

    


    Though it works, I still think my code is far from perfect. Comments are welcome.

    


  • how to get precise video bit rate in a .ts file ?

    26 juillet 2022, par Wang Yilan

    I often use ffprobe to get video bitrates and audio bitrates, but when I used ffprobe to get video bitrate of a .ts file, it seemed get wrong answers :

    


    > ffprobe ts-5s/abs-Life_of_PI-01-05s-0.95-1.5-0.15.ts
ffprobe version N-107320-g3354f8695c Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --enable-version3 --enable-libvmaf --enable-libx264 --enable-libx265 --enable-libvpx --enable-x86asm --enable-shared --disable-static --enable-gpl --enable-postproc --enable-hardcoded-tables --enable-pthreads --enable-pic --enable-zlib --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-lcjson
  libavutil      57. 27.100 / 57. 27.100
  libavcodec     59. 36.100 / 59. 36.100
  libavformat    59. 26.100 / 59. 26.100
  libavdevice    59.  6.100 / 59.  6.100
  libavfilter     8. 41.100 /  8. 41.100
  libswscale      6.  6.100 /  6.  6.100
  libswresample   4.  6.100 /  4.  6.100
  libpostproc    56.  5.100 / 56.  5.100
Input #0, mpegts, from 'ts-5s/abs-Life_of_PI-01-05s-0.95-1.5-0.15.ts':
  Duration: 00:00:05.02, start: 1.472511, bitrate: 1423 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x688, 23.98 fps, 23.98 tbr, 90k tbn
  Stream #0:1[0x101](und): Audio: mp2 ([3][0][0][0] / 0x0003), 44100 Hz, stereo, fltp, 384 kb/s


    


    it seemed that the bitrate is 1423k,but when I used bitrate viewer to get this result, it is 952k :
enter image description here

    


    And 1423k-384k=1039k, it cannot match the result of bitrate-viewer, neither.

    


    So my question are :

    


      

    1. what result is the correct result of this .ts file ?
    2. 


    3. Can I get this result in batches ? (using terminal commands or others)
    4. 


    


    many thanks.

    


  • FFMPEG HTTP Stream error, failed : Connection refused

    17 juillet 2022, par Halo Gass

    I tried to stream a video frame from opencv to network using MPEG-Dash, HLS, or RTSP via FFMPEG, but everytime I tried everything, it always throw "Connection Error, Connection Refused" even streaming to 127.0.0.1.

    


    Here the code for testing :

    


    import subprocess
import cv2
rtmp_url = "rtmp://127.0.0.1:1935/stream/pupils_trace"

# webcamera is 0, also you can set a video file name instead, for example "/home/user/demo.mp4"
path = 0
cap = cv2.VideoCapture(path)

# gather video info to ffmpeg
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

# command and params for ffmpeg
command = ['ffmpeg',
           '-y',
           '-f', 'rawvideo',
           '-vcodec', 'rawvideo',
           '-pix_fmt', 'bgr24',
           '-s', "{}x{}".format(width, height),
           '-r', str(fps),
           '-i', '-',
           '-c:v', 'libx264',
           '-pix_fmt', 'yuv420p',
           '-preset', 'ultrafast',
           '-f', 'flv',
           rtmp_url]

# using subprocess and pipe to fetch frame data
p = subprocess.Popen(command, stdin=subprocess.PIPE)


while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        print("frame read failed")
        break

    # YOUR CODE FOR PROCESSING FRAME HERE

    # write to pipe
    p.stdin.write(frame.tobytes())


    


    and below is the log :

    


    ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)&#xA;  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;Input #0, rawvideo, from &#x27;pipe:&#x27;:&#xA;  Duration: N/A, start: 0.000000, bitrate: 221184 kb/s&#xA;    Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 1280x720, 221184 kb/s, 10 tbr, 10 tbn, 10 tbc&#xA;[tcp @ 0x556bea198680] Connection to tcp://127.0.0.1:1935 failed: Connection refused&#xA;[rtmp @ 0x556bea1a2640] Cannot open connection tcp://127.0.0.1:1935&#xA;rtmp://127.0.0.1:1935/stream/pupils_trace: Connection refused&#xA;Traceback (most recent call last):&#xA;  File "testing.py", line 42, in <module>&#xA;    p.stdin.write(frame.tobytes())&#xA;</module>

    &#xA;

    Here what I tried (All of it always "Connection Refused")

    &#xA;

      &#xA;
    1. Running the code directly
    2. &#xA;

    3. Running the code using sudo
    4. &#xA;

    5. Run with 'sudo su'
    6. &#xA;

    7. Allow the port used in ufw
    8. &#xA;

    9. Disable ufw
    10. &#xA;

    11. I tried executing command directly in terminal, also throws "connection refused"
    12. &#xA;

    13. using 127.0.0.1 or "localhost" or 0.0.0.0 or my local IP, everything throws connection error
    14. &#xA;

    15. Tried UDP and TCP
    16. &#xA;

    &#xA;

    Anyone can help me ?&#xA;Thanks

    &#xA;