Recherche avancée

Médias (0)

Mot : - Tags -/navigation

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (45)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

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

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

Sur d’autres sites (9117)

  • C++ RTSP Stream recording timebase wrong ffmpeg

    29 juillet 2021, par Tom Baires

    We fetch a camera stream over RTSP (Axis Q1755 H264). And after a random time we a start recording the stream to a file. I check the video file with ffprobe and realise the start time is not the start time of the recording it is the start time of fetch the stream. My Video has a length of 5 seconds and the start time of the video should be 0. But the real starttime of the Video is at second 20. This leads to a an incorrect timebase. (ffmpeg Version 3.3.3)

    


    I try to repair it, but now i have some time the error timebase 1/180000... i marked my changes with the comment (timebase repair logic)

    


    timebase video

    


    ffprobe Output (without timebase repair logic)
The start is higher as the duration, correctly the start is 0 and not 20.080000

    


    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'C:\testvideo.mp4':  
 Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf57.71.100   Duration: 00:00:05.04, start: 20.080000, bitrate: 2675 kb/s
     Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, bt709), 800x450 [SAR 1:1 DAR 16:9], 2670 kb/s, 50.20 fps,
 50 tbr, 180k tbn, 360k tbc (default)
     Metadata:
       handler_name    : VideoHandler


    


    Error after the add of timebase repair logic

    


    


    [mpeg4 @ 00000178fcb12b40] timebase 1/180000 not supported by MPEG 4
standard, the maximum admitted value for the timebase denominator is
65535 Could not open codec 'mpeg4' : Unspecified error Cannot start
recording

    


    


    Here some parts of my code

    


    Start Logic

    


    bool RecordingStreamGrabber::start()
{
    CORE_LOG_INFO(m_logger, "Started RecordingStreamGrabber");
    if (m_thread == NULL)
    {
        if (this->prepareInputStream())
        {
            m_run = true;
            m_thread = new std::thread(RecordingStreamGrabber::run, this);
            return true;
        }
        CORE_LOG_ERROR(m_logger, "Error starting RecrodingStreamGrabber");
        return false;
    }
    return false;
}


    


    Prepare Input/Output Stream

    


    bool RecordingStreamGrabber::prepareInputStream()
{
    CORE_LOG_INFO(m_logger, "Preparing Inputstream for recording: " << m_url);

    m_ifmtctx = avformat_alloc_context();
    interrupt_recording_nostop = false;
    interrupt_recording_timeout = m_timeout; // Timeout in milisekunde
    interrupt_recording_starttime = GetTickCount();
    m_ifmtctx->interrupt_callback = interrupt_timeout_cb;

    if (avformat_open_input(&m_ifmtctx, m_url.c_str(), NULL, NULL) != 0)
    {
        m_ifmtctx = NULL;
        CORE_LOG_ERROR(m_logger, "Error opening recording URL: " << m_url);
        return false;
    }

    interrupt_recording_nostop = true;

    if (avformat_find_stream_info(m_ifmtctx, NULL) < 0)
    {
        CORE_LOG_ERROR(m_logger, "Error finding stream in URL: " << m_url);
        avformat_close_input(&m_ifmtctx);
        m_ifmtctx = NULL;
        return false;
    }

    //search for the first video stream
    m_stream_index = -1;
    for (unsigned int i = 0; i < m_ifmtctx->nb_streams && m_stream_index == -1; i++)
    {
        m_iccx = m_ifmtctx->streams[i]->codec;
        if (m_iccx->codec_type == AVMEDIA_TYPE_VIDEO)
        {
            m_istream = m_ifmtctx->streams[i];
            m_stream_index = i;
        }
    }

    if (m_stream_index == -1)
    {
        CORE_LOG_ERROR(m_logger, "Could not find video stream in URL: " << m_url);
        avformat_close_input(&m_ifmtctx);
        m_ifmtctx = NULL;
        return false;
    }

    return true;
}

