Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (77)

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

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

  • Gestion de la ferme

    2 mars 2010, par

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

Sur d’autres sites (9923)

  • Some H264-mp4 videos can't be loaded by any non-Chromium based web browser

    3 mai 2020, par Laizrod

    I regularly use ffmpeg to encode some videos, blu-ray etc in mp4 files (encoded in H264 and AAC) in order to be played on web browsers.
Chromium based browsers such as Google Chrome or the new Microsoft Edge can play all of my files flawlessly.
But today I noticed that some video files couldn't be loaded by some web browsers. It looks like they can't be loaded by any non-Chromium based web browser. (Safari, Firefox etc..)

    



    So I decided to check out and compare the specs of files that work with any web browser, and files that doesn't work with non-Chromium based browsers.

    



    There's what I got :

    



      

    • Playable by any web browser :
    • 


    



    General
Complete name                            : /storage/100.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (isom/iso2/avc1/mp41)
File size                                : 624 MiB
Duration                                 : 23 min 54 s
Overall bit rate                         : 3 648 kb/s
Encoded date                             : UTC 2019-10-02 22:15:27
Tagged date                              : UTC 2019-10-02 22:15:27
Writing application                      : HandBrake 1.2.2 2019022300

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 1 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=3, N=24
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 23 min 54 s
Bit rate                                 : 3 481 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 23.976 (24000/1001) FPS
Minimum frame rate                       : 23.974 FPS
Maximum frame rate                       : 23.981 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.070
Stream size                              : 595 MiB (95%)
Encoded date                             : UTC 2019-10-02 22:15:27
Tagged date                              : UTC 2019-10-02 22:15:27
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 23 min 54 s
Bit rate mode                            : Constant
Bit rate                                 : 160 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 27.4 MiB (4%)
Title                                    : Stereo
Language                                 : Japanese
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 2019-10-02 22:15:27
Tagged date                              : UTC 2019-10-02 22:15:27


    



      

    • Unplayable by non-chromium based web browsers :
    • 


    



    General
Complete name                            : /storage/DL/test.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 329 MiB
Duration                                 : 23 min 52 s
Overall bit rate                         : 1 926 kb/s
Writing application                      : Lavf58.20.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 23 min 52 s
Bit rate                                 : 1 792 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.036
Stream size                              : 306 MiB (93%)
Writing library                          : x264 core 155 r2917 0a84d98
Encoding settings                        : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=34 / lookahead_threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
Language                                 : Japanese
Codec configuration box                  : avcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 23 min 52 s
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 21.9 MiB (7%)
Language                                 : Japanese
Default                                  : Yes
Alternate group                          : 1


    



    My knowledge is limited and I'm unable to understand why and which differences are causing my issue.
