Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (77)

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

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

  • How to convert H264 RTP stream from PCAP to a playable video file

    21 août 2014, par yoosha

    I have captured stream of H264 in PCAP files and trying to create media files from the data. The container is not important (avi,mp4,mkv,…).
    When I’m using videosnarf or rtpbreak (combined with python code that adds 00 00 00 01 before each packet) and then ffmpeg, the result is OK only if the input frame rate is constant (or near constant). However, when the input is vfr, the result plays too fast (and on same rare cases too slow).
    For example :

    videosnarf -i captured.pcap –c
    ffmpeg -i H264-media-1.264 output.avi

    After doing some investigation of the issue I believe now that since the videosnarf (and rtpbreak) are removing the RTP header from the packets, the timestamp is lost and ffmpeg is referring to the input data as cbr.

    1. I would like to know if there is a way to pass (on a separate file ?)
      the timestamps vector or any other information to ffmpeg so the
      result will be created correctly ?
    2. Is there any other way I can take the data out of the PCAP file and play it or convert it and then play it ?
    3. Since all work is done in Python, any suggestion of libraries/modules that can help with the work (even if requires some codding) is welcome as well.

    Note : All work is done offline, no limitations on the output. It can be cbr/vbr, any playable container and transcoding. The only "limitation" I have : it should all run on linux…

    Thanks
    Y

    Some additional information :
    Since the nothing provides the FFMPEG with the timestamp data, i decided to try a different approach : skip videosnarf and use Python code to pipe the packets directly to ffmpeg (using the "-f -i -" options) but then it refuses to accept it unless I provide an SDP file...
    How do I provide the SDP file ? is it an additional input file ? ("-i config.sdp")

    The following code is an unsuccessful try doing the above :

    import time  
    import sys  
    import shutil  
    import subprocess  
    import os  
    import dpkt  

    if len(sys.argv) < 2:  
       print "argument required!"  
       print "txpcap <pcap file="file">"  
       sys.exit(2)  
    pcap_full_path = sys.argv[1]  

    ffmp_cmd = ['ffmpeg','-loglevel','debug','-y','-i','109c.sdp','-f','rtp','-i','-','-na','-vcodec','copy','p.mp4']  

    ffmpeg_proc = subprocess.Popen(ffmp_cmd,stdout = subprocess.PIPE,stdin = subprocess.PIPE)  

    with open(pcap_full_path, "rb") as pcap_file:  
       pcapReader = dpkt.pcap.Reader(pcap_file)  
       for ts, data in pcapReader:  
           if len(data) &lt; 49:  
               continue  
           ffmpeg_proc.stdin.write(data[42:])

    sout, err = ffmpeg_proc.communicate()  
    print "stdout ---------------------------------------"  
    print sout  
    print "stderr ---------------------------------------"  
    print err  
    </pcap>

    In general this will pipe the packets from the PCAP file to the following command :

    ffmpeg -loglevel debug -y -i 109c.sdp -f rtp -i - -na -vcodec copy p.mp4

    SDP file : [RTP includes dynamic payload type # 109, H264]

    v=0
    o=- 0 0 IN IP4 ::1
    s=No Name
    c=IN IP4 ::1
    t=0 0
    a=tool:libavformat 53.32.100
    m=video 0 RTP/AVP 109
    a=rtpmap:109 H264/90000
    a=fmtp:109
    packetization-mode=1 ;profile-level-id=64000c ;sprop-parameter-sets=Z2QADKwkpAeCP6wEQAAAAwBAAAAFI8UKkg==,aMvMsiw= ;
    b=AS:200

    Results :

    ffmpeg version 0.10.2 Copyright (c) 2000-2012 the FFmpeg developers
    built on Mar 20 2012 04:34:50 with gcc 4.4.6 20110731 (Red Hat
    4.4.6-3) configuration : —prefix=/usr —libdir=/usr/lib64 —shlibdir=/usr/lib64 —mandir=/usr/share/man —enable-shared —enable-runtime-cpudetect —enable-gpl —enable-version3 —enable-postproc —enable-avfilter —enable-pthreads —enable-x11grab —enable-vdpau —disable-avisynth —enable-frei0r —enable-libopencv —enable-libdc1394 —enable-libdirac —enable-libgsm —enable-libmp3lame —enable-libnut —enable-libopencore-amrnb —enable-libopencore-amrwb —enable-libopenjpeg —enable-librtmp —enable-libschroedinger —enable-libspeex —enable-libtheora —enable-libvorbis —enable-libvpx —enable-libx264 —enable-libxavs —enable-libxvid —extra-cflags=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector —param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC’ —disable-stripping libavutil 51. 35.100 / 51. 35.100 libavcodec 53. 61.100 / 53. 61.100 libavformat 53. 32.100
    / 53. 32.100 libavdevice 53. 4.100 / 53. 4.100
    libavfilter 2. 61.100 / 2. 61.100 libswscale 2. 1.100
    / 2. 1.100 libswresample 0. 6.100 / 0. 6.100
    libpostproc 52. 0.100 / 52. 0.100 [sdp @ 0x15c0c00] Format sdp
    probed with size=2048 and score=50 [sdp @ 0x15c0c00] video codec set
    to : h264 [NULL @ 0x15c7240] RTP Packetization Mode : 1 [NULL @
    0x15c7240] RTP Profile IDC : 64 Profile IOP : 0 Level : c [NULL @
    0x15c7240] Extradata set to 0x15c78e0 (size : 36) !error,_recognition
    separate : 1 ; 1 [h264 @ 0x15c7240] error,_recognition combined : 1 ;
    10001 [sdp @ 0x15c0c00] decoding for stream 0 failed [sdp @
    0x15c0c00] Could not find codec parameters (Video : h264) [sdp @
    0x15c0c00] Estimating duration from bitrate, this may be inaccurate
    109c.sdp : could not find codec parameters Traceback (most recent
    call last) : File "./ffpipe.py", line 26, in
    ffmpeg_proc.stdin.write(data[42 :]) IOError : [Errno 32] Broken pipe

    (forgive the mass above, the editor keep on complaining about code that is not indented OK ??)

    I’m working on this issue for days... any help/suggestion/hint will be appreciated.

  • RaspberryPi HLS streaming with nginx and ffmpeg ; v4l2 error : ioctl(VIDIOC_STREAMON) : Protocol error

    22 janvier 2021, par Mirco Weber

    I'm trying to realize a baby monitoring with a Raspberry Pi (Model 4B, 4GB RAM) and an ordinary Webcam (with integrated Mic).&#xA;I followed this Tutorial : https://github.com/DeTeam/webcam-stream/blob/master/Tutorial.md

    &#xA;

    Shortly described :

    &#xA;

      &#xA;
    1. I installed and configured an nginx server with rtmp module enabled.
    2. &#xA;

    3. I installed ffmpeg with this configuration —enable-gpl —enable-nonfree —enable-mmal —enable-omx-rpi
    4. &#xA;

    5. I tried to stream ;)
    6. &#xA;

    &#xA;

    The configuration of nginx seems to be working (sometimes streaming works, the server starts without any complication and when the server is up and running, the webpage is displayed).&#xA;The configuration of ffmpeg seems to be fine as well, since streaming sometimes works...

    &#xA;

    I was trying a couple of different ffmpeg-commands ; all of them are sometimes working and sometimes resulting in an error.&#xA;The command looks like following :

    &#xA;

    ffmpeg -re&#xA;-f v4l2&#xA;-i /dev/video0&#xA;-f alsa&#xA;-ac 1&#xA;-thread_queue_size 4096&#xA;-i hw:CARD=Camera,DEV=0&#xA;-profile:v high&#xA;-level:v 4.1&#xA;-vcodec h264_omx&#xA;-r 10&#xA;-b:v 512k&#xA;-s 640x360&#xA;-acodec aac&#xA;-strict&#xA;-2&#xA;-ac 2&#xA;-ab 32k&#xA;-ar 44100&#xA;-f flv&#xA;rtmp://localhost/show/stream;&#xA;

    &#xA;

    Note : I rearranged the code to make it easier to read. In the terminal, it is all in one line.&#xA;Note : There is no difference when using -f video4linux2 instead of -f v4l2

    &#xA;

    The camera is recognized by the system :

    &#xA;

    pi@raspberrypi:~ $ v4l2-ctl --list-devices&#xA;bcm2835-codec-decode (platform:bcm2835-codec):&#xA;    /dev/video10&#xA;    /dev/video11&#xA;    /dev/video12&#xA;&#xA;bcm2835-isp (platform:bcm2835-isp):&#xA;    /dev/video13&#xA;    /dev/video14&#xA;    /dev/video15&#xA;    /dev/video16&#xA;&#xA;HD Web Camera: HD Web Camera (usb-0000:01:00.0-1.2):&#xA;    /dev/video0&#xA;    /dev/video1&#xA;

    &#xA;

    When only using -i /dev/video0, audio transmission never worked.&#xA;The output of arecord -L was :

    &#xA;

    pi@raspberrypi:~ $ arecord -L&#xA;default&#xA;    Playback/recording through the PulseAudio sound server&#xA;null&#xA;    Discard all samples (playback) or generate zero samples (capture)&#xA;jack&#xA;    JACK Audio Connection Kit&#xA;pulse&#xA;    PulseAudio Sound Server&#xA;usbstream:CARD=Headphones&#xA;    bcm2835 Headphones&#xA;    USB Stream Output&#xA;sysdefault:CARD=Camera&#xA;    HD Web Camera, USB Audio&#xA;    Default Audio Device&#xA;front:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    Front speakers&#xA;surround21:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    2.1 Surround output to Front and Subwoofer speakers&#xA;surround40:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    4.0 Surround output to Front and Rear speakers&#xA;surround41:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    4.1 Surround output to Front, Rear and Subwoofer speakers&#xA;surround50:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    5.0 Surround output to Front, Center and Rear speakers&#xA;surround51:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    5.1 Surround output to Front, Center, Rear and Subwoofer speakers&#xA;surround71:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers&#xA;iec958:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    IEC958 (S/PDIF) Digital Audio Output&#xA;dmix:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    Direct sample mixing device&#xA;dsnoop:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    Direct sample snooping device&#xA;hw:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    Direct hardware device without any conversions&#xA;plughw:CARD=Camera,DEV=0&#xA;    HD Web Camera, USB Audio&#xA;    Hardware device with all software conversions&#xA;usbstream:CARD=Camera&#xA;    HD Web Camera&#xA;    USB Stream Output&#xA;

    &#xA;

    that's why i added -i hw:CARD=Camera,DEV=0.

    &#xA;

    As mentioned above, it worked very well a couple of times with this configuration and commands.&#xA;But very often, i get the following error message when starting to stream :

    &#xA;

    pi@raspberrypi:~ $ ffmpeg -re -f video4linux2 -i /dev/video0 -f alsa -ac 1 -thread_queue_size 4096 -i hw:CARD=Camera,DEV=0 -profile:v high -level:v 4.1 -vcodec h264_omx -r 10 -b:v 512k -s 640x360 -acodec aac -strict -2 -ac 2 -ab 32k -ar 44100 -f flv rtmp://localhost/show/stream&#xA;ffmpeg version N-100673-g553eb07737 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 8 (Raspbian 8.3.0-6&#x2B;rpi1)&#xA;  configuration: --enable-gpl --enable-nonfree --enable-mmal --enable-omx-rpi --extra-ldflags=-latomic&#xA;  libavutil      56. 63.101 / 56. 63.101&#xA;  libavcodec     58.117.101 / 58.117.101&#xA;  libavformat    58. 65.101 / 58. 65.101&#xA;  libavdevice    58. 11.103 / 58. 11.103&#xA;  libavfilter     7. 96.100 /  7. 96.100&#xA;  libswscale      5.  8.100 /  5.  8.100&#xA;  libswresample   3.  8.100 /  3.  8.100&#xA;  libpostproc    55.  8.100 / 55.  8.100&#xA;[video4linux2,v4l2 @ 0x2ea4600] ioctl(VIDIOC_STREAMON): Protocol error&#xA;/dev/video0: Protocol error&#xA;

    &#xA;

    And when I'm swithing to /dev/video1 (since this was also an output for v4l2-ctl --list-devices), I get the following error message :

    &#xA;

    pi@raspberrypi:~ $ ffmpeg -re -f v4l2 -i /dev/video1 -f alsa -ac 1 -thread_queue_size 4096 -i hw:CARD=Camera,DEV=0 -profile:v high -level:v 4.1 -vcodec h264_omx -r 10 -b:v 512k -s 640x360 -acodec aac -strict -2 -ac 2 -ab 32k -ar 44100 -f flv rtmp://localhost/show/stream&#xA;ffmpeg version N-100673-g553eb07737 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 8 (Raspbian 8.3.0-6&#x2B;rpi1)&#xA;  configuration: --enable-gpl --enable-nonfree --enable-mmal --enable-omx-rpi --extra-ldflags=-latomic&#xA;  libavutil      56. 63.101 / 56. 63.101&#xA;  libavcodec     58.117.101 / 58.117.101&#xA;  libavformat    58. 65.101 / 58. 65.101&#xA;  libavdevice    58. 11.103 / 58. 11.103&#xA;  libavfilter     7. 96.100 /  7. 96.100&#xA;  libswscale      5.  8.100 /  5.  8.100&#xA;  libswresample   3.  8.100 /  3.  8.100&#xA;  libpostproc    55.  8.100 / 55.  8.100&#xA;[video4linux2,v4l2 @ 0x1aa4610] ioctl(VIDIOC_G_INPUT): Inappropriate ioctl for device&#xA;/dev/video1: Inappropriate ioctl for device&#xA;

    &#xA;

    When using the video0 input, the webcam's LED that recognizes an access is constantly on. When using video1not.

    &#xA;

    After hours and days of googling and tears and whiskey, for the sake of my liver, my marriage and my physical and mental health, I'm very sincerly asking for your help...&#xA;What the f**k is happening and what can I do to make it work ???

    &#xA;

    Thanks everybody :)

    &#xA;

    UPDATE 1 :

    &#xA;

      &#xA;
    1. using the full path to ffmpeg does not change anything...
    2. &#xA;

    3. /dev/video0 and /dev/video1 have access rights for everybody
    4. &#xA;

    5. sudo ffmpeg ... does not change anything as well
    6. &#xA;

    7. the problem seems to be at an "early stage". Stripping the command down to ffmpeg -i /dev/video0 results in the same problem
    8. &#xA;

    &#xA;

    UPDATE 2 :
    &#xA;It seems that everything is working when I first start another Application that needs access to the webcam and then ffmpeg...&#xA;Might be some driver issue, but when I'm looking for loaded modules with lsmod, there is absolutely no change before and after I started the application...&#xA;Any help still appreciated...

    &#xA;

    UPDATE 3 :
    &#xA;I was checking the output of dmesg.
    &#xA;When I started the first application I received this message :
    &#xA;uvcvideo: Failed to query (GET_DEF) UVC control 12 on unit 2: -32 (exp. 4).&#xA;
    And when I started ffmpeg, nothing happend but everything worked...

    &#xA;

  • Best way to diagnose VideoCapture not opening the rtmp stream

    8 janvier 2021, par Greg0ry

    I am pulling my hair off for a few days and I'm out of ideas.

    &#xA;

    I have two rtmp streams

    &#xA;

      &#xA;
    • first stream is transcoded directly by myself (I use ffmpeg to transcode) and then I attach to that stream with opencv - VideoCapture can open the stream with no problem
    • &#xA;

    • second stream is transcoded by 3rd party system (this system captures video through WebRTC and then encodes to h264) - this stream cannot be opened by VideCapture no matter what I do
    • &#xA;

    &#xA;

    I can attach with pure ffmpeg to that dodgy stream and I can restream - but this is not ideal as introduces extra network traffic and latency.

    &#xA;

    I was playing with OPENCV_FFMPEG_CAPTURE_OPTIONS environmental variable (I was trying to remove audio stream, change the video codec, playing with rtmp options like this OPENCV_FFMPEG_CAPTURE_OPTIONS="loglevel;debug" python my_script.py) - no joy

    &#xA;

    So I figured I am trying to solve this problem from wrong end. I should somehow collect underlying ffmpeg logs that should be available when calling VideoCapture. So I tried to set OPENCV_FFMPEG_CAPTURE_OPTIONS="v;debug" but I can see no ffmpeg output when calling VideoCapture.

    &#xA;

    This is very simple python3 script I was using during tests :

    &#xA;

    import cv2 as cv&#xA;dodgy_cap = cv.VideoCapture()&#xA;dodgy_cap.open(&#x27;rtmp://my_local_ip_address/rtmp/dodgy_stream_name&#x27;)&#xA;print(dodgy_cap.isOpened())  # always returns False&#xA;healthy_cap = cv.VideoCapture()&#xA;healthy_cap.open(&#x27;rtmp://my_local_ip_address/rtmp/healthy_stream_name&#x27;)&#xA;print(healthy_cap.isOpened())  # always returns True&#xA;

    &#xA;

    I collected information about both streams with ffprobe, but even though they look different I cannot see what would be the difference that prevents opencv from opening VideoCapture for dodgy stream..

    &#xA;

    This is a fragment from (very) verbose log for healthy stream :

    &#xA;

    RTMP_ClientPacket, received: notify 254 bytes                                                                                                                                                                                               &#xA;(object begin)                                                                                                                                                                                                                              &#xA;Property:                                                                                                                                                                                  &#xA;Property:                                                                                                                                                                                             &#xA;(object begin)                                                                                                                                                                                                                              &#xA;Property:                                                                                                                                                                                        &#xA;Property:                                                                                                                                                                                     &#xA;Property:                                                                                                                                                                                     &#xA;Property:                                                                                                                                                                                        &#xA;Property:                                                                                                                                                                                        &#xA;Property:                                                                                                                                                                                        &#xA;Property:                                                                                                                                                               &#xA;Property:                                                                                                                                                                         &#xA;Property:                                                                                                                                                                               &#xA;Property:                                                                                                                                                                                        &#xA;(object end)                                                                                                                                                                                                                                &#xA;(object end)                                                                                                                                                                                                                                &#xA;Metadata:&#xA;  duration              0.00&#xA;  width                 2048.00&#xA;  height                1536.00&#xA;  videodatarate         0.00&#xA;  framerate             6.00&#xA;  videocodecid          7.00&#xA;  title                 Session streamed by "preview"&#xA;  comment               h264Preview_01_main&#xA;  encoder               Lavf58.20.100&#xA;  filesize              0.00&#xA;&#xA;(... raw network packets ...)&#xA;&#xA;Input #0, flv, from &#x27;rtmp://my_local_ip_address/rtmp/healthy_stream_name&#x27;:&#xA;  Metadata:&#xA;    title           : Session streamed by "preview"&#xA;    comment         : h264Preview_01_main&#xA;    encoder         : Lavf58.20.100&#xA;  Duration: 00:00:00.00, start: 159.743000, bitrate: N/A&#xA;    Stream #0:0, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(progressive), 2048x1536, 0/1, 6 fps, 6 tbr, 1k tbn&#xA;&#xA;

    &#xA;

    And this is the fragment for dodgy stream :

    &#xA;

    RTMP_ClientPacket, received: notify 205 bytes                                                                                                                                                                                               &#xA;(object begin)                                                                                                                                                                                                                              &#xA;Property:                                                                                                                                                                                                 &#xA;(object begin)                                                                                                                                                                                                                              &#xA;Property:                                                                                                                                                                                &#xA;Property:                                                                                                                                                                            &#xA;Property:                                                                                                                                                                                       &#xA;Property:                                                                                                                                                                                       &#xA;Property:                                                                                                                                                                                       &#xA;Property:                                                                                                                                                                                    &#xA;Property:                                                                                                                                                                                        &#xA;Property:                                                                                                                                                                                      &#xA;Property:                                                                                                                                                                                      &#xA;(object end)                                                                                                                                                                                                                                &#xA;(object end)                                                                                                                                                                                                                                &#xA;RTMP_ReadPacket: fd=3                                                                                                                                                                                                                       &#xA;&#xA;(... raw network packets ...)&#xA;&#xA;Input #0, flv, from &#x27;rtmp://my_local_ip_address/rtmp/dodgy_stream_name&#x27;:&#xA;  Duration: N/A, start: 4511.449000, bitrate: N/A&#xA;    Stream #0:0, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(progressive, left), 640x480, 0/1, 15.17 fps, 15.08 tbr, 1k tbn, 30 tbc&#xA;    Stream #0:1, 124, 1/1000: Audio: aac (LC), 48000 Hz, mono, fltp&#xA;&#xA;

    &#xA;

    Both streams don't require any authentication (they are not exposed to the outside world)

    &#xA;

    Dodgy stream contains audio but I don't think it is source of problem as I was able to connect to other healthy rtmp streams that contained audio..

    &#xA;

    I have no more ideas how can I debug this problem, please help..

    &#xA;


    &#xA;

    I found in VideoCap documentation that I can enable exception mode, however it did not help much (it says where it failed but it does not say why) :

    &#xA;

    >>> dodgy_stream = cv.VideoCapture()&#xA;>>> dodgy_stream.setExceptionMode(True)&#xA;>>> dodgy_stream.open("rtmp://my_local_ip_address/rtmp/dodgy_stream_name")&#xA;Traceback (most recent call last):&#xA;  File "<stdin>", line 1, in <module>&#xA;cv2.error: OpenCV(4.5.0) /tmp/pip-req-build-s_nildlw/opencv/modules/videoio/src/cap.cpp:177: error: (-2:Unspecified error) could not open &#x27;rtmp://my_local_ip_address/rtmp/dodgy_stream_name&#x27; in function &#x27;open&#x27;&#xA;</module></stdin>

    &#xA;