Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (67)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • 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

Sur d’autres sites (8739)

  • Concat video/audio files downloaded from mpd dash manifest

    15 mai 2022, par Bloworlf Mathurin

    I have this manifest I fetched from an url :

    


    &lt;?xml version="1.0"?>&#xA;<mpd type="dynamic" xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" availabilitystarttime="2022-05-14T21:18:50-07:00" availabilityendtime="2022-05-14T22:35:36-07:00" timeshiftbufferdepth="PT20S" suggestedpresentationdelay="PT2S" minbuffertime="PT1S" publishtime="2022-05-14T21:18:50-07:00" minimumupdateperiod="PT1S" validationerrors="" currentservertimems="0" firstavtimems="1652588331877" lastvideoframets="0" loapstreamid="17944405669984029" publishframetime="939">&#xA;    <period start="PT0S">&#xA;        <adaptationset segmentalignment="true" maxwidth="432" maxheight="766" maxframerate="30">&#xA;            <representation mimetype="video/mp4" codecs="avc1.4d401e" width="432" height="766" framerate="30" startwithsap="1" bandwidth="38894" maxbandwidth="46772" playbackresolutionmos="432:82.84,720:65.43,216:70.39" qualityclass="sd" qualitylabel="432p">&#xA;                <segmenttemplate presentationtimeoffset="0" timescale="1000" initialization="some/url/some_id-init.m4v?ms=m_C&amp;amp;ccb=2-4" media="some/url/some_id-$Time$.m4v?ms=m_C&amp;amp;ccb=2-4">&#xA;                    <segmenttimeline>&#xA;                        <s t="4092613" d="2000"></s>&#xA;                        <s t="4094613" d="2000"></s>&#xA;                        <s t="4096613" d="2000"></s>&#xA;                        <s t="4098613" d="2000"></s>&#xA;                        <s t="4100613" d="2000"></s>&#xA;                        <s t="4102613" d="2000"></s>&#xA;                        <s t="4104613" d="2000"></s>&#xA;                        <s t="4106613" d="2000"></s>&#xA;                        <s t="4108613" d="2000"></s>&#xA;                        <s t="4110613" d="2000"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;        <adaptationset segmentalignment="true">&#xA;            <representation mimetype="audio/mp4" codecs="mp4a.40.2" audiosamplingrate="44100" startwithsap="1" bandwidth="48979" maxbandwidth="57732">&#xA;                <segmenttemplate presentationtimeoffset="0" timescale="1000" initialization="some/url/some_id-init.m4a?ms=m_C&amp;amp;ccb=2-4" media="some/url/some_id-$Time$.m4a?ms=m_C&amp;amp;ccb=2-4">&#xA;                    <segmenttimeline>&#xA;                        <s t="4092613" d="2000"></s>&#xA;                        <s t="4094613" d="2000"></s>&#xA;                        <s t="4096613" d="2000"></s>&#xA;                        <s t="4098613" d="2000"></s>&#xA;                        <s t="4100613" d="2000"></s>&#xA;                        <s t="4102613" d="2000"></s>&#xA;                        <s t="4104613" d="2000"></s>&#xA;                        <s t="4106613" d="2000"></s>&#xA;                        <s t="4108613" d="2000"></s>&#xA;                        <s t="4110613" d="2000"></s>&#xA;                    </segmenttimeline>&#xA;                </segmenttemplate>&#xA;            </representation>&#xA;        </adaptationset>&#xA;    </period>&#xA;</mpd>&#xA;

    &#xA;

    I manage to download all the files (init file + 10 segment files) and put them in an array

    &#xA;

    File[] files = downloadSegments();

    &#xA;

    So I have :&#xA;[0] -> file-0.m4v (which is the init file)&#xA;[1] -> file-1.m4v (1st segment)&#xA;... and so on.

    &#xA;

    My question is how can I concat/append all these files into another file (final_segment.m4v) ?

    &#xA;

    I looked around a lot and am now using 'com.arthenica:ffmpeg-kit-video:4.5.1-1'&#xA;I've last tried :

    &#xA;

    FFmpegSession session = FFmpegKit.execute("-i file-0.m4v -i file-1.m4v ... -c copy final_segment.m4v");&#xA;

    &#xA;

    Is there something I'm missing ?

    &#xA;

    Also I assume that I'll have to do the same for the audio segments. So I will have 2 files (final_segment.m4v and final_segment.m4a) that I will have to merge/mix together.

    &#xA;

    If you could help me with some piece of code, that would be great.

    &#xA;

  • extracting video and data streams from MPEG2 TS over RTP in real-time

    10 janvier 2024, par Tejal Barnwal

    I have H264 video stream and KLV meta data encapsulated inside MPEG2 TS container which are sent over an RTP over UDP from a camera.&#xA;I intend to do the following :

    &#xA;

      &#xA;
    1. Extract both video and data streams from RTP
    2. &#xA;

    3. Process video feed using opencv in a seperate thread
    4. &#xA;

    5. process klv metadata in a seperate thread
    6. &#xA;

    &#xA;

    My problem what exact arguments should I provide to ffmpeg so as to read h264 video stream and show the images frame by frame using opencv ?

    &#xA;

    With the help of some previous posts like Simultaneously map video and data streams to one subprocess pipeline in real-time, I was able to get some idea about how could I proceed to procees the stream over RTP.

    &#xA;

    I started out by using the following script :

    &#xA;

    #!/usr/bin/env python3&#xA;from asyncio import streams&#xA;from logging.handlers import QueueListener&#xA;import klvdata&#xA;import subprocess as sp&#xA;import shlex&#xA;import threading&#xA;import numpy as np&#xA;import cv2&#xA;import time&#xA;from io import BytesIO&#xA;&#xA;# Video reader thread.&#xA;def video_reader(pipe):&#xA;    cols, rows = 1280, 720  # Assume we know frame size is 1280x720&#xA;&#xA;    counter = 0&#xA;    while True:&#xA;        print("read image")&#xA;        raw_image = pipe.read(cols*rows*3)  # Read raw video frame&#xA;&#xA;        # Break the loop when length is too small&#xA;        if len(raw_image) &lt; cols*rows*3:&#xA;            break&#xA;&#xA;        if (counter % 10) == 0:&#xA;            # Show video frame evey 60 frames&#xA;            image = np.frombuffer(raw_image, np.uint8).reshape([rows, cols, 3])&#xA;            cv2.imshow(&#x27;Video&#x27;, image) # Show video image for testing&#xA;            cv2.waitKey(1)&#xA;        counter &#x2B;= 1&#xA;        print("image showed on window")&#xA;        time.sleep(0.25)&#xA;&#xA;&#xA;&#xA;# https://github.com/paretech/klvdata/tree/master/klvdata&#xA;def bytes_to_int(value, signed=False):&#xA;    """Return integer given bytes."""&#xA;    return int.from_bytes(bytes(value), byteorder=&#x27;big&#x27;, signed=signed)&#xA;&#xA;&#xA;# Data reader thread (read KLV data).&#xA;def data_reader(pipe):&#xA;    key_length = 16  # Assume key length is 16 bytes.&#xA;&#xA;    f = open(&#x27;data.bin&#x27;, &#x27;wb&#x27;)  # For testing - store the KLV data to data.bin (binary file)&#xA;&#xA;    while True:&#xA;        # https://en.wikipedia.org/wiki/KLV&#xA;        # The first few bytes are the Key, much like a key in a standard hash table data structure.&#xA;        # Keys can be 1, 2, 4, or 16 bytes in length.&#xA;        # Presumably in a separate specification document you would agree on a key length for a given application.&#xA;        key = pipe.read(key_length)  # Read the key&#xA;        &#xA;        if len(key) &lt; key_length:&#xA;            break  # Break the loop when length is too small&#xA;        f.write(key)  # Write data to binary file for testing&#xA;&#xA;        # https://github.com/paretech/klvdata/tree/master/klvdata&#xA;        # Length field&#xA;        len_byte = pipe.read(1)&#xA;&#xA;        if len(len_byte) &lt; 1:&#xA;            break  # Break the loop when length is too small&#xA;        f.write(len_byte)  # Write data to binary file for testing&#xA;&#xA;        byte_length = bytes_to_int(len_byte)&#xA;&#xA;        # https://github.com/paretech/klvdata/tree/master/klvdata                                                &#xA;        if byte_length &lt; 128:&#xA;            # BER Short Form&#xA;            length = byte_length&#xA;            ber_len_bytes = b&#x27;&#x27;&#xA;        else:&#xA;            # BER Long Form&#xA;            ber_len = byte_length - 128&#xA;            ber_len_bytes = pipe.read(ber_len)&#xA;&#xA;            if len(ber_len_bytes) &lt; ber_len:&#xA;                break  # Break the loop when length is too small&#xA;            f.write(ber_len_bytes)  # Write ber_len_bytes to binary file for testing&#xA;&#xA;            length = bytes_to_int(ber_len_bytes)&#xA;&#xA;        # Read the value (length bytes)&#xA;        value = pipe.read(length)&#xA;        if len(value) &lt; length:&#xA;            break  # Break the loop when length is too small&#xA;        f.write(value)  # Write data to binary file for testing&#xA;&#xA;        klv_data = key &#x2B; len_byte &#x2B; ber_len_bytes &#x2B; value  # Concatenate key length and data&#xA;        klv_data_as_bytes_io = BytesIO(klv_data)  # Wrap klv_data with BytesIO (before parsing)&#xA;&#xA;        # Parse the KLV data&#xA;        for packet in klvdata.StreamParser(klv_data_as_bytes_io): &#xA;            metadata = packet.MetadataList()&#xA;            for key, value in metadata.items():&#xA;                print(key, value)&#xA;                &#xA;            print("\n") # New line&#xA;&#xA;# Execute FFmpeg as sub-process&#xA;# Map the video to stderr and map the data to stdout&#xA;process = sp.Popen(shlex.split(&#x27;ffmpeg -hide_banner -loglevel quiet &#x27;                        # Set loglevel to quiet for disabling the prints ot stderr&#xA;                               &#x27;-i "rtp://192.168.0.141:11024" &#x27;                                        # Input video "Day Flight.mpg"&#xA;                               &#x27;-map 0:v -c:v rawvideo -pix_fmt bgr24 -f:v rawvideo pipe:2 &#x27; # rawvideo format is mapped to stderr pipe (raw video codec with bgr24 pixel format)&#xA;                               &#x27;-map 0:d -c copy -copy_unknown -f:d data pipe:1 &#x27;            # Copy the data without ddecoding.&#xA;                               &#x27;-report&#x27;),                                                   # Create a log file (because we can&#x27;t the statuses that are usually printed to stderr).&#xA;                                stdout=sp.PIPE, stderr=sp.PIPE)&#xA;&#xA;&#xA;# Start video reader thread (pass stderr pipe as argument).&#xA;video_thread = threading.Thread(target=video_reader, args=(process.stderr,))&#xA;video_thread.start()&#xA;&#xA;# Start data reader thread (pass stdout pipe as argument).&#xA;data_thread = threading.Thread(target=data_reader, args=(process.stdout,))&#xA;data_thread.start()&#xA;&#xA;&#xA;# Wait for threads (and process) to finish.&#xA;video_thread.join()&#xA;data_thread.join()&#xA;process.wait()&#xA;&#xA;

    &#xA;

    With the above script, I was facing two issues :

    &#xA;

      &#xA;
    1. The second thread resulted in an attribute error
    2. &#xA;

    &#xA;

    Exception in thread Thread-2:&#xA;Traceback (most recent call last):&#xA;  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner&#xA;    self.run()&#xA;  File "/usr/lib/python3.8/threading.py", line 870, in run&#xA;    self._target(*self._args, **self._kwargs)&#xA;  File "video_data_extraction.py", line 97, in data_reader&#xA;    print(packet.MetadataList())&#xA;AttributeError: &#x27;UnknownElement&#x27; object has no attribute &#x27;MetadataList&#x27;&#xA;&#xA;

    &#xA;

      &#xA;
    1. With this though I continuously able to see following output on the terminal regarding reading the images
    2. &#xA;

    &#xA;

    read image&#xA;image showed on window&#xA;read image&#xA;image showed on window&#xA;read image&#xA;image showed on window&#xA;read image&#xA;image showed on window&#xA;read image&#xA;image showed on window&#xA;read image&#xA;image showed on window&#xA;

    &#xA;

    The imshow windows wasnt updating properly ! It seemed stuck after a few frames.

    &#xA;

    Further diving into the lane with the help of following command, I concluded that the video stream that I am reading has H264 encoding

    &#xA;

    ffprobe -i rtp://192.168.0.141:11024 -show_streams -show_formats&#xA;

    &#xA;

    Output of the above command :

    &#xA;

    ffprobe version 4.2.7-0ubuntu0.1 Copyright (c) 2007-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/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --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-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;[rtp @ 0xaaaac81ecce0] PES packet size mismatch&#xA;    Last message repeated 62 times&#xA;[NULL @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[rtp @ 0xaaaac81ecce0] PES packet size mismatch&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[rtp @ 0xaaaac81ecce0] PES packet size mismatch&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] non-existing PPS 0 referenced&#xA;    Last message repeated 1 times&#xA;[h264 @ 0xaaaac81f09b0] decode_slice_header error&#xA;[h264 @ 0xaaaac81f09b0] no frame!&#xA;[rtp @ 0xaaaac81ecce0] PES packet size mismatch&#xA;    Last message repeated 187 times&#xA;Input #0, rtp, from &#x27;rtp://192.168.0.141:11024&#x27;:&#xA;  Duration: N/A, start: 1317.040656, bitrate: N/A&#xA;  Program 1 &#xA;    Stream #0:1: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 90k tbn&#xA;    Stream #0:0: Data: klv (KLVA / 0x41564C4B)&#xA;Unsupported codec with id 100356 for input stream 0&#xA;[STREAM]&#xA;index=0&#xA;codec_name=klv&#xA;codec_long_name=SMPTE 336M Key-Length-Value (KLV) metadata&#xA;profile=unknown&#xA;codec_type=data&#xA;codec_tag_string=KLVA&#xA;codec_tag=0x41564c4b&#xA;id=N/A&#xA;r_frame_rate=0/0&#xA;avg_frame_rate=0/0&#xA;time_base=1/90000&#xA;start_pts=118533659&#xA;start_time=1317.040656&#xA;duration_ts=N/A&#xA;duration=N/A&#xA;bit_rate=N/A&#xA;max_bit_rate=N/A&#xA;bits_per_raw_sample=N/A&#xA;nb_frames=N/A&#xA;nb_read_frames=N/A&#xA;nb_read_packets=N/A&#xA;DISPOSITION:default=0&#xA;DISPOSITION:dub=0&#xA;DISPOSITION:original=0&#xA;DISPOSITION:comment=0&#xA;DISPOSITION:lyrics=0&#xA;DISPOSITION:karaoke=0&#xA;DISPOSITION:forced=0&#xA;DISPOSITION:hearing_impaired=0&#xA;DISPOSITION:visual_impaired=0&#xA;DISPOSITION:clean_effects=0&#xA;DISPOSITION:attached_pic=0&#xA;DISPOSITION:timed_thumbnails=0&#xA;[/STREAM]&#xA;[STREAM]&#xA;index=1&#xA;codec_name=h264&#xA;codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10&#xA;profile=Constrained Baseline&#xA;codec_type=video&#xA;codec_time_base=1/50&#xA;codec_tag_string=[27][0][0][0]&#xA;codec_tag=0x001b&#xA;width=1280&#xA;height=720&#xA;coded_width=1280&#xA;coded_height=720&#xA;has_b_frames=0&#xA;sample_aspect_ratio=N/A&#xA;display_aspect_ratio=N/A&#xA;pix_fmt=yuv420p&#xA;level=31&#xA;color_range=unknown&#xA;color_space=unknown&#xA;color_transfer=unknown&#xA;color_primaries=unknown&#xA;chroma_location=left&#xA;field_order=progressive&#xA;timecode=N/A&#xA;refs=1&#xA;is_avc=false&#xA;nal_length_size=0&#xA;id=N/A&#xA;r_frame_rate=25/1&#xA;avg_frame_rate=25/1&#xA;time_base=1/90000&#xA;start_pts=118533659&#xA;start_time=1317.040656&#xA;duration_ts=N/A&#xA;duration=N/A&#xA;bit_rate=N/A&#xA;max_bit_rate=N/A&#xA;bits_per_raw_sample=8&#xA;nb_frames=N/A&#xA;nb_read_frames=N/A&#xA;nb_read_packets=N/A&#xA;DISPOSITION:default=0&#xA;DISPOSITION:dub=0&#xA;DISPOSITION:original=0&#xA;DISPOSITION:comment=0&#xA;DISPOSITION:lyrics=0&#xA;DISPOSITION:karaoke=0&#xA;DISPOSITION:forced=0&#xA;DISPOSITION:hearing_impaired=0&#xA;DISPOSITION:visual_impaired=0&#xA;DISPOSITION:clean_effects=0&#xA;DISPOSITION:attached_pic=0&#xA;DISPOSITION:timed_thumbnails=0&#xA;[/STREAM]&#xA;[FORMAT]&#xA;filename=rtp://192.168.0.141:11024&#xA;nb_streams=2&#xA;nb_programs=1&#xA;format_name=rtp&#xA;format_long_name=RTP input&#xA;start_time=1317.040656&#xA;duration=N/A&#xA;size=N/A&#xA;bit_rate=N/A&#xA;probe_score=100&#xA;[/FORMAT]&#xA;

    &#xA;

    Further, in the log output, I see a lot of statements in regard to missed packets and PES packet mismatch

    &#xA;

    [rtp @ 0xaaaaf31896c0] max delay reached. need to consume packet&#xA;[rtp @ 0xaaaaf31896c0] RTP: missed 98 packets&#xA;[rtp @ 0xaaaaf31896c0] Continuity check failed for pid 40 expected 14 got 10&#xA;[rtp @ 0xaaaaf31896c0] PES packet size mismatch&#xA;rtp://192.168.0.141:11024: corrupt input packet in stream 0&#xA;frame=  124 fps=2.6 q=-0.0 size=  334800kB time=00:00:05.32 bitrate=515406.0kbits/s dup=97 drop=0 speed=0.111x &#xA;

    &#xA;

    What arguments do I provide to ffmpeg and in what order because my stream 0 is metadata and stream 1 is video so as to display image frame by frame with opencv ?&#xA;I would be grateful for any help that you could provide.

    &#xA;

    Further, I also have a query regarding how does ffmpeg know to that it has to first convert the rtp packets into mpeg2 TS packets before segregating video stream and data stream ?

    &#xA;

  • ffmpeg streaming UDP port is closed [closed]

    26 décembre 2023, par BrilliantContract

    I'm trying to use ffmpeg in order to transcode RTSP stream from CCTV to HLS stream so it could be accessed through a web server.

    &#xA;

    ffmpeg used to stream video from CCTV with following command

    &#xA;

    $ ffmpeg -i "rtsp://cam-1.loc:554?user=admin&amp;password=admin&amp;channel=1&amp;stream=0" -hls_time 3 -hls_wrap 10 -f mpegts udp://localhost:6601&#xA;ffmpeg version 4.2.8 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with gcc 8 (GCC)&#xA;  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags=&#x27;-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection&#x27; --extra-ldflags=&#x27;-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld &#x27; --extra-cflags=&#x27; &#x27; --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect&#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;[rtsp @ 0x5576c7340600] getaddrinfo(cam-1.loc): Name or service not known&#xA;Guessed Channel Layout for Input Stream #0.1 : mono&#xA;Input #0, rtsp, from &#x27;rtsp://cam-1.loc:554?user=admin&amp;password=admin&amp;channel=1&amp;stream=0&#x27;:&#xA;  Metadata:&#xA;    title           : RTSP Session&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;    Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc&#xA;    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))&#xA;  Stream #0:1 -> #0:1 (pcm_alaw (native) -> mp2 (native))&#xA;Press [q] to stop, [?] for help&#xA;Output #0, mpegts, to &#x27;udp://localhost:6601&#x27;:&#xA;  Metadata:&#xA;    title           : RTSP Session&#xA;    encoder         : Lavf58.29.100&#xA;    Stream #0:0: Video: mpeg2video (Main), yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc&#xA;    Metadata:&#xA;      encoder         : Lavc58.54.100 mpeg2video&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1&#xA;    Stream #0:1: Audio: mp2, 16000 Hz, mono, s16, 160 kb/s&#xA;    Metadata:&#xA;      encoder         : Lavc58.54.100 mp2&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5338.9kbits/s dup=0 drop=5 speed=1.12x    &#xA;[rtsp @ 0x5576c7340600] RTP: missed 3 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 6 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 6 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 4 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 6 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 6 packets&#xA;[h264 @ 0x5576c7993c80] concealing 972 DC, 972 AC, 972 MV errors in I frame&#xA;rtsp://cam-1.loc:554?user=admin&amp;password=admin&amp;channel=1&amp;stream=0: corrupt decoded frame in stream 0=1.11x    &#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packette=5298.4kbits/s dup=0 drop=5 speed=1.02x    &#xA;[rtsp @ 0x5576c7340600] RTP: missed 2 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 4 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 3 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 4 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 5 packets&#xA;[rtsp @ 0x5576c7340600] max delay reached. need to consume packet&#xA;[rtsp @ 0x5576c7340600] RTP: missed 2 packets&#xA;[h264 @ 0x5576c779b9c0] cabac decode of qscale diff failed at 66 60&#xA;[h264 @ 0x5576c779b9c0] error while decoding MB 66 60, bytestream 9825&#xA;[h264 @ 0x5576c779b9c0] concealing 943 DC, 943 AC, 943 MV errors in I frame&#xA;rtsp://cam-1.loc:554?user=admin&amp;password=admin&amp;channel=1&amp;stream=0: corrupt decoded frame in stream 0=1.02x    &#xA;frame= 1315 fps= 25 q=31.0 Lsize=   34249kB time=00:00:53.32 bitrate=5261.8kbits/s dup=0 drop=5 speed=1.02x    &#xA;video:30544kB audio:1042kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 8.431973%&#xA;

    &#xA;

    nmap used to check if 6601 port is open

    &#xA;

    $ nmap -Pn localhost -p 6601&#xA;Starting Nmap 7.70 ( https://nmap.org ) at 2023-12-26 10:47 UTC&#xA;Nmap scan report for localhost (127.0.0.1)&#xA;Host is up (0.0011s latency).&#xA;Other addresses for localhost (not scanned): ::1&#xA;&#xA;PORT     STATE  SERVICE&#xA;6601/tcp closed mstmg-sstp&#xA;&#xA;Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds&#xA;

    &#xA;

    However, ffplayer able to play video stream

    &#xA;

    ffplay udp://localhost:6601&#xA;ffplay version 4.2.8 Copyright (c) 2003-2022 the FFmpeg developers&#xA;  built with gcc 8 (GCC)&#xA;  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags=&#x27;-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection&#x27; --extra-ldflags=&#x27;-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld &#x27; --extra-cflags=&#x27; &#x27; --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect&#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;[mpeg2video @ 0x7f1ad854afc0] Invalid frame dimensions 0x0. f=0/0   &#xA;    Last message repeated 7 times&#xA;Input #0, mpegts, from &#x27;udp://localhost:6601&#x27;:0KB sq=    0B f=0/0   &#xA;  Duration: N/A, start: 59.288000, bitrate: N/A&#xA;  Program 1 &#xA;    Metadata:&#xA;      service_name    : RTSP Session&#xA;      service_provider: FFmpeg&#xA;    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc&#xA;    Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s&#xA;

    &#xA;

    VLC cannot play the video stream :

    &#xA;

    vlc udp://localhost:6601&#xA;VLC media player 3.0.18 Vetinari (revision )&#xA;[000055769aa81ba0] main libvlc: Running vlc with the default interface. Use &#x27;cvlc&#x27; to use vlc without interface.&#xA;Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.&#xA;[00007fec64011e90] mjpeg demux error: cannot peek&#xA;

    &#xA;

    ffprobe output

    &#xA;

    ffprobe udp://localhost:6601&#xA;ffprobe version 4.2.8 Copyright (c) 2007-2022 the FFmpeg developers&#xA;  built with gcc 8 (GCC)&#xA;  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags=&#x27;-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection&#x27; --extra-ldflags=&#x27;-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld &#x27; --extra-cflags=&#x27; &#x27; --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librsvg --enable-libsrt --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-libzvbi --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-libmfx --enable-runtime-cpudetect&#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;[mpeg2video @ 0x55e1be0910c0] Invalid frame dimensions 0x0.&#xA;    Last message repeated 9 times&#xA;Input #0, mpegts, from &#x27;udp://localhost:6601&#x27;:&#xA;  Duration: N/A, start: 262.760000, bitrate: N/A&#xA;  Program 1 &#xA;    Metadata:&#xA;      service_name    : RTSP Session&#xA;      service_provider: FFmpeg&#xA;    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc&#xA;    Stream #0:1[0x101]: Audio: mp2 ([4][0][0][0] / 0x0004), 16000 Hz, mono, s16p, 160 kb/s&#xA;

    &#xA;

    Why the video stream is not playing in VLC ?

    &#xA;

    Why nmap do not see that UPD port is open ?

    &#xA;