bool RecordingStreamGrabber::prepareOutputStream()
{
    if (m_ofmtctx)
    {
        CORE_LOG_DEBUG(m_logger, "Close outputfile: " << m_targetfile);
        avformat_free_context(m_ofmtctx);
        m_ofmtctx = NULL;
    }

    m_ofmt = av_guess_format(NULL, m_targetfile.c_str(), NULL);

    m_ofmtctx = avformat_alloc_context();

    m_ofmtctx->oformat = m_ofmt;

    if (avio_open2(&m_ofmtctx->pb, m_targetfile.c_str(), AVIO_FLAG_WRITE, NULL, NULL) != 0)
    {
        avformat_free_context(m_ofmtctx);
        m_ofmtctx = NULL;
        CORE_LOG_ERROR(m_logger, "Error opening outputfile: " << m_targetfile);
        return false;
    }

    m_ostream = avformat_new_stream(m_ofmtctx, NULL);

    avcodec_copy_context(m_ostream->codec, m_iccx);

    m_ostream->sample_aspect_ratio.num = m_iccx->sample_aspect_ratio.num;
    m_ostream->sample_aspect_ratio.den = m_iccx->sample_aspect_ratio.den;

    /* time base: this is the fundamental unit of time (in seconds) in terms
    of which frame timestamps are represented. for fixed-fps content,
    timebase should be 1/framerate and timestamp increments should be
    identically 1. */
    m_ostream->time_base.num = m_iccx->time_base.num;
    m_ostream->time_base.den = m_iccx->time_base.den;

    avformat_write_header(m_ofmtctx, NULL);

#ifdef WIN32
    sprintf_s(m_ofmtctx->filename, sizeof(m_ofmtctx->filename), "%s", m_targetfile.c_str());
#else
    snprintf(m_ofmtctx->filename, sizeof(m_ofmtctx->filename), "%s", m_targetfile.c_str());
#endif
    return true;
}


    


    Recording Logic

    


    void RecordingStreamGrabber::run(RecordingStreamGrabber *_this)
{
    AVPacket packet;
    av_init_packet(&packet);
    int i = 0;
    bool startFrame = true;
    bool keyFrame = false;
    int64_t pts, dts;
    _this->m_tailWritten = true;
    while (_this->m_run)
    {
        if (av_read_frame(_this->m_ifmtctx, &packet) >= 0)
        {
            if ((packet.flags & AV_PKT_FLAG_KEY) == AV_PKT_FLAG_KEY)
            {
                keyFrame = true;
                CORE_LOG_DEBUG(_this->m_logger, "Detected key frame: " << i << "");
            }

            if (_this->m_record)
            {
                if (packet.stream_index == _this->m_stream_index)
                {
                    packet.stream_index = _this->m_ostream->id;

                    if (_this->m_tailWritten == false || keyFrame == true)
                    {
                        //#####################################
                        //timebase repair logic (my changes)
                        //#####################################
                        AVStream *in_stream;
                        AVStream *out_stream;

                        in_stream = _this->m_ifmtctx->streams[packet.stream_index];
                        out_stream = _this->m_ofmtctx->streams[packet.stream_index];

                        if (startFrame)
                        {
                            pts = packet.pts;
                            dts = packet.dts;
                            startFrame = false;
                        }
                        packet.pts -= pts;
                        packet.dts -= dts;

                        packet.pts = av_rescale_q_rnd(packet.pts, in_stream->time_base, out_stream->time_base, (AVRounding)((int)AV_ROUND_NEAR_INF | (int)AV_ROUND_PASS_MINMAX));
                        packet.dts = av_rescale_q_rnd(packet.dts, in_stream->time_base, out_stream->time_base, (AVRounding)((int)AV_ROUND_NEAR_INF | (int)AV_ROUND_PASS_MINMAX));

                        packet.duration = av_rescale_q(packet.duration, in_stream->time_base, out_stream->time_base);
                        //end of my changes
                        
                        av_interleaved_write_frame(_this->m_ofmtctx, &packet);
                        _this->m_tailWritten = false;
                    }
                }
            }
            else if (_this->m_ofmtctx)
            {
                if (_this->m_tailWritten == false)
                {
                    av_write_trailer(_this->m_ofmtctx);
                    avio_close(_this->m_ofmtctx->pb);
                }
                avformat_free_context(_this->m_ofmtctx);
                _this->m_tailWritten = true;
                _this->m_ofmtctx = NULL;
                startFrame = true;
            }
            i++;
            keyFrame = false;
        }
        av_free_packet(&packet);
        av_init_packet(&packet);
    }
    if (_this->m_record)
    {
        av_write_trailer(_this->m_ofmtctx);
        avio_close(_this->m_ofmtctx->pb);
    }
    if (_this->m_ofmtctx)
    {
        avformat_free_context(_this->m_ofmtctx);
        _this->m_ofmtctx = NULL;
    }
    _this->m_record = false;

    avformat_close_input(&_this->m_ifmtctx);
    _this->m_ifmtctx = NULL;
}


    


    Other question
