Advanced search

Medias (91)

Other articles (102)

  • MediaSPIP 0.1 Beta version

    25 April 2011, by

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • MediaSPIP version 0.1 Beta

    16 April 2011, by

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, 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 (...)

  • Amélioration de la version de base

    13 September 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

On other websites (9858)

  • Algorithm when recording SegmentTimeline of MPEG-DASH MPD in shaka packager

    25 March 2021, by jgkim0518

    I packaged a media stream by mpeg-dash transcoded video at twice the speed and audio at normal speed.
Here is the command:

    


    ffmpeg -re -stream_loop -1 -i timing_logic.mp4 -c:v hevc_nvenc -filter:v "setpts=2*PTS" -c:a libfdk_aac -map 0:v -map 0:a -f mpegts udp://xxx.xxx.xxx.xxx:xxxx?pkt_size=1316


    


    The source information used here is as follows:

    


    Input #0, mpegts, from '/home/test/timing_logic/timing_logic.mp4':
Duration: 00:00:30.22, start: 1.400000, bitrate: 16171 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: hevc (Main 10) (HEVC / 0x43564548), yuv420p10le(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 128 kb/s Stream mapping:
Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_nvenc))
Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
Output #0, mpegts, to 'udp://xxx.xxx.xxx.xxx:xxxx?pkt_size=1316':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: hevc (hevc_nvenc) (Main 10), p010le, 3840x2160 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 50 fps, 90k tbn, 50 tbc
Metadata:
encoder : Lavc58.91.100 hevc_nvenc
Side data:
cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
Stream #0:1(eng): Audio: aac (libfdk_aac), 48000 Hz, stereo, s16, 139 kb/s
Metadata:
encoder : Lavc58.91.100 libfdk_aac


    


    My shaka packager command is:

    


    packager \ 'in=udp://xxx.xxx.xxx.xxx:xxxx,stream=video,init_segment=/home/test/timing_logic/package/video/0/video.mp4,segment_template=/home/test/timing_logic/package/video/0/$Time$.m4s' \
'in=udp://xxx.xxx.xxx.xxx:xxxx,stream=audio,init_segment=/home/test/timing_logic/package/audio/0/audio.mp4,segment_template=/home/test/timing_logic/package/audio/0/$Time$.m4a' \
--segment_duration 5 --fragment_duration 5 --minimum_update_period 5 --min_buffer_time 5 \
--preserved_segments_outside_live_window 24 --time_shift_buffer_depth 40 \
--allow_codec_switching --allow_approximate_segment_timeline --log_file_generation_deletion \
--mpd_output $OUTPUT/$output_mpd.mpd &


    


    Looking at the mpd generated as a result of packaging, the duration of the audio is twice that of the video, and the number of segments is half.
