Recherche avancée

Médias (91)

Autres articles (90)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

Sur d’autres sites (5435)

  • How to encode H.264 video using FFmpeg C API and then open the output with a media player ?

    4 avril 2016, par GummiB

    I’m trying to encode a H.264 video with the FFMPEG C API.
    I have successfully compiled and executed the decoding/encoding example provided by FFMPEG.

    The problem I’m facing is that the .mpg file (encoded with AV_CODEC_ID_MPEG1VIDEO) the example creates works. Windows creates a thumbnail and everything. On the other hand the .h264 (encoded with AV_CODEC_ID_H264) file does not. When I try to play the file in VLC the play/pause button just flickers, no thumbnail in windows, no nothing.

    During encoding libx264 reports the following :

    [libx264 @ 004b81a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 004b81a0] profile High, level 1.3
    [libx264 @ 004b81a0] frame I:3     Avg QP:26.79  size:  2116
    [libx264 @ 004b81a0] frame P:12    Avg QP:26.60  size:   789
    [libx264 @ 004b81a0] frame B:10    Avg QP:31.39  size:   499
    [libx264 @ 004b81a0] consecutive B-frames: 20.0% 80.0%
    [libx264 @ 004b81a0] mb I  I16..4: 78.3% 11.6% 10.1%
    [libx264 @ 004b81a0] mb P  I16..4: 77.4%  0.6%  0.1%  P16..4: 20.3%  0.7%  0.9%  0.0%  0.0%    skip: 0.0%
    [libx264 @ 004b81a0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  9.4%  0.2%  0.0%  direct:11.0%  skip:79.4%  L0:25.4% L1:35.4% BI:39.2%
    [libx264 @ 004b81a0] final ratefactor: 17.03
    [libx264 @ 004b81a0] 8x8 transform intra:3.4% inter:31.3%
    [libx264 @ 004b81a0] direct mvs  spatial:0.0% temporal:100.0%
    [libx264 @ 004b81a0] coded y,uvDC,uvAC intra: 4.4% 35.8% 1.6% inter: 1.3% 34.5% 9.5%
    [libx264 @ 004b81a0] i16 v,h,dc,p:  0%  0%  0% 100%
    [libx264 @ 004b81a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 20% 17% 49%  0%  0%  0%  1%  6%
    [libx264 @ 004b81a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14%  7% 18% 45%  2%  7%  2%  3%  2%
    [libx264 @ 004b81a0] i8c dc,h,v,p:  2%  6%  4% 88%
    [libx264 @ 004b81a0] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 004b81a0] ref P L0: 95.6%  1.6%  2.2%  0.5%  0.2%
    [libx264 @ 004b81a0] ref B L0: 67.5% 28.5%  3.2%  0.8%
    [libx264 @ 004b81a0] kb/s:166.45

    "ffprobe.exe test.h264 -show_streams" returns

    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=High
    codec_type=video
    codec_time_base=1/50
    codec_tag_string=[0][0][0][0]
    codec_tag=0x0000
    width=352
    height=288
    has_b_frames=1
    sample_aspect_ratio=0:1
    display_aspect_ratio=0:1
    pix_fmt=yuv420p
    level=13
    timecode=N/A
    id=N/A
    r_frame_rate=50/2
    avg_frame_rate=25/1
    time_base=1/1200000
    start_pts=N/A
    start_time=N/A
    duration_ts=N/A
    duration=N/A
    bit_rate=N/A
    nb_frames=N/A
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=0
    DISPOSITION:dub=0
    DISPOSITION:original=0
    DISPOSITION:comment=0
    DISPOSITION:lyrics=0
    DISPOSITION:karaoke=0
    DISPOSITION:forced=0
    DISPOSITION:hearing_impaired=0
    DISPOSITION:visual_impaired=0
    DISPOSITION:clean_effects=0
    DISPOSITION:attached_pic=0
    [/STREAM]

    There you can see :

    start_time=N/A
    duration_ts=N/A
    duration=N/A

    I have tried countless changes to the AVCodecContext and multitude of parameters options to av_opt_set function. Still no luck getting a working H.264 video. I have even tried different builds of FFmpeg. No luck.

    I’m using the "FFmpeg git-0fb64da 32-bit Dev" build from Zeranoe and MinGw 4.7.2

  • Is there a media server which just receives any rtsp streams and serves them ?

    7 mai 2015, par Given92

    I have some rtmp streams served over nginx-rtmp-module and the number of them will be changed dynamically.

    But for the limit of client, I have to serve them in rtsp protocol. Obviously, It’s not supported by nginx-rtmp-module. So I plan to run a rtsp server in the same device, and convert the rtmp stream into rtsp stream with ffmpeg, then send the rtsp stream to the rtsp server. So that client could play the stream from the rtsp server.

    The trouble is that I could not found a stable server which just receive any rtsp streams and serve them.

    There is an example that fits all my need but it’s a little unstable.

    I run it in verbose mode and send stream with :

    ffmpeg -i rtmp://localhost/<name> -codec copy -ar 44100 -ac 1 -f rtsp rtsp://localhost:5545/<name>
    </name></name>

    and play the stream with :

    gst-launch-0.10 playbin2 uri=rtsp://<server>/<name>
    </name></server>

    The video does not appear and there are some repeated warnning like this :

    WARNING: from element /GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstRtpVorbisDepay:rtpvorbisdepay0: Could not decode stream.
    Additional debug info:
    gstrtpvorbisdepay.c(633): gst_rtp_vorbis_depay_process (): /GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstRtpVorbisDepay:rtpvorbisdepay0:

    When I try :

    gst-launch-1.0 playbin uri=rtsp://<server>/<name>
    </name></server>

    it is stuck and no video appear :

    Setting pipeline to PAUSED ...
    Pipeline is live and does not need PREROLL ...
    Progress: (open) Opening Stream
    Progress: (connect) Connecting to rtsp://211.68.127.12/box
    Progress: (open) Retrieving server options
    Progress: (open) Retrieving media info
    Progress: (request) SETUP stream 0
    Progress: (request) SETUP stream 1
    Progress: (open) Opened Stream
    Setting pipeline to PLAYING ...
    New clock: GstSystemClock
    Progress: (request) Sending PLAY request
    Progress: (request) Sending PLAY request
    Progress: (request) Sent PLAY request

    When I play with :

    ffplay rtsp://<server>/<name>
    </name></server>

    The video appears but the quality depress me.

    Here is the output :

    ```ffplay version 2.6.2 Copyright (c) 2003-2015 the FFmpeg developers
     built with gcc 4.9.2 (GCC) 20150304 (prerelease)
     configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gnutls --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-runtime-cpudetect --enable-shared --enable-swresample --enable-vdpau --enable-version3 --enable-x11grab
     libavutil      54. 20.100 / 54. 20.100
     libavcodec     56. 26.100 / 56. 26.100
     libavformat    56. 25.101 / 56. 25.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 11.102 /  5. 11.102
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 2 times
    [h264 @ 0x7f97f4000cc0] ref 7 overflow
    [h264 @ 0x7f97f4000cc0] error while decoding MB 19 23
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 615 DC, 615 AC, 615 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 370 DC, 370 AC, 370 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] ref 4 overflow
    [h264 @ 0x7f97f4000cc0] error while decoding MB 37 23
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 597 DC, 597 AC, 597 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 3 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets  0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 473 DC, 473 AC, 473 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 564 DC, 564 AC, 564 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 605 DC, 605 AC, 605 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets  0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 17 packets0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] ref 4 overflow
    [h264 @ 0x7f97f4000cc0] error while decoding MB 27 20
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 742 DC, 742 AC, 742 MV errors in P frame
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 23 packets0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] out of range intra chroma pred mode at 9 4
    [h264 @ 0x7f97f4000cc0] error while decoding MB 9 4
    [h264 @ 0x7f97f4000cc0] concealing 1480 DC, 1480 AC, 1480 MV errors in I frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 7 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4000cc0] concealing 278 DC, 278 AC, 278 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets 0KB sq=    0B f=0/0  
       Last message repeated 2 times
    [mp3 @ 0x7f97f4009280] RTP: missed 2 packets  0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 1 times
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets 0KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 5 packets
    Input #0, rtsp, from 'rtsp://211.68.127.12/box':B sq=    0B f=0/0  
     Metadata:
       title           :
     Duration: N/A, start: 0.000033, bitrate: N/A
       Stream #0:0: Video: h264 (Baseline), yuv420p(tv), 720x576 [SAR 1:1 DAR 5:4], 24 fps, 24 tbr, 90k tbn, 48 tbc
       Stream #0:1: Audio: mp3, 44100 Hz, mono, s16p, 56 kb/s
    [h264 @ 0x7f97f4263d40] ref 7 overflow vq=  226KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] error while decoding MB 19 23
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 615 DC, 615 AC, 615 MV errors in P frame
    [h264 @ 0x7f97f4264580] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4264580] concealing 370 DC, 370 AC, 370 MV errors in P frame
    [h264 @ 0x7f97f41699a0] ref 4 overflow
    [h264 @ 0x7f97f41699a0] error while decoding MB 37 23
    [h264 @ 0x7f97f41699a0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f41699a0] concealing 597 DC, 597 AC, 597 MV errors in P frame
    [h264 @ 0x7f97f4264580] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4264580] concealing 473 DC, 473 AC, 473 MV errors in P frame
    [h264 @ 0x7f97f4264580] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4264580] concealing 564 DC, 564 AC, 564 MV errors in P frame
    [h264 @ 0x7f97f41699a0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f41699a0] concealing 605 DC, 605 AC, 605 MV errors in P frame
    [h264 @ 0x7f97f4264580] out of range intra chroma pred mode at 9 4  
    [h264 @ 0x7f97f4264580] error while decoding MB 9 4
    [h264 @ 0x7f97f4264580] concealing 1480 DC, 1480 AC, 1480 MV errors in I frame
    [h264 @ 0x7f97f416a200] ref 4 overflow
    [h264 @ 0x7f97f416a200] error while decoding MB 27 20
    [h264 @ 0x7f97f416a200] Cannot use next picture in error concealment
    [h264 @ 0x7f97f416a200] concealing 742 DC, 742 AC, 742 MV errors in P frame
    [h264 @ 0x7f97f416a200] Cannot use next picture in error concealment
    [h264 @ 0x7f97f416a200] concealing 278 DC, 278 AC, 278 MV errors in P frame
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets53KB sq=    0B f=0/0  
       Last message repeated 1 times
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets 60KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 10 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 2 times
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -4 -4
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -1 -1
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -1 -1
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 3 times
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -5 -5
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -4 -4
       Last message repeated 1 times
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -7 -7
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -5 -5
    [mp3 @ 0x7f97f4009280] overread, skip -10 enddists: -6 -6
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 2 times
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -7 -7
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -6 -6
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -3 -3
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f416a200] Cannot use next picture in error concealment
    [h264 @ 0x7f97f42630e0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f416a200] concealing 327 DC, 327 AC, 327 MV errors in P frame
    [h264 @ 0x7f97f42630e0] concealing 327 DC, 327 AC, 327 MV errors in P frame
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 325 DC, 325 AC, 325 MV errors in P frame
    [h264 @ 0x7f97f41699a0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f41699a0] concealing 371 DC, 371 AC, 371 MV errors in P frame
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -4 -4 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -2 -2
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -7 -7 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -2 -2
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets08KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets05KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] ref 3 overflow vq=  207KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] error while decoding MB 20 34
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 119 DC, 119 AC, 119 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 1 times
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -2 -2 0B f=0/0  
    [h264 @ 0x7f97f4263d40] out of range intra chroma pred mode at 37 23
    [h264 @ 0x7f97f4263d40] error while decoding MB 37 23
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 597 DC, 597 AC, 597 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -2 -2 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -3 -3
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -4 -4
    [h264 @ 0x7f97f4000cc0] RTP: missed 16 packets
    [h264 @ 0x7f97f41699a0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f41699a0] concealing 435 DC, 435 AC, 435 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 1 times
    [mp3 @ 0x7f97f4009280] RTP: missed 2 packets211KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -2 -2
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -2 -2
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -6 -6
    [h264 @ 0x7f97f42630e0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f42630e0] concealing 519 DC, 519 AC, 519 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 1 times
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets158KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 8 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets58KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets55KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets55KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets56KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets66KB sq=    0B f=0/0  
    [h264 @ 0x7f97f416a200] ref 11 overflowvq=  158KB sq=    0B f=0/0  
    [h264 @ 0x7f97f416a200] error while decoding MB 13 29
    [h264 @ 0x7f97f416a200] Cannot use next picture in error concealment
    [h264 @ 0x7f97f416a200] concealing 351 DC, 351 AC, 351 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets54KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets61KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 6 packets57KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -2 -2 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -8 enddists: -5 -5
    [h264 @ 0x7f97f416a200] out of range intra chroma pred mode at 34 8
    [h264 @ 0x7f97f416a200] error while decoding MB 34 8
    [h264 @ 0x7f97f416a200] concealing 1275 DC, 1275 AC, 1275 MV errors in I frame
    [h264 @ 0x7f97f4264580] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4264580] concealing 327 DC, 327 AC, 327 MV errors in P frame
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets152KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -5 -5 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -5 -5 0B f=0/0  
    [h264 @ 0x7f97f42630e0] P sub_mb_type 12 out of range at 9 26=0/0  
    [h264 @ 0x7f97f42630e0] error while decoding MB 9 26
    [h264 @ 0x7f97f42630e0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f42630e0] concealing 490 DC, 490 AC, 490 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 3 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 10 packets3KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets29KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets16KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets21KB sq=    0B f=0/0  
    [h264 @ 0x7f97f42630e0] Cannot use next picture in error concealment
    [h264 @ 0x7f97f42630e0] concealing 513 DC, 513 AC, 513 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets19KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets27KB sq=    0B f=0/0  
       Last message repeated 1 times
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets32KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 3 packets
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets135KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [mp3 @ 0x7f97f4009280] overread, skip -9 enddists: -2 -2
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -4 -4 0B f=0/0  
    [h264 @ 0x7f97f4264580] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4264580] concealing 230 DC, 230 AC, 230 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 4 packets21KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 3 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 2 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets05KB sq=    0B f=0/0  
       Last message repeated 3 times
    [h264 @ 0x7f97f4000cc0] RTP: missed 7 packets16KB sq=    0B f=0/0  
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets
    [h264 @ 0x7f97f4263d40] ref 13 overflowvq=  110KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] error while decoding MB 12 33
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 172 DC, 172 AC, 172 MV errors in P frame
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets12KB sq=    0B f=0/0  
       Last message repeated 2 times
    [h264 @ 0x7f97f416a200] Cannot use next picture in error concealment
    [h264 @ 0x7f97f416a200] concealing 414 DC, 414 AC, 414 MV errors in P frame
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets116KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
       Last message repeated 1 times
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets12KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4000cc0] RTP: missed 6 packets
    [h264 @ 0x7f97f4000cc0] RTP: missed 1 packets
    [mp3 @ 0x7f97f4009280] RTP: missed 1 packets126KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 327 DC, 327 AC, 327 MV errors in P frame
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -1 -1 0B f=0/0  
    [mp3 @ 0x7f97f4009280] overread, skip -5 enddists: -4 -4
    [mp3 @ 0x7f97f4009280] overread, skip -7 enddists: -6 -6
    ^C[h264 @ 0x7f97f4263d40] ref 7 overflowq=  107KB sq=    0B f=0/0  
    [h264 @ 0x7f97f4263d40] error while decoding MB 8 24
    [h264 @ 0x7f97f4263d40] Cannot use next picture in error concealment
    [h264 @ 0x7f97f4263d40] concealing 581 DC, 581 AC, 581 MV errors in P frame

    I’m not sure whether ffmpeg or rtsp-server is the problem, does anyone have some ideas ?

    Thanks very much.

  • Play video using mse (media source extension) in google chrome

    23 août 2019, par liyuqihxc

    I’m working on a project that convert rtsp stream (ffmpeg) and play it on the web page (signalr + mse).

    So far it works pretty much as I expected on the latest version of edge and firefox, but not chrome.

    here’s the code

    public class WebmMediaStreamContext
    {
       private Process _ffProcess;
       private readonly string _cmd;
       private byte[] _initSegment;
       private Task _readMediaStreamTask;
       private CancellationTokenSource _cancellationTokenSource;

       private const string _CmdTemplate = "-i {0} -c:v libvpx -tile-columns 4 -frame-parallel 1 -keyint_min 90 -g 90 -f webm -dash 1 pipe:";

       public static readonly byte[] ClusterStart = { 0x1F, 0x43, 0xB6, 0x75, 0x01, 0x00, 0x00, 0x00 };

       public event EventHandler<clusterreadyeventargs> ClusterReadyEvent;

       public WebmMediaStreamContext(string rtspFeed)
       {
           _cmd = string.Format(_CmdTemplate, rtspFeed);
       }

       public async Task StartConverting()
       {
           if (_ffProcess != null)
               throw new InvalidOperationException();

           _ffProcess = new Process();
           _ffProcess.StartInfo = new ProcessStartInfo
           {
               FileName = "ffmpeg/ffmpeg.exe",
               Arguments = _cmd,
               UseShellExecute = false,
               CreateNoWindow = true,
               RedirectStandardOutput = true
           };
           _ffProcess.Start();

           _initSegment = await ParseInitSegmentAndStartReadMediaStream();
       }

       public byte[] GetInitSegment()
       {
           return _initSegment;
       }

       // Find the first cluster, and everything before it is the InitSegment
       private async Task ParseInitSegmentAndStartReadMediaStream()
       {
           Memory<byte> buffer = new byte[10 * 1024];
           int length = 0;
           while (length != buffer.Length)
           {
               length += await _ffProcess.StandardOutput.BaseStream.ReadAsync(buffer.Slice(length));
               int cluster = buffer.Span.IndexOf(ClusterStart);
               if (cluster >= 0)
               {
                   _cancellationTokenSource = new CancellationTokenSource();
                   _readMediaStreamTask = new Task(() => ReadMediaStreamProc(buffer.Slice(cluster, length - cluster).ToArray(), _cancellationTokenSource.Token), _cancellationTokenSource.Token, TaskCreationOptions.LongRunning);
                   _readMediaStreamTask.Start();
                   return buffer.Slice(0, cluster).ToArray();
               }
           }

           throw new InvalidOperationException();
       }

       private void ReadMoreBytes(Span<byte> buffer)
       {
           int size = buffer.Length;
           while (size > 0)
           {
               int len = _ffProcess.StandardOutput.BaseStream.Read(buffer.Slice(buffer.Length - size));
               size -= len;
           }
       }

       // Parse every single cluster and fire ClusterReadyEvent
       private void ReadMediaStreamProc(byte[] bytesRead, CancellationToken cancel)
       {
           Span<byte> buffer = new byte[5 * 1024 * 1024];
           bytesRead.CopyTo(buffer);
           int bufferEmptyIndex = bytesRead.Length;

           do
           {
               if (bufferEmptyIndex &lt; ClusterStart.Length + 4)
               {
                   ReadMoreBytes(buffer.Slice(bufferEmptyIndex, 1024));
                   bufferEmptyIndex += 1024;
               }

               int clusterDataSize = BitConverter.ToInt32(
                   buffer.Slice(ClusterStart.Length, 4)
                   .ToArray()
                   .Reverse()
                   .ToArray()
               );
               int clusterSize = ClusterStart.Length + 4 + clusterDataSize;
               if (clusterSize > buffer.Length)
               {
                   byte[] newBuffer = new byte[clusterSize];
                   buffer.Slice(0, bufferEmptyIndex).CopyTo(newBuffer);
                   buffer = newBuffer;
               }

               if (bufferEmptyIndex &lt; clusterSize)
               {
                   ReadMoreBytes(buffer.Slice(bufferEmptyIndex, clusterSize - bufferEmptyIndex));
                   bufferEmptyIndex = clusterSize;
               }

               ClusterReadyEvent?.Invoke(this, new ClusterReadyEventArgs(buffer.Slice(0, bufferEmptyIndex).ToArray()));

               bufferEmptyIndex = 0;
           } while (!cancel.IsCancellationRequested);
       }
    }
    </byte></byte></byte></clusterreadyeventargs>

    I use ffmpeg to convert the rtsp stream to vp8 WEBM byte stream and parse it to "Init Segment" (ebml head、info、tracks...) and "Media Segment" (cluster), then send it to browser via signalR

    $(function () {

       var mediaSource = new MediaSource();
       var mimeCodec = 'video/webm; codecs="vp8"';

       var video = document.getElementById('video');

       mediaSource.addEventListener('sourceopen', callback, false);
       function callback(e) {
           var sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
           var queue = [];

           sourceBuffer.addEventListener('updateend', function () {
               if (queue.length === 0) {
                   return;
               }

               var base64 = queue[0];
               if (base64.length === 0) {
                   mediaSource.endOfStream();
                   queue.shift();
                   return;
               } else {
                   var buffer = new Uint8Array(atob(base64).split("").map(function (c) {
                       return c.charCodeAt(0);
                   }));
                   sourceBuffer.appendBuffer(buffer);
                   queue.shift();
               }
           }, false);

           var connection = new signalR.HubConnectionBuilder()
               .withUrl("/signalr-video")
               .configureLogging(signalR.LogLevel.Information)
               .build();
           connection.start().then(function () {
               connection.stream("InitVideoReceive")
                   .subscribe({
                       next: function(item) {
                           if (queue.length === 0 &amp;&amp; !!!sourceBuffer.updating) {
                               var buffer = new Uint8Array(atob(item).split("").map(function (c) {
                                   return c.charCodeAt(0);
                               }));
                               sourceBuffer.appendBuffer(buffer);
                               console.log(blockindex++ + " : " + buffer.byteLength);
                           } else {
                               queue.push(item);
                           }
                       },
                       complete: function () {
                           queue.push('');
                       },
                       error: function (err) {
                           console.error(err);
                       }
                   });
           });
       }
       video.src = window.URL.createObjectURL(mediaSource);
    })

    chrome just play the video for 3 5 seconds and then stop for buffering, even though there are plenty of cluster transfered and inserted into SourceBuffer.

    here’s the information in chrome ://media-internals/

    Player Properties :

    render_id: 217
    player_id: 1
    origin_url: http://localhost:52531/
    frame_url: http://localhost:52531/
    frame_title: Home Page
    url: blob:http://localhost:52531/dcb25d89-9830-40a5-ba88-33c13b5c03eb
    info: Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    pipeline_state: kSuspended
    found_video_stream: true
    video_codec_name: vp8
    video_dds: false
    video_decoder: FFmpegVideoDecoder
    duration: unknown
    height: 720
    width: 1280
    video_buffering_state: BUFFERING_HAVE_NOTHING
    for_suspended_start: false
    pipeline_buffering_state: BUFFERING_HAVE_NOTHING
    event: PAUSE

    Log

    Timestamp       Property            Value
    00:00:00 00     origin_url          http://localhost:52531/
    00:00:00 00     frame_url           http://localhost:52531/
    00:00:00 00     frame_title         Home Page
    00:00:00 00     url                 blob:http://localhost:52531/dcb25d89-9830-40a5-ba88-33c13b5c03eb
    00:00:00 00     info                ChunkDemuxer: buffering by DTS
    00:00:00 35     pipeline_state      kStarting
    00:00:15 213    found_video_stream  true
    00:00:15 213    video_codec_name    vp8
    00:00:15 216    video_dds           false
    00:00:15 216    video_decoder       FFmpegVideoDecoder
    00:00:15 216    info                Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    00:00:15 216    pipeline_state      kPlaying
    00:00:15 213    duration            unknown
    00:00:16 661    height              720
    00:00:16 661    width               1280
    00:00:16 665    video_buffering_state       BUFFERING_HAVE_ENOUGH
    00:00:16 665    for_suspended_start         false
    00:00:16 665    pipeline_buffering_state    BUFFERING_HAVE_ENOUGH
    00:00:16 667    pipeline_state      kSuspending
    00:00:16 670    pipeline_state      kSuspended
    00:00:52 759    info                Effective playback rate changed from 0 to 1
    00:00:52 759    event               PLAY
    00:00:52 759    pipeline_state      kResuming
    00:00:52 760    video_dds           false
    00:00:52 760    video_decoder       FFmpegVideoDecoder
    00:00:52 760    info                Selected FFmpegVideoDecoder for video decoding, config: codec: vp8 format: 1 profile: vp8 coded size: [1280,720] visible rect: [0,0,1280,720] natural size: [1280,720] has extra data? false encryption scheme: Unencrypted rotation: 0°
    00:00:52 760    pipeline_state      kPlaying
    00:00:52 793    height              720
    00:00:52 793    width               1280
    00:00:52 798    video_buffering_state       BUFFERING_HAVE_ENOUGH
    00:00:52 798    for_suspended_start         false
    00:00:52 798    pipeline_buffering_state    BUFFERING_HAVE_ENOUGH
    00:00:56 278    video_buffering_state       BUFFERING_HAVE_NOTHING
    00:00:56 295    for_suspended_start         false
    00:00:56 295    pipeline_buffering_state    BUFFERING_HAVE_NOTHING
    00:01:20 717    event               PAUSE
    00:01:33 538    event               PLAY
    00:01:35 94     event               PAUSE
    00:01:55 561    pipeline_state      kSuspending
    00:01:55 563    pipeline_state      kSuspended

    Can someone tell me what’s wrong with my code, or dose chrome require some magic configuration to work ?

    Thanks 

    Please excuse my english :)