How can I check whether my project uses the deprecated api (answer of @berak) ?

    


  • convert mp4 to m4a using ffmpeg in android

    30 novembre 2017, par abdulrahman

    I’m trying to add the ability to compress video files in my project. However, I tried to extract the Audio from the original video file using FFMPEG Library before compressing it. The command line was

    -i video.mp4 -c:a aac -b:a 160k target.m4a

    After the encoding was done I noticed that the output is still a video file but with a difference in the size. This brought two questions to me and I would like to know their answers.

    1 - can the ".m4a" file be considered as a video file ?

    2 - can I use this command line to compress video files ?

    Best regards

    Log after executing the command

    <p>

    success load
    started encoding
    ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 4.8 (GCC)
      configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
      libavutil      55. 17.103 / 55. 17.103
      libavcodec     57. 24.102 / 57. 24.102
      libavformat    57. 25.100 / 57. 25.100
      libavdevice    57.  0.101 / 57.  0.101
      libavfilter     6. 31.100 /  6. 31.100
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/tempVid.mp4':
      Metadata:
        major_brand     : 3gp4
        minor_version   : 0
        compatible_brands: isom3gp4
        creation_time   : 2017-11-30 03:22:41
        com.android.version: 6.0.1
      Duration: 00:00:19.80, start: 0.000000, bitrate: 4246 kb/s
        Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 176x144, 4112 kb/s, SAR 1:1 DAR 11:9, 29.94 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
        Metadata:
          rotate          : 270
          creation_time   : 2017-11-30 03:22:41
          handler_name    : VideoHandle
        Side data:
          displaymatrix: rotation of 90.00 degrees
        Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
        Metadata:
          creation_time   : 2017-11-30 03:22:41
         handler_name    : SoundHandle
    [libx264 @ 0xb5bc4400] using SAR=1/1
    [libx264 @ 0xb5bc4400] using cpu capabilities: none!
    [libx264 @ 0xb5bc4400] profile High, level 1.1
    [libx264 @ 0xb5bc4400] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=5 lookahead_threads=1 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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    [aac @ 0xb5bc4c00] Too many bits 20480.000000 > 6144 per frame requested, clamping to max
    Output #0, ipod, to '/storage/emulated/0/target.m4a':
      Metadata:
        major_brand     : 3gp4
        minor_version   : 0
        compatible_brands: isom3gp4
        com.android.version: 6.0.1
        encoder         : Lavf57.25.100
        Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 144x176 [SAR 1:1 DAR 9:11], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
        Metadata:
          handler_name    : VideoHandle
         creation_time   : 2017-11-30 03:22:41
          encoder         : Lavc57.24.102 libx264
       Side data:
          unknown side data type 10 (24 bytes)
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s (default)
        Metadata:
          creation_time   : 2017-11-30 03:22:41
          handler_name    : SoundHandle
          encoder         : Lavc57.24.102 aac
     Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (amr_nb (amrnb) -> aac (native))
    Press [q] to stop, [?] for help
    frame=   47 fps=0.0 q=0.0 size=       0kB time=00:00:00.76 bitrate=   0.5kbits/s speed=1.53x    
    frame=   69 fps= 68 q=29.0 size=      12kB time=00:00:01.79 bitrate=  56.3kbits/s speed=1.77x    
    frame=   88 fps= 57 q=29.0 size=      22kB time=00:00:02.30 bitrate=  76.5kbits/s speed=1.49x    
    frame=  110 fps= 54 q=29.0 size=      31kB time=00:00:02.81 bitrate=  89.9kbits/s speed=1.37x    
    frame=  118 fps= 45 q=29.0 size=      34kB time=00:00:03.84 bitrate=  71.5kbits/s speed=1.47x    
    frame=  144 fps= 46 q=29.0 size=      44kB time=00:00:03.84 bitrate=  93.7kbits/s speed=1.23x    
    frame=  150 fps= 41 q=29.0 size=      48kB time=00:00:04.86 bitrate=  80.6kbits/s speed=1.34x    
    frame=  178 fps= 42 q=29.0 size=      62kB time=00:00:04.86 bitrate= 105.2kbits/s speed=1.16x    
    frame=  185 fps= 39 q=29.0 size=      67kB time=00:00:05.88 bitrate=  93.4kbits/s speed=1.25x    
    frame=  206 fps= 40 q=29.0 size=      78kB time=00:00:05.88 bitrate= 108.5kbits/s speed=1.13x    
    frame=  214 fps= 37 q=29.0 size=      84kB time=00:00:06.91 bitrate=  99.8kbits/s speed=1.21x    
    frame=  238 fps= 38 q=29.0 size=     100kB time=00:00:06.91 bitrate= 118.0kbits/s speed=1.11x    
    frame=  249 fps= 37 q=29.0 size=     106kB time=00:00:07.93 bitrate= 109.3kbits/s speed=1.18x    
    frame=  268 fps= 37 q=29.0 size=     119kB time=00:00:08.19 bitrate= 119.1kbits/s speed=1.13x    
    frame=  279 fps= 36 q=29.0 size=     127kB time=00:00:08.96 bitrate= 116.4kbits/s speed=1.16x    
    frame=  298 fps= 36 q=29.0 size=     140kB time=00:00:09.21 bitrate= 124.4kbits/s speed=1.11x    
    frame=  308 fps= 35 q=29.0 size=     149kB time=00:00:09.98 bitrate= 122.3kbits/s speed=1.14x    
    frame=  328 fps= 35 q=29.0 size=     162kB time=00:00:10.24 bitrate= 129.5kbits/s speed= 1.1x    
    frame=  343 fps= 35 q=29.0 size=     172kB time=00:00:10.88 bitrate= 129.2kbits/s speed=1.11x    
    frame=  358 fps= 35 q=29.0 size=     180kB time=00:00:11.90 bitrate= 124.0kbits/s speed=1.15x    
    frame=  387 fps= 36 q=29.0 size=     195kB time=00:00:11.90 bitrate= 134.1kbits/s speed=1.09x    
    frame=  398 fps= 35 q=29.0 size=     202kB time=00:00:12.92 bitrate= 127.9kbits/s speed=1.14x    
    frame=  418 fps= 35 q=29.0 size=     213kB time=00:00:13.31 bitrate= 131.3kbits/s speed=1.12x    
    frame=  432 fps= 35 q=29.0 size=     222kB time=00:00:13.95 bitrate= 130.3kbits/s speed=1.13x    
    frame=  448 fps= 35 q=29.0 size=     230kB time=00:00:14.59 bitrate= 129.0kbits/s speed=1.13x    
    frame=  469 fps= 35 q=29.0 size=     242kB time=00:00:14.97 bitrate= 132.5kbits/s speed=1.11x    
    frame=  478 fps= 34 q=29.0 size=     247kB time=00:00:15.87 bitrate= 127.6kbits/s speed=1.14x    
    frame=  509 fps= 35 q=29.0 size=     259kB time=00:00:16.00 bitrate= 132.8kbits/s dup=1 drop=0 speed=1.11x    
    frame=  525 fps= 35 q=29.0 size=     266kB time=00:00:17.02 bitrate= 127.8kbits/s dup=1 drop=0 speed=1.13x    
    frame=  539 fps= 35 q=29.0 size=     271kB time=00:00:17.79 bitrate= 124.5kbits/s dup=1 drop=0 speed=1.15x    
    frame=  564 fps= 35 q=29.0 size=     285kB time=00:00:18.04 bitrate= 129.4kbits/s dup=1 drop=0 speed=1.13x    
    frame=  574 fps= 35 q=29.0 size=     290kB time=00:00:19.07 bitrate= 124.8kbits/s dup=1 drop=0 speed=1.15x    
    frame=  590 fps= 35 q=29.0 size=     297kB time=00:00:19.45 bitrate= 125.2kbits/s dup=1 drop=0 speed=1.14x    
    frame=  594 fps= 33 q=-1.0 Lsize=     328kB time=00:00:19.84 bitrate= 135.2kbits/s dup=1 drop=0 speed= 1.1x    
    video:246kB audio:70kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.381132%
    [libx264 @ 0xb5bc4400] frame I:3     Avg QP:22.61  size:  4103
    [libx264 @ 0xb5bc4400] frame P:230   Avg QP:25.04  size:   851
    [libx264 @ 0xb5bc4400] frame B:361   Avg QP:28.82  size:   121
    [libx264 @ 0xb5bc4400] consecutive B-frames:  1.2% 40.7% 37.9% 20.2%
    [libx264 @ 0xb5bc4400] mb I  I16..4:  4.0% 49.8% 46.1%
    [libx264 @ 0xb5bc4400] mb P  I16..4:  0.1%  0.3%  0.2%  P16..4: 52.0% 27.1% 15.1%  0.0%  0.0%    skip: 5.3%
    [libx264 @ 0xb5bc4400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 43.4%  2.1%  0.3%  direct: 1.7%  skip:52.5%  L0:39.3% L1:55.4% BI: 5.3%
    [libx264 @ 0xb5bc4400] 8x8 transform intra:51.7% inter:57.7%
    [libx264 @ 0xb5bc4400] coded y,uvDC,uvAC intra: 81.9% 93.5% 80.4% inter: 11.9% 40.0% 17.4%
    [libx264 @ 0xb5bc4400] i16 v,h,dc,p: 11% 25%  7% 57%
    [libx264 @ 0xb5bc4400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 20% 16%  6% 11%  5% 20%  6%  9%
    [libx264 @ 0xb5bc4400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 22% 14%  5% 10%  7% 19%  5%  7%
    [libx264 @ 0xb5bc4400] i8c dc,h,v,p: 61% 18% 10% 10%
    [libx264 @ 0xb5bc4400] Weighted P-Frames: Y:24.3% UV:22.2%
    [libx264 @ 0xb5bc4400] ref P L0: 57.6% 14.3% 16.8%  8.9%  2.3%
    [libx264 @ 0xb5bc4400] ref B L0: 76.3% 19.1%  4.6%
    [libx264 @ 0xb5bc4400] ref B L1: 91.9%  8.1%
    [libx264 @ 0xb5bc4400] kb/s:101.58
    [aac @ 0xb5bc4c00] Qavg: 64130.668
    success ffmpeg
    end encoding
    ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
                                                               built with gcc 4.8 (GCC)
                                                               configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                               libavutil      55. 17.103 / 55. 17.103
                                                               libavcodec     57. 24.102 / 57. 24.102
                                                               libavformat    57. 25.100 / 57. 25.100
                                                               libavdevice    57.  0.101 / 57.  0.101
                                                               libavfilter     6. 31.100 /  6. 31.100
                                                               libswscale      4.  0.100 /  4.  0.100
                                                               libswresample   2.  0.101 /  2.  0.101
                                                               libpostproc    54.  0.100 / 54.  0.100
                                                             Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/tempVid.mp4':
                                                               Metadata:
                                                                 major_brand     : 3gp4
                                                                 minor_version   : 0
                                                                 compatible_brands: isom3gp4
                                                                 creation_time   : 2017-11-30 03:22:41
                                                                 com.android.version: 6.0.1
                                                               Duration: 00:00:19.80, start: 0.000000, bitrate: 4246 kb/s
                                                                 Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 176x144, 4112 kb/s, SAR 1:1 DAR 11:9, 29.94 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
                                                                 Metadata:
                                                                   rotate          : 270
                                                                   creation_time   : 2017-11-30 03:22:41
                                                                   handler_name    : VideoHandle
                                                                 Side data:
                                                                   displaymatrix: rotation of 90.00 degrees
                                                                 Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
                                                                 Metadata:
                                                                   creation_time   : 2017-11-30 03:22:41
                                                                   handler_name    : SoundHandle
                                                             [libx264 @ 0xb5bc4400] using SAR=1/1
                                                             [libx264 @ 0xb5bc4400] using cpu capabilities: none!
                                                             [libx264 @ 0xb5bc4400] profile High, level 1.1
                                                             [libx264 @ 0xb5bc4400] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=5 lookahead_threads=1 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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
                                                             [aac @ 0xb5bc4c00] Too many bits 20480.000000 > 6144 per frame requested, clamping to max
                                                             Output #0, ipod, to '/storage/emulated/0/target.m4a':
                                                               Metadata:
                                                                 major_brand     : 3gp4
                                                                 minor_version   : 0
                                                                 compatible_brands: isom3gp4
                                                                 com.android.version: 6.0.1
                                                                 encoder         : Lavf57.25.100
                                                                 Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 144x176 [SAR 1:1 DAR 9:11], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
                                                                 Metadata:
                                                                   handler_name    : VideoHandle
                                                                   creation_time   : 2017-11-30 03:22:41
                                                                   encoder         : Lavc57.24.102 libx264
                                                                 Side data:
                                                                   unknown side data type 10 (24 bytes)
                                                                 Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s (default)
                                                                 Metadata:
                                                                   creation_time   : 2017-11-30 03:22:41
                                                                   handler_name    : SoundHandle
                                                                   encoder         : Lavc57.24.102 aac
                                                             Stream mapping:
                                                               Stream #0:0 -> #0:0 (h26

    </p>
  • C flags which gives priority to quality for decoded images in ffmpeg

    18 janvier 2016, par Tank2005

    I’m trying to decode h.264 streaming with ffmpeg(latest version) on Android NDK.

    I succeeded to get a decoded frame. But, an aquired image is very dirty even if low latency flag is disabled.

    If I want to give priority to quality over decoding speed, which flags should I specify ?

    bool initCodec(bool low_latency)
    {
       av_register_all();

       codec = avcodec_find_decoder(AV_CODEC_ID_H264);
       if(!codec) return false;

       context = avcodec_alloc_context3(codec);
       if(!context) return false;

       if(codec->capabilities &amp; CODEC_CAP_TRUNCATED) context->flags |= CODEC_FLAG_TRUNCATED;
       if(low_latency == true) context->flags |= CODEC_FLAG_LOW_DELAY;

       frame = av_frame_alloc();

       int res = avcodec_open2(context, codec, NULL);
       if (res &lt; 0) {
           qDebug() &lt;&lt; "Coundn't open codec :" &lt;&lt; res;
           return false;
       }

       av_init_packet(&amp;avpkt);
       return true;
    }

    void sendBytes(unsigned char *buf, int buflen)
    {
       avpkt.size = buflen;
       avpkt.data = buf;

       int got_frame, len;
       while (avpkt.size > 0) {
           len = avcodec_decode_video2(context, frame, &amp;got_frame, &amp;avpkt);
           if (len &lt; 0) {
               qDebug() &lt;&lt; "Error while decoding : " &lt;&lt; len;
               break;
           }
           if (got_frame) {
               onGotFrame(frame);
           }
           avpkt.size -= len;
           avpkt.data += len;
       }
    }

    Decoded image sample

    Ex : I heard that it made a problem while compiling the library. So I write a compile option here(I built it on OpenSUSE Linux).

    #!/bin/bash
    NDK=/home/ndk
    SYSROOT=$NDK/platforms/android-9/arch-arm/
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
    function build_one
    {
    ./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --disable-encoders \
    --disable-decoders \
    --enable-decoder=h264 \
    --enable-decoder=aac \
    --disable-protocols \
    --disable-demuxers \
    --disable-muxers \
    --disable-filters \
    --disable-network \
    --disable-parsers \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-asm --enable-yasm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -marm -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
    --extra-ldflags="-Wl,--fix-cortex-a8" \
    $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    }
    CPU=armv7-a
    PREFIX=$(pwd)/android/$CPU
    build_on