The following is the content of mpd:

    


    &lt;?xml version="1.0" encoding="UTF-8"?>&#xA;&#xA;<mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" minbuffertime="PT5S" type="dynamic" publishtime="2021-03-23T10:01:57Z" availabilitystarttime="2021-03-23T09:59:55Z" minimumupdateperiod="PT5S" timeshiftbufferdepth="PT40S">&#xA;<period start="PT0S">&#xA;<adaptationset contenttype="audio" segmentalignment="true">&#xA;<representation bandwidth="140020" codecs="mp4a.40.2" mimetype="audio/mp4" audiosamplingrate="48000">&#xA;<audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;<segmenttemplate timescale="90000" initialization="/home/test/timing_logic/package/audio/0/audio.mp4" media="/home/test/timing_logic/package/audio/0/$Time$.m4a" startnumber="16">&#xA;<segmenttimeline>&#xA;<s t="6751436" d="449280"></s>&#xA;<s t="7200716" d="451200"></s>&#xA;<s t="7651916" d="449280"></s>&#xA;<s t="8101196" d="374400"></s>&#xA;<s t="8551196" d="449280"></s>&#xA;<s t="9000476" d="451200"></s>&#xA;<s t="9451674" d="449280"></s>&#xA;<s t="9900956" d="449280"></s>&#xA;<s t="10350236" d="451200"></s>&#xA;<s t="10801434" d="374400"></s>&#xA;</segmenttimeline>&#xA;</segmenttemplate>&#xA;</representation>&#xA;</adaptationset>&#xA;<adaptationset contenttype="video" width="3840" height="2160" framerate="90000/3600" segmentalignment="true" par="16:9">&#xA;<representation bandwidth="1520392" codecs="hvc1.2.4.L153" mimetype="video/mp4" sar="1:1">&#xA;<segmenttemplate timescale="90000" initialization="/home/test/timing_logic/package/video/0/video.mp4" media="/home/test/timing_logic/package/video/0/$Time$.m4s" startnumber="19">&#xA;<segmenttimeline>&#xA;<s t="16954440" d="900000" r="4"></s>&#xA;</segmenttimeline>&#xA;</segmenttemplate>&#xA;</representation>&#xA;</adaptationset>&#xA;</period>&#xA;</mpd>&#xA;

    &#xA;

    When looking at the MPD, it seems that the shaka packager checks the PTS or DTS of the TS when creating a segment and recording the contents of the SegmentTimeline.&#xA;But I couldn't understand even by looking at the MPEG standard documentation and the DASH-IF documentation.

    &#xA;

    My question is whether the packager refers to PTS or DTS when creating a segment.&#xA;How are SegmentTimeline's S@t and S@d recorded?&#xA;What algorithm is the SegmentTimeline recorded with? Please help me. Thank you.

    &#xA;

  • Algorithm when recording SegmentTimeline

    24 March 2021, by jgkim0518

    I packaged a media stream by mpeg-dash transcoded video at twice the speed and audio at normal speed.&#xA;Here is the command:

    &#xA;

    ffmpeg -re -stream_loop -1 -i timing_logic.mp4 -c:v hevc_nvenc -filter:v "setpts=2*PTS" -c:a libfdk_aac -map 0:v -map 0:a -f mpegts udp://xxx.xxx.xxx.xxx:xxxx?pkt_size=1316&#xA;

    &#xA;

    The source information used here is as follows:

    &#xA;

    Input #0, mpegts, from &#x27;/home/test/timing_logic/timing_logic.mp4&#x27;:&#xA;Duration: 00:00:30.22, start: 1.400000, bitrate: 16171 kb/s&#xA;Program 1&#xA;Metadata:&#xA;service_name : Service01&#xA;service_provider: FFmpeg&#xA;Stream #0:0[0x100]: Video: hevc (Main 10) (HEVC / 0x43564548), yuv420p10le(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc&#xA;Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 128 kb/s Stream mapping:&#xA;Stream #0:0 -> #0:0 (hevc (native) -> hevc (hevc_nvenc))&#xA;Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))&#xA;Press [q] to stop, [?] for help&#xA;frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A&#xA;frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A&#xA;Output #0, mpegts, to &#x27;udp://xxx.xxx.xxx.xxx:xxxx?pkt_size=1316&#x27;:&#xA;Metadata:&#xA;encoder : Lavf58.45.100&#xA;Stream #0:0: Video: hevc (hevc_nvenc) (Main 10), p010le, 3840x2160 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 50 fps, 90k tbn, 50 tbc&#xA;Metadata:&#xA;encoder : Lavc58.91.100 hevc_nvenc&#xA;Side data:&#xA;cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A&#xA;Stream #0:1(eng): Audio: aac (libfdk_aac), 48000 Hz, stereo, s16, 139 kb/s&#xA;Metadata:&#xA;encoder : Lavc58.91.100 libfdk_aac&#xA;

    &#xA;

    My shaka packager command is:

    &#xA;

    packager \ &#x27;in=udp://xxx.xxx.xxx.xxx:xxxx,stream=video,init_segment=/home/test/timing_logic/package/video/0/video.mp4,segment_template=/home/test/timing_logic/package/video/0/$Time$.m4s&#x27; \&#xA;&#x27;in=udp://xxx.xxx.xxx.xxx:xxxx,stream=audio,init_segment=/home/test/timing_logic/package/audio/0/audio.mp4,segment_template=/home/test/timing_logic/package/audio/0/$Time$.m4a&#x27; \&#xA;--segment_duration 5 --fragment_duration 5 --minimum_update_period 5 --min_buffer_time 5 \&#xA;--preserved_segments_outside_live_window 24 --time_shift_buffer_depth 40 \&#xA;--allow_codec_switching --allow_approximate_segment_timeline --log_file_generation_deletion \&#xA;--mpd_output $OUTPUT/$output_mpd.mpd &amp;&#xA;

    &#xA;

    Looking at the mpd generated as a result of packaging, the duration of the audio is twice that of the video, and the number of segments is half.&#xA;The following is the content of mpd:

    &#xA;

    &lt;?xml version="1.0" encoding="UTF-8"?>&#xA;&#xA;<mpd xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-live:2011" minbuffertime="PT5S" type="dynamic" publishtime="2021-03-23T10:01:57Z" availabilitystarttime="2021-03-23T09:59:55Z" minimumupdateperiod="PT5S" timeshiftbufferdepth="PT40S">&#xA;<period start="PT0S">&#xA;<adaptationset contenttype="audio" segmentalignment="true">&#xA;<representation bandwidth="140020" codecs="mp4a.40.2" mimetype="audio/mp4" audiosamplingrate="48000">&#xA;<audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>&#xA;<segmenttemplate timescale="90000" initialization="/home/test/timing_logic/package/audio/0/audio.mp4" media="/home/test/timing_logic/package/audio/0/$Time$.m4a" startnumber="16">&#xA;<segmenttimeline>&#xA;<s t="6751436" d="449280"></s>&#xA;<s t="7200716" d="451200"></s>&#xA;<s t="7651916" d="449280"></s>&#xA;<s t="8101196" d="374400"></s>&#xA;<s t="8551196" d="449280"></s>&#xA;<s t="9000476" d="451200"></s>&#xA;<s t="9451674" d="449280"></s>&#xA;<s t="9900956" d="449280"></s>&#xA;<s t="10350236" d="451200"></s>&#xA;<s t="10801434" d="374400"></s>&#xA;</segmenttimeline>&#xA;</segmenttemplate>&#xA;</representation>&#xA;</adaptationset>&#xA;<adaptationset contenttype="video" width="3840" height="2160" framerate="90000/3600" segmentalignment="true" par="16:9">&#xA;<representation bandwidth="1520392" codecs="hvc1.2.4.L153" mimetype="video/mp4" sar="1:1">&#xA;<segmenttemplate timescale="90000" initialization="/home/test/timing_logic/package/video/0/video.mp4" media="/home/test/timing_logic/package/video/0/$Time$.m4s" startnumber="19">&#xA;<segmenttimeline>&#xA;<s t="16954440" d="900000" r="4"></s>&#xA;</segmenttimeline>&#xA;</segmenttemplate>&#xA;</representation>&#xA;</adaptationset>&#xA;</period>&#xA;</mpd>&#xA;

    &#xA;

    When looking at the MPD, it seems that the shaka packager checks the PTS or DTS of the TS when creating a segment and recording the contents of the SegmentTimeline.&#xA;But I couldn't understand even by looking at the MPEG standard documentation and the DASH-IF documentation.

    &#xA;

    My question is whether the packager refers to PTS or DTS when creating a segment.&#xA;How are SegmentTimeline's S@t and S@d recorded?&#xA;What algorithm is the SegmentTimeline recorded with? Please help me. Thank you.

    &#xA;

  • h264 encoding of bgr images into .mp4 file with libav

    10 February 2021, by xyfix

    I'm trying to encode(h264) a series of .png into a mp4 file. A cv::Mat holds the png data (BGR) and that is converted to YUV420P which is then encoded and written to a .mp4 file. I have added two block statements in the code to store images on the disk (before and after encoding). The first image before it gets encoded is correct but the second one after encoding is not. The avcodec_send_frame returns 0 so up to that point everything works.&#xA;Edit : I get an mp4 file of 1 MB but I can't open it with vlc&#xA;ecodec.h

    &#xA;

    class ECodec&#xA;{&#xA;public:&#xA;&#xA;    MovieCodec();&#xA;&#xA;    ~MovieCodec();&#xA;&#xA;    void MatToFrame( cv::Mat&amp; image );&#xA;&#xA;    void encode( AVFrame *frame, AVPacket *pkt );&#xA;&#xA;private:&#xA; &#xA;    FILE* m_file;&#xA;&#xA;    AVCodec* m_encoder = NULL;&#xA;&#xA;    AVCodecContext* m_codecContextOut = NULL;&#xA;&#xA;    AVPacket* m_packet = NULL;&#xA;&#xA;};&#xA;

    &#xA;

    ecodec.cpp

    &#xA;

    ECodec::ECodec() :&#xA;//    m_encoder( avcodec_find_encoder_by_name( videoCodec.c_str()))&#xA;    m_encoder( avcodec_find_encoder( AV_CODEC_ID_H264 ))&#xA;{&#xA;    m_file = fopen( "c:\\tmp\\outputVideo.mp4", "wb");&#xA;}&#xA;&#xA;&#xA;&#xA;void ECodec::MatToFrame( cv::Mat&amp; image )&#xA;{&#xA;    int ret( 0 );&#xA;    int frameRate( 24 );&#xA;    AVFrame *frame = NULL;&#xA;&#xA;    m_encoder( avcodec_find_encoder( AV_CODEC_ID_H264 ))&#xA;    m_codecContextOut = avcodec_alloc_context3( m_encoder );&#xA;&#xA;    m_codecContextOut->width = 800;&#xA;    m_codecContextOut->height = 640;&#xA;    m_codecContextOut->bit_rate = 400000;//m_codecContextOut->width * m_codecContextOut->height * 3;&#xA;    m_codecContextOut->time_base = (AVRational){1, 24};&#xA;    m_codecContextOut->framerate = (AVRational){24, 1};&#xA;    m_codecContextOut->codec_tag = AV_CODEC_ID_H264;&#xA;    m_codecContextOut->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    m_codecContextOut->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    m_codecContextOut->gop_size = 1;&#xA;    m_codecContextOut->max_b_frames = 1;&#xA;&#xA;    av_log_set_level(AV_LOG_VERBOSE);&#xA;&#xA;    ret = av_opt_set(m_codecContextOut->priv_data, "preset", "slow", 0);&#xA;&#xA;    ret = avcodec_open2(m_codecContextOut, m_encoder, NULL);&#xA;&#xA;    frame = av_frame_alloc();&#xA;&#xA;    frame->format = AV_PIX_FMT_YUV420P;&#xA;    frame->width = image.cols();&#xA;    frame->height = image.rows();&#xA;&#xA;&#xA;    ret = av_image_alloc(frame->data, frame->linesize, frame->width,  frame->height, AV_PIX_FMT_YUV420P, 1);&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        return;&#xA;    }&#xA;&#xA;    struct SwsContext *sws_ctx;&#xA;    sws_ctx = sws_getContext((int)image.cols(), (int)image.rows(), AV_PIX_FMT_RGB24,&#xA;                             (int)image.cols(), (int)image.rows(), AV_PIX_FMT_YUV420P,&#xA;                             0, NULL, NULL, NULL);&#xA;&#xA;    const uint8_t* rgbData[1] = { (uint8_t* )image.getData() };&#xA;    int rgbLineSize[1] = { 3 * image.cols() };&#xA;&#xA;    sws_scale(sws_ctx, rgbData, rgbLineSize, 0, image.rows(), frame->data, frame->linesize);&#xA;&#xA;    frame->pict_type = AV_PICTURE_TYPE_I;&#xA;&#xA;cv::Mat yuv420p(frame->height &#x2B; frame->height/2, frame->width, CV_8UC1,frame->data[0]);&#xA;cv::Mat cvmIm;&#xA;cv::cvtColor(yuv420p,cvmIm,CV_YUV420p2BGR);&#xA;cv::imwrite("c:\\tmp\\rawimage.png", cvmIm);&#xA;//OK&#xA;&#xA;    m_packet = av_packet_alloc();&#xA;    ret = av_new_packet( m_packet, m_codecContextOut->width * m_codecContextOut->height * 3 );&#xA;&#xA;    /* encode the image */&#xA;    encode( frame, m_packet );&#xA;&#xA;&#xA;    avcodec_free_context(&amp;m_codecContextOut);&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free( &amp;m_packet );&#xA;}&#xA;&#xA;&#xA;&#xA;&#xA;void ECodec::encode( AVFrame *frame, AVPacket *pkt )&#xA;{&#xA;    int ret;&#xA;    &#xA;    /* send the frame to the encoder */&#xA;    ret = avcodec_send_frame( m_codecContextOut, frame);&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        fprintf(stderr, "Error sending a frame for encoding\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    do&#xA;    {&#xA;        ret = avcodec_receive_packet(m_codecContextOut, pkt);&#xA;        if (ret == 0)&#xA;        {&#xA;&#xA;cv::Mat yuv420p(frame->height &#x2B; frame->height/2, frame->width, CV_8UC1,pkt->data);&#xA;cv::Mat cvmIm;&#xA;cv::cvtColor(yuv420p,cvmIm,CV_YUV420p2BGR);&#xA;cv::imwrite("c:\\tmp\\rawencodedimage.png", cvmIm);&#xA;//NOT OK&#xA;            fwrite(pkt->data, 1, pkt->size, m_file );&#xA;            av_packet_unref(pkt);&#xA;&#xA;            break;&#xA;        }&#xA;        else if ((ret &lt; 0) &amp;&amp; (ret != AVERROR(EAGAIN)))&#xA;        {&#xA;            return;&#xA;        }&#xA;        else if (ret == AVERROR(EAGAIN))&#xA;        {&#xA;             ret = avcodec_send_frame(m_codecContextOut, NULL);&#xA;             if (0 > ret)&#xA;             {&#xA;                 return;&#xA;             }&#xA;        }&#xA;    } while (ret == 0);&#xA;}&#xA;

    &#xA;