Can someone identify the problem and help me fix it with ffmpeg ?

    



    Thank you

    


  • FFmpeg Opus choppy sound UPDATED DESCRIPTION

    2 juin 2020, par easy_breezy

    I'm using FFmpeg and try to encode and decode a raw PCM sound to Opus using a built-in FFmpeg "opus" codec. My input samples are raw PCM 8000 Hz 16 bit mono, in AV_SAMPLE_FMT_S16 format. Since Opus requires sample format AV_SAMPLE_FMT_FLTP and sample rate 48000 Hz only, so I resample my samples before encode them.

    



    I have two instances of ResamplerAudio class that does the work of resampling audio samples and has a member of SwrContext, I use the first instance of ResamplerAudio for resampling a raw PCM input audio before encoding and the second for resampling decoded audio to get it's format and sample rate the same as source values of input raw audio.

    



    ResamplerAudio class has a function that init it's SwrContext member like this :

    



    void ResamplerAudio::init(AVCodecContext *codecContext, int inSampleRate, int outSampleRate, AVSampleFormat inSampleFmt, AVSampleFormat outSampleFmt)
{
    swrContext = swr_alloc();
    if (!swrContext)
    {
        LOGE(TAG, "[init] Couldn't allocate swr context");
        return;
    }

    av_opt_set_int(swrContext, "in_channel_layout", (int64_t) codecContext->channel_layout, 0);
    av_opt_set_int(swrContext, "out_channel_layout", (int64_t) codecContext->channel_layout,  0);

    av_opt_set_int(swrContext, "in_channel_count", codecContext->channels, 0);
    av_opt_set_int(swrContext, "out_channel_count", codecContext->channels, 0);

    av_opt_set_int(swrContext, "in_sample_rate", inSampleRate, 0);
    av_opt_set_int(swrContext, "out_sample_rate", outSampleRate, 0);

    av_opt_set_sample_fmt(swrContext, "in_sample_fmt", inSampleFmt, 0);
    av_opt_set_sample_fmt(swrContext, "out_sample_fmt", outSampleFmt,  0);

    int ret = swr_init(swrContext);
    if (ret < 0)
    {
        LOGE(TAG, "[init] swr_init error: %s", av_err2str(ret));
        return;
    }

    LOGD(TAG, "[init] success codecContext->channel_layout: %d; inSampleRate: %d; outSampleRate: %d; inSampleFmt: %d; outSampleFmt: %d", (int) codecContext->channel_layout, inSampleRate, outSampleRate, inSampleFmt, outSampleFmt);
}


    



    And I call ResamplerAudio::init function for the first instance of ResamplerAudio (this instance do resamping a raw PCM input audio before encoding and I called it resamplerEncoder) with the following args :

    



    resamplerEncoder->init(contextEncoder, 8000, 48000, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP);


    



    The second instance of ResamplerAudio (this instance do resamping after decoding audio from Opus and I called it resamplerDecoder) I init with the following args :

    



    resamplerDecoder->init(contextDecoder, 48000, 8000, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16);


    



    The function of ResamplerAudio that does resampling looks like this :

    



    std::vector ResamplerAudio::convert(uint8_t **inData, int inSamplesCount, int outChannels, int outFormat)
{
    std::vector result;
    uint8_t *dstData = NULL;
    const int dstNbSamples = swr_get_out_samples(swrContext, inSamplesCount);
    av_samples_alloc(&dstData, NULL, outChannels, dstNbSamples, AVSampleFormat(outFormat), 1);
    int resampledSize = swr_convert(swrContext, &dstData, dstNbSamples, (const uint8_t **)inData, inSamplesCount);
    int dstBufSize = av_samples_get_buffer_size(NULL, outChannels, resampledSize, AVSampleFormat(outFormat), 1);

    if (dstBufSize <= 0) return result;

    std::copy(&dstData[0], &dstData[dstBufSize], std::back_inserter(result));

    return result;
}


    



    And I call ResamplerAudio::convert function before encoding with the following args :

    



    // data - an array of raw pcm audio
// dataLength - the length of data array
// getSamplesCount() - function that calculates samples count
// frameEncode - AVFrame that using for encode audio
std::vector resampledData = resamplerEncoder->convert(&data, getSamplesCount(dataLength, frameEncode->channels, AV_SAMPLE_FMT_S16), frameEncode->channels, frameEncode->format);


    



    getSamplesCount() function looks like this :

    



    getSamplesCount(int bytesCount, int channels, AVSampleFormat format)
{
    return bytesCount / av_get_bytes_per_sample(format) / channels;
}


    



    After that I fill my frameEncode with resampled samples :

    



    memcpy(&frame->data[0][0], &resampledData[0], sizeof(uint8_t) * resampledDataLength);


    



    And pass frameEncode to encoding like this encodeFrame(resampledDataLength) :

    



    void encodeFrame(int dataLength)
{
    /* send the frame for encoding */
    int ret = avcodec_send_frame(contextEncoder, frameEncode);
    if (ret < 0)
    {
        LOGE(TAG, "[encodeFrame] avcodec_send_frame error: %s", av_err2str(ret));
        return;
    }

    /* read all the available output packets (in general there may be any number of them */
    while (ret >= 0)
    {
        ret = avcodec_receive_packet(contextEncoder, packetEncode);
        if (ret < 0 && ret != AVERROR(EAGAIN)) LOGE(TAG, "[encodeFrame] error in avcodec_receive_packet: %s", av_err2str(ret));
        if (ret < 0) break;

        // encodedData - std::vector that stores encoded data
        std::copy(&packetEncode->data[0], &packetEncode->data[dataLength], std::back_inserter(encodedData));
        av_packet_unref(packetEncode);
    }
}


    



    Then I decode my encoded samples and do resampling to get back them in source sample format and sample rate so I call ResamplerAudio::convert function for resamplerDecoder with the following args :

    



    // frameDecode - AVFrame that holds decoded audio
std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);


    



    And result sound is choppy and I also noticed that the decoded array size is bigger than the source array size with raw pcm audio.

    



    Please any ideas what I'm doing wrong ?

    



    UPD 18.05.2020

    



    I tested my resampling logic, I did resampling of raw pcm sound without any encoding and decoding routines. First I tried to convert the sample rate of input sound from 8000 Hz to 48000 Hz than I took resampled samples from step above and convert it's sample rate from 48000 Hz to 8000 Hz and the result sound is perfect and clean, also I did the same steps but I converted not a sample rate but a sample format from AV_SAMPLE_FMT_S16 to AV_SAMPLE_FMT_FLTP and vice versa and again the result sound is perfect and clean, also I got the same result when I coverted both a sample rate and a sample format.
So I assume that the problem of distorted and choppy sound is in my encoding or decoding routine, I think most likely in decoding routine because after decoding I ALWAYS get AVFrame with 960 nb_samples despite what was the size of input sound.

    



    My decoding routine looks like this :

    



    std::vector decode(uint8_t *data, unsigned int dataLength)
{
    decodedData.clear();

    int dataSize = dataLength;

    while (dataSize > 0)
    {
        if (!frameDecode)
        {
            frameDecode = av_frame_alloc();
            if (!frameDecode)
            {
                LOGE(TAG, "[decode] Couldn't allocate the frame");
                return EMPTY_DATA;
            }
        }

        ret = av_parser_parse2(parser, contextDecoder, &packetDecode->data, &packetDecode->size, &data[0], dataSize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
        if (ret < 0) {
            LOGE(TAG, "[decode] av_parser_parse2 error: %s", av_err2str(ret));
            return EMPTY_DATA;
        }

        data += ret;
        dataSize -= ret;

        doDecode();
    }
    return decodedData;
}

void doDecode()
{
    if (packetDecode->size) {
        /* send the packet with the compressed data to the decoder */
        int ret = avcodec_send_packet(contextDecoder, packetDecode);
        if (ret < 0) LOGE(TAG, "[decode] avcodec_send_packet error: %s", av_err2str(ret));

        /* read all the output frames (in general there may be any number of them */
        while (ret >= 0)
        {
            ret = avcodec_receive_frame(contextDecoder, frameDecode);
            if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) LOGE(TAG, "[decode] avcodec_receive_frame error: %s", av_err2str(ret));
            if (ret < 0) break;

            std::vector resampledData = resamplerDecoder->convert(frameDecode->data, frameDecode->nb_samples, frameDecode->channels, AV_SAMPLE_FMT_S16);
            if (!resampledData.size()) continue;
            std::copy(&resampledData.data()[0], &resampledData.data()[resampledData.size()], std::back_inserter(decodedData));
        }
    }
}


    



    UPD 30.05.2020

    



    I decided to refuse to use FFmpeg in my project and use libopus 1.3.1 instead, so I made a wrapper around it and it works fine.

    


  • Taking care of silent priming frames converting mp4 to ts ?

    13 février 2019, par keepitterron
    videoOutputSettings = [
     AVVideoCodecKey: AVVideoCodecH264,
     AVVideoWidthKey: width,
     AVVideoHeightKey: height,
     AVVideoCompressionPropertiesKey: [
       AVVideoAverageBitRateKey: avgBitRate,
       AVVideoExpectedSourceFrameRateKey: fps,
       AVVideoProfileLevelKey: AVVideoProfileLevelH264BaselineAutoLevel
     ]
    ]
    audioOutputSettings = [
     AVFormatIDKey: kAudioFormatMPEG4AAC,
     AVSampleRateKey: 44100,
     AVNumberOfChannelsKey: 2
    ]

    I record a video + audio with AVCaptureSession (screen, camera and mic in OSX) and i encode it with AVAssetWriter (AVFileType.mp4), swapping the writers every 6 seconds.
    Every time a new part is written, a nodeJS app will be notified and using ffmpeg will convert it to ts with

    ffmpeg -y -i generatedFile.mp4 -c copy -copyts -muxdelay 0 -muxpreload 0 outputFile.ts

    I’ll manually write a m3u8 looking like :

    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:7
    #EXT-X-MEDIA-SEQUENCE:0
    #EXT-X-PLAYLIST-TYPE:VOD
    #EXTINF:6.140227,
    11214532343c4cae953d45e94a1660ea-0.ts
    #EXTINF:6.284218,
    11214532343c4cae953d45e94a1660ea-1.ts
    #EXTINF:6.099999999999998,
    11214532343c4cae953d45e94a1660ea-2.ts
    #EXTINF:6.133333,
    11214532343c4cae953d45e94a1660ea-3.ts
    #EXTINF:6.133333,
    11214532343c4cae953d45e94a1660ea-4.ts
    #EXTINF:6.100000000000001,
    11214532343c4cae953d45e94a1660ea-5.ts
    #EXTINF:6.133333,
    11214532343c4cae953d45e94a1660ea-6.ts
    #EXTINF:6.199999999999996,
    11214532343c4cae953d45e94a1660ea-7.ts
    #EXTINF:6.0666670000000025,
    11214532343c4cae953d45e94a1660ea-8.ts
    #EXT-X-ENDLIST

    The issue is : I have audio gaps between parts and I believe is AAC’s priming frames not being handled correctly.
    Am I correct in assuming so ?

    example file

    ❯ afinfo 11.mp4
    File:           11.mp4
    File type ID:   mp4f
    Num Tracks:     1
    ----
    Data format:     2 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
                   no channel layout.
    estimated duration: 6.128617 sec
    audio bytes: 87558
    audio packets: 266
    bit rate: 113407 bits per second
    packet size upper bound: 401
    maximum packet size: 401
    audio data file offset: 577163
    optimized
    audio 270272 valid frames + 2112 priming + 0 remainder = 272384
    format list:
    [ 0] format:      2 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
    Channel layout: Stereo (L R)
    ----

    example file

    ❯ ffprobe -v error -show_format -show_streams 1.mp4
    [STREAM]
    index=0
    codec_name=h264
    codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    profile=Baseline
    codec_type=video
    codec_time_base=1/60
    codec_tag_string=avc1
    codec_tag=0x31637661
    width=1920
    height=1080
    coded_width=1920
    coded_height=1088
    has_b_frames=0
    sample_aspect_ratio=1:1
    display_aspect_ratio=16:9
    pix_fmt=yuv420p
    level=40
    color_range=tv
    color_space=bt709
    color_transfer=bt709
    color_primaries=bt709
    chroma_location=bottom
    field_order=unknown
    timecode=N/A
    refs=1
    is_avc=true
    nal_length_size=4
    id=N/A
    r_frame_rate=30/1
    avg_frame_rate=30/1
    time_base=1/600
    start_pts=3600
    start_time=6.000000
    duration_ts=7260
    duration=12.100000
    bit_rate=4227137
    max_bit_rate=N/A
    bits_per_raw_sample=8
    nb_frames=183
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    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
    DISPOSITION:timed_thumbnails=0
    TAG:creation_time=2019-02-13T13:21:51.000000Z
    TAG:language=und
    TAG:handler_name=Core Media Video
    [/STREAM]
    [STREAM]
    index=1
    codec_name=aac
    codec_long_name=AAC (Advanced Audio Coding)
    profile=LC
    codec_type=audio
    codec_time_base=1/44100
    codec_tag_string=mp4a
    codec_tag=0x6134706d
    sample_fmt=fltp
    sample_rate=44100
    channels=2
    channel_layout=stereo
    bits_per_sample=0
    id=N/A
    r_frame_rate=0/0
    avg_frame_rate=0/0
    time_base=1/44100
    start_pts=272991
    start_time=6.190272
    duration_ts=545352
    duration=12.366259
    bit_rate=115688
    max_bit_rate=128000
    bits_per_raw_sample=N/A
    nb_frames=269
    nb_read_frames=N/A
    nb_read_packets=N/A
    DISPOSITION:default=1
    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
    DISPOSITION:timed_thumbnails=0
    TAG:creation_time=2019-02-13T13:21:51.000000Z
    TAG:language=und
    TAG:handler_name=Core Media Audio
    [/STREAM]
    [FORMAT]
    filename=1.mp4
    nb_streams=2
    nb_programs=0
    format_name=mov,mp4,m4a,3gp,3g2,mj2
    format_long_name=QuickTime / MOV
    start_time=6.000000
    duration=12.366259
    size=3317034
    bit_rate=2145860
    probe_score=100
    TAG:major_brand=mp42
    TAG:minor_version=1
    TAG:compatible_brands=mp41mp42isom
    TAG:creation_time=2019-02-13T13:21:51.000000Z
    [/FORMAT]

    Is there a way I can generate ts files with the encoder delay being taken care of ?