Recherche avancée

Médias (91)

Autres articles (88)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • MediaSPIP Player : problèmes potentiels

    22 février 2011, par

    Le lecteur ne fonctionne pas sur Internet Explorer
    Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
    Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)

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

Sur d’autres sites (10993)

  • Accessing RTSP Server hosted on AWS over internet

    27 juillet 2018, par Kishor V

    I am trying to access my EC2 Ubuntu instance from AWS using gaminganywhere (gaminganywhere.org). The security group policy is to allow all connections, but couldn’t connect to the server. Here is the log from the client and server.

    Client

    # [7860] 1522686205.894230 # include: config/common/controller.conf
    # [7860] 1522686205.894569 # include: config/common/video-x264.conf
    # [7860] 1522686205.894755 # include: config/common/audio-lame.conf
    # [7860] 1522686205.895002 # RTSP[config]: using 'udp' for RTP flows.
    # [7860] 1522686205.895012 # RTSP[config]: controller port = 8555
    # [7860] 1522686205.895016 # RTSP[config]: controller via 'udp' protocol.
    # [7860] 1522686205.895058 # RTSP[config]: video-encoder = libx264 (libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
    # [7860] 1522686205.895071 # RTSP[config]: audio-encoder = libmp3lame (libmp3lame MP3 (MPEG audio layer 3))
    # [7860] 1522686205.895101 # RTSP[config]: video specific option: threads = auto
    Remote server @ 18.188.161.135[18.188.161.135]:8554
    # [7860] 1522686205.971505 SDL: prefer opengl hardware renderer.
    # [7860] 1522686205.971532 controller queue: initialized size=32708 (481 units)
    # [7860] 1522686205.971693 controller socket: socket address [18.188.161.135:8555]
    # [7860] 1522686205.971727 controller client-thread started: tid=7863.
    watchdog: launched, waiting for audio/video frames ...
    # [7860] 1522686205.971813 rtspclient: max tolerable video delay disabled.
    *** SAVEFILE: YUV image saved to 'NULL'; timestamp saved to 'NULL'.
    RTP reordering threshold = 300000
    # [7860] 1522686205.971959 qos-measurement: initialized.
    Opening connection to 18.188.161.135, port 8554...
    ...remote connection opened
    Sending request: DESCRIBE rtsp://18.188.161.135:8554/desktop RTSP/1.0
    CSeq: 2
    User-Agent: RTSP Client (LIVE555 Streaming Media v2014.05.27)
    Accept: application/sdp


    Received 619 new bytes of response data.
    Received a complete DESCRIBE response:
    RTSP/1.0 200 OK
    CSeq: 2
    Date: Mon, Apr 02 2018 16:23:26 GMT
    Content-Base: rtsp://10.0.0.73:8554/desktop/
    Content-Type: application/sdp
    Content-Length: 456

    v=0
    o=- 1522685876960515 1 IN IP4 10.0.0.73
    s=GamingAnywhere Server
    i=desktop
    t=0 0
    a=tool:LIVE555 Streaming Media v2014.05.27
    a=type:broadcast
    a=control:*
    a=range:npt=0-
    a=x-qt-text-nam:GamingAnywhere Server
    a=x-qt-text-inf:desktop
    m=video 0 RTP/AVP 96
    c=IN IP4 0.0.0.0
    b=AS:3000
    a=rtpmap:96 H264/90000
    a=fmtp:96 packetization-mode=1;profile-level-id=4D4020;sprop-parameter-sets=Z01AILaAUAIGhAAAAwAEAAADAMI8YMqA,aO88gA==
    a=control:track1

    [URL:"rtsp://10.0.0.73:8554/desktop/"]: Got a SDP description:
    v=0
    o=- 1522685876960515 1 IN IP4 10.0.0.73
    s=GamingAnywhere Server
    i=desktop
    t=0 0
    a=tool:LIVE555 Streaming Media v2014.05.27
    a=type:broadcast
    a=control:*
    a=range:npt=0-
    a=x-qt-text-nam:GamingAnywhere Server
    a=x-qt-text-inf:desktop
    m=video 0 RTP/AVP 96
    c=IN IP4 0.0.0.0
    b=AS:3000
    a=rtpmap:96 H264/90000
    a=fmtp:96 packetization-mode=1;profile-level-id=4D4020;sprop-parameter-sets=Z01AILaAUAIGhAAAAwAEAAADAMI8YMqA,aO88gA==
    a=control:track1

    # [7860] 1522686206.581278 qos-measurement: source #0 added, prefix=-281002320
    video decoder: use decoder h264
    video decoder(0): sprop configured with 'Z01AILaAUAIGhAAAAwAEAAADAMI8YMqA,aO88gA==', decoded-size=36
    SPROP = [ 00 00 00 01 67 4d 40 20 b6 80 50 02 06 84 00 00 03 00 04 00 00 03 00 c2 3c 60 ca 80 00 00 00 01 68 ef 3c 80 ]
    video decoder(0): codec h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
    video decoder(0) initialized (client port 44578)
    [URL:"rtsp://10.0.0.73:8554/desktop/"]: Initiated the "video/H264" subsession (client ports 44578-44579)
    Sending request: SETUP rtsp://10.0.0.73:8554/desktop/track1 RTSP/1.0
    CSeq: 3
    User-Agent: RTSP Client (LIVE555 Streaming Media v2014.05.27)
    Transport: RTP/AVP;unicast;client_port=44578-44579


    Received 212 new bytes of response data.
    Received a complete SETUP response:
    RTSP/1.0 200 OK
    CSeq: 3
    Date: Mon, Apr 02 2018 16:23:26 GMT
    Transport: RTP/AVP;unicast;destination=117.206.20.30;source=10.0.0.73;client_port=44578-44579;server_port=6970-6971
    Session: CBA2E074;timeout=65


    [URL:"rtsp://10.0.0.73:8554/desktop/"]: Set up the "video/H264" subsession (client ports 44578-44579)
    [URL:"rtsp://10.0.0.73:8554/desktop/"]: Created a data sink for the "video/H264" subsession
    Receiver buffer increased to 2097152
    NAT hole punching: fd=11, local-port=44578/44578 server-port=6970
    Sending request: PLAY rtsp://10.0.0.73:8554/desktop/ RTSP/1.0
    CSeq: 4
    User-Agent: RTSP Client (LIVE555 Streaming Media v2014.05.27)
    Session: CBA2E074
    Range: npt=0.000-


    watchdog: initialized, but no frames received ...
    Received 184 new bytes of response data.
    Received a complete PLAY response:
    RTSP/1.0 200 OK
    CSeq: 4
    Date: Mon, Apr 02 2018 16:23:27 GMT
    Range: npt=0.000-
    Session: CBA2E074
    RTP-Info: url=rtsp://10.0.0.73:8554/desktop/track1;seq=32456;rtptime=2677630715


    [URL:"rtsp://10.0.0.73:8554/desktop/"]: Started playing session...
    watchdog: initialized, but no frames received ...
    watchdog: initialized, but no frames received ...
    watchdog: initialized, but no frames received ...
    watchdog: initialized, but no frames received ...
    watchdog: initialized, but no frames received ...
    watchdog: initialized, but no frames received ...

    Server

    # [4432] 1522685876.873593 # include: config/common/server-common.conf
    # [4432] 1522685876.873731 # include: config/common/controller.conf
    # [4432] 1522685876.873810 # include: config/common/video-x264.conf
    # [4432] 1522685876.873882 # include: config/common/video-x264-param.conf
    # [4432] 1522685876.873974 # include: config/common/audio-lame.conf
    # [4432] 1522685876.874060 # RTSP[config]: using 'udp' for RTP flows.
    # [4432] 1522685876.874100 # RTSP[config]: controller port = 8555
    # [4432] 1522685876.874131 # RTSP[config]: controller via 'udp' protocol.
    # [4432] 1522685876.874189 # RTSP[config]: video-encoder = libx264 (libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
    # [4432] 1522685876.874230 # RTSP[config]: audio-encoder = libmp3lame (libmp3lame MP3 (MPEG audio layer 3))
    # [4432] 1522685876.874281 # RTSP[config]: video specific option: b = 3000000
    # [4432] 1522685876.874316 # RTSP[config]: video specific option: g = 48
    # [4432] 1522685876.874348 # RTSP[config]: video specific option: intra-refresh = 1
    # [4432] 1522685876.874378 # RTSP[config]: video specific option: me_method = dia
    # [4432] 1522685876.874410 # RTSP[config]: video specific option: me_range = 16
    # [4432] 1522685876.874440 # RTSP[config]: video specific option: preset = faster
    # [4432] 1522685876.874471 # RTSP[config]: video specific option: profile = main
    # [4432] 1522685876.874501 # RTSP[config]: video specific option: refs = 1
    # [4432] 1522685876.874532 # RTSP[config]: video specific option: slices = 4
    # [4432] 1522685876.874563 # RTSP[config]: video specific option: threads = 4
    # [4432] 1522685876.874594 # RTSP[config]: video specific option: tune = zerolatency
    # [4432] 1522685876.874625 *** Crop disabled.
    # [4432] 1522685876.878908 sink server: live555-rtsp-server registered
    # [4432] 1522685876.878957 key-blocking initialized: 0+0 keys blocked.
    # [4432] 1522685876.879015 sdl_replayer: sizeof(sdlmsg) = 64
    # [4432] 1522685876.879465 sdl replayer: Replay using XTest (version 2.2) for display :0 screen 0, size=1280x1024.
    # [4432] 1522685876.879793 XShm extention version 1.2 with shared pixmaps
    # [4432] 1522685876.879832 X-Window-init: dimension: 1280x1024x8 @ 0/1
    # [4432] 1522685876.879917 dpipe: 'video-0' initialized, 8 frames, framesize = 16384092
    # [4432] 1522685876.913130 video-source: video-0 initialized max-curr-out = (2560x1600)-(1280x1024)-(1280x1024)
    # [4432] 1522685876.914241 Frame converter created: from (1280,1024)[30] -> (1280,1024)[0]
    # [4432] 1522685876.914343 dpipe: 'filter-0' initialized, 8 frames, framesize = 16384092
    # [4432] 1522685876.948463 video encoder: video source #0 from 'filter-0' (1280x1024).
    # [4432] 1522685876.948720 vencoder-init: option b = 3000000
    # [4432] 1522685876.948755 vencoder-init: option g = 48
    # [4432] 1522685876.948783 vencoder-init: option intra-refresh = 1
    # [4432] 1522685876.948811 vencoder-init: option me_method = dia
    # [4432] 1522685876.948839 vencoder-init: option me_range = 16
    # [4432] 1522685876.948867 vencoder-init: option preset = faster
    # [4432] 1522685876.948894 vencoder-init: option profile = main
    # [4432] 1522685876.948921 vencoder-init: option refs = 1
    # [4432] 1522685876.948949 vencoder-init: option slices = 4
    # [4432] 1522685876.948977 vencoder-init: option threads = 4
    # [4432] 1522685876.949004 vencoder-init: option tune = zerolatency
    [libx264 @ 0x9518b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0x9518b40] profile Main, level 3.2
    [libx264 @ 0x9518b40] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=dia subme=4 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=48 keyint_min=4 scenecut=40 intra_refresh=1 rc=abr mbtree=0 bitrate=3000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    # [4432] 1522685876.958913 video encoder: initialized.
    # [4432] 1522685876.959008 video encoder: ffmpeg-video-encoder registered
    # [4432] 1522685876.959137 RGB2YUV filter[4443]: pipe#0 from 'video-0' to 'filter-0' (output-resolution=1280x1024)
    # [4432] 1522685876.959229 video source thread started: tid=4442
    # [4432] 1522685876.959290 controller socket: socket address [0.0.0.0:8555]
    # [4432] 1522685876.959337 controller server started: tid=4441.
    # [4432] 1522685876.960458 encoder: packet queue initialized (3x3145728 bytes)
    # [4432] 1522685876.960516 qos-measurement: initialized.
    # [4432] 1522685876.960587 (Use port 8000 for optional RTSP-over-HTTP tunneling.)
    # [4432] 1522685983.386797 video encdoer: all started (1)
    # [4432] 1522685983.386926 encoder client registered: total 1 clients.
    # [4432] 1522685983.386990 encoder: pktqueue #0 callback registered (0xf55a88a0)
    # [4432] 1522685983.387065 video encoder: h.264/found sps@4(24); pps@32(4)
    # [4432] 1522685983.387118 GAMediaSubsession: video/H264 SPS=0xdcfc346c(24); PPS=0xdcfc356c(4); profile_level_id=4d4020
    # [4432] 1522685983.387191 qos: add sink#1 for H.264, rtpsink=0xdc6061f8
    # [4432] 1522685983.387255 encoder client unregistered: 0 clients left.
    # [4432] 1522685983.387290 encoder: no more clients, quitting ...
    # [4432] 1522685983.387355 video encoding started: tid=4445 1280x1024@24fps, nalbuf_size=15828640, pic_in_size=1966080.
    # [4432] 1522685983.387402 video encoder: thread terminated (tid=4445).
    # [4432] 1522685983.387446 video encdoer: all stopped (1)
    [libx264 @ 0x9518b40] final ratefactor: 23.57
    # [4432] 1522685983.388265 video encoder: deinitialized.
    # [4432] 1522685983.741415 video encoder: video source #0 from 'filter-0' (1280x1024).
    # [4432] 1522685983.741772 vencoder-init: option b = 3000000
    # [4432] 1522685983.741819 vencoder-init: option g = 48
    # [4432] 1522685983.741870 vencoder-init: option intra-refresh = 1
    # [4432] 1522685983.741926 vencoder-init: option me_method = dia
    # [4432] 1522685983.741975 vencoder-init: option me_range = 16
    # [4432] 1522685983.742020 vencoder-init: option preset = faster
    # [4432] 1522685983.742086 vencoder-init: option profile = main
    # [4432] 1522685983.742123 vencoder-init: option refs = 1
    # [4432] 1522685983.742154 vencoder-init: option slices = 4
    # [4432] 1522685983.742188 vencoder-init: option threads = 4
    # [4432] 1522685983.742218 vencoder-init: option tune = zerolatency
    [libx264 @ 0xdc605f40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0xdc605f40] profile Main, level 3.2
    [libx264 @ 0xdc605f40] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=dia subme=4 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=1 keyint=48 keyint_min=4 scenecut=40 intra_refresh=1 rc=abr mbtree=0 bitrate=3000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    # [4432] 1522685983.749123 video encoder: initialized.
    # [4432] 1522685983.749175 video encdoer: all started (1)
    # [4432] 1522685983.749209 encoder client registered: total 1 clients.
    # [4432] 1522685983.749241 encoder: pktqueue #0 callback registered (0xf55a88a0)
    # [4432] 1522685983.749301 video encoder: h.264/found sps@4(24); pps@32(4)
    # [4432] 1522685983.749336 GAMediaSubsession: video/H264 SPS=0xdcfc353c(24); PPS=0xdcfc363c(4); profile_level_id=4d4020
    # [4432] 1522685983.749385 qos: add sink#1 for H.264, rtpsink=0xe3471b60
    # [4432] 1522685983.749480 video encoding started: tid=4454 1280x1024@24fps, nalbuf_size=15828640, pic_in_size=1966080.
    # [4432] 1522685983.775570 first video frame written (pts=0)
    # [4432] 1522686049.085120 encoder client unregistered: 0 clients left.
    # [4432] 1522686049.085221 encoder: no more clients, quitting ...
    # [4432] 1522686049.102929 video encoder: thread terminated (tid=4454).
    # [4432] 1522686049.103052 video encdoer: all stopped (1)
    [libx264 @ 0xdc605f40] frame I:1     Avg QP: 7.00  size:   447
    [libx264 @ 0xdc605f40] frame P:1568  Avg QP: 0.01  size:   216
    [libx264 @ 0xdc605f40] mb I  I16..4: 99.9%  0.0%  0.1%
    [libx264 @ 0xdc605f40] mb P  I16..4:  3.2%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:96.8%
    [libx264 @ 0xdc605f40] final ratefactor: -29.32
    [libx264 @ 0xdc605f40] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
    [libx264 @ 0xdc605f40] i16 v,h,dc,p: 94%  0%  6%  0%
    [libx264 @ 0xdc605f40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%
    [libx264 @ 0xdc605f40] i8c dc,h,v,p: 100%  0%  0%  0%
    [libx264 @ 0xdc605f40] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 0xdc605f40] kb/s:41.58
    # [4432] 1522686049.104181 video encoder: deinitialized.

    I think the IP address in RTSP header is the LAN IP of the device which is causing the making the connection to fail. The same software works fine from the LAN. Any help is appreciated.

  • Video rotating to left by 90 degree when converted using ffmpeg

    15 juillet 2017, par Herdesh Verma

    I developed a below code :

    extern "C"
    {
    #include <libavutil></libavutil>imgutils.h>
    #include <libavutil></libavutil>opt.h>
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavutil></libavutil>mathematics.h>
    #include <libavutil></libavutil>samplefmt.h>
    #include <libavutil></libavutil>timestamp.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libavfilter></libavfilter>avfiltergraph.h>
    #include <libswscale></libswscale>swscale.h>
    }
    #include
    static AVFormatContext *fmt_ctx = NULL;

    static int frame_index = 0;

    static int j = 0, nbytes=0;
    uint8_t *video_outbuf = NULL;
    static AVPacket *pAVPacket=NULL;
    static int value=0;
    static AVFrame *pAVFrame=NULL;
    static AVFrame *outFrame=NULL;
    static AVStream *video_st=NULL;
    static AVFormatContext *outAVFormatContext=NULL;
    static AVCodec *outAVCodec=NULL;
    static AVOutputFormat *output_format=NULL;
    static AVCodecContext *video_dec_ctx = NULL, *audio_dec_ctx;
    static AVCodecContext *outAVCodecContext=NULL;
    static int width, height;
    static enum AVPixelFormat pix_fmt;
    static AVStream *video_stream = NULL, *audio_stream = NULL;
    static const char *src_filename = NULL;
    static const char *video_dst_filename = NULL;
    static const char *audio_dst_filename = NULL;
    static FILE *video_dst_file = NULL;
    static FILE *audio_dst_file = NULL;
    static uint8_t *video_dst_data[4] = {NULL};
    static int      video_dst_linesize[4];
    static int video_dst_bufsize;
    static int video_stream_idx = -1, audio_stream_idx = -1;
    static AVPacket *pkt=NULL;
    static AVPacket *pkt1=NULL;
    static AVFrame *frame = NULL;
    //static AVPacket pkt;
    static int video_frame_count = 0;
    static int audio_frame_count = 0;
    static int refcount = 0;
    AVCodec *codec;
    static struct SwsContext *sws_ctx;
    AVCodecContext *c= NULL;
    int i, out_size, size, x, y, outbuf_size;
    AVFrame *picture;
    uint8_t *outbuf, *picture_buf;
    int video_outbuf_size;
    int w, h;
    AVPixelFormat pixFmt;
    uint8_t *data[4];
    int linesize[4];

    static int open_codec_context(int *stream_idx,
                             AVCodecContext **dec_ctx, AVFormatContext
    *fmt_ctx, enum AVMediaType type)
    {
    int ret, stream_index;
    AVStream *st;
    AVCodec *dec = NULL;
    AVDictionary *opts = NULL;
    ret = av_find_best_stream(fmt_ctx, type, -1, -1, NULL, 0);
    if (ret &lt; 0) {
       printf("Could not find %s stream in input file '%s'\n",
               av_get_media_type_string(type), src_filename);
       return ret;
    } else {
       stream_index = ret;
       st = fmt_ctx->streams[stream_index];
       /* find decoder for the stream */
       dec = avcodec_find_decoder(st->codecpar->codec_id);
       if (!dec) {
           printf("Failed to find %s codec\n",
                   av_get_media_type_string(type));
           return AVERROR(EINVAL);
       }
       /* Allocate a codec context for the decoder */
       *dec_ctx = avcodec_alloc_context3(dec);
       if (!*dec_ctx) {
           printf("Failed to allocate the %s codec context\n",
                   av_get_media_type_string(type));
           return AVERROR(ENOMEM);
       }
       /* Copy codec parameters from input stream to output codec context */
       if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) &lt; 0) {
           printf("Failed to copy %s codec parameters to decoder context\n",
                   av_get_media_type_string(type));
           return ret;
       }
       /* Init the decoders, with or without reference counting */
       av_dict_set(&amp;opts, "refcounted_frames", refcount ? "1" : "0", 0);
       if ((ret = avcodec_open2(*dec_ctx, dec, &amp;opts)) &lt; 0) {
           printf("Failed to open %s codec\n",
                   av_get_media_type_string(type));
           return ret;
       }
       *stream_idx = stream_index;
    }
    return 0;
    }



    int main (int argc, char **argv)
    {
    int ret = 0, got_frame;
    src_filename = argv[1];
    video_dst_filename = argv[2];
    audio_dst_filename = argv[3];
    av_register_all();
    avcodec_register_all();
    printf("Registered all\n");

    /* open input file, and allocate format context */
    if (avformat_open_input(&amp;fmt_ctx, src_filename, NULL, NULL) &lt; 0) {
       printf("Could not open source file %s\n", src_filename);
       exit(1);
    }

    /* retrieve stream information */
    if (avformat_find_stream_info(fmt_ctx, NULL) &lt; 0) {
       printf("Could not find stream information\n");
       exit(1);
    }

    if (open_codec_context(&amp;video_stream_idx, &amp;video_dec_ctx, fmt_ctx,
    AVMEDIA_TYPE_VIDEO) >= 0) {
       video_stream = fmt_ctx->streams[video_stream_idx];
       avformat_alloc_output_context2(&amp;outAVFormatContext, NULL, NULL,
    video_dst_filename);
       if (!outAVFormatContext)
       {
               printf("\n\nError : avformat_alloc_output_context2()");
               return -1;
       }
    }

    if (open_codec_context(&amp;audio_stream_idx, &amp;audio_dec_ctx, fmt_ctx,
    AVMEDIA_TYPE_AUDIO) >= 0) {
       audio_stream = fmt_ctx->streams[audio_stream_idx];
       audio_dst_file = fopen(audio_dst_filename, "wb");
       if (!audio_dst_file) {
           printf("Could not open destination file %s\n", audio_dst_filename);
           ret = 1;
           goto end;
       }
    }
    /* dump input information to stderr */
    av_dump_format(fmt_ctx, 0, src_filename, 0);

    if (!audio_stream &amp;&amp; !video_stream) {
       printf("Could not find audio or video stream in the input, aborting\n");
       ret = 1;
       goto end;
    }

       output_format = av_guess_format(NULL, video_dst_filename, NULL);
       if( !output_format )
       {
        printf("\n\nError : av_guess_format()");
        return -1;
       }

       video_st = avformat_new_stream(outAVFormatContext ,NULL);
       if( !video_st )
       {
               printf("\n\nError : avformat_new_stream()");
         return -1;
       }

       outAVCodecContext = avcodec_alloc_context3(outAVCodec);
       if( !outAVCodecContext )
       {
         printf("\n\nError : avcodec_alloc_context3()");
         return -1;
       }


       outAVCodecContext = video_st->codec;
       outAVCodecContext->codec_id = AV_CODEC_ID_MPEG4;// AV_CODEC_ID_MPEG4; //
    AV_CODEC_ID_H264 // AV_CODEC_ID_MPEG1VIDEO
       outAVCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
       outAVCodecContext->pix_fmt  = AV_PIX_FMT_YUV420P;
       outAVCodecContext->bit_rate = 400000; // 2500000
       outAVCodecContext->width = 1920;
       //outAVCodecContext->width = 500;
       outAVCodecContext->height = 1080;
       //outAVCodecContext->height = 500;
       outAVCodecContext->gop_size = 3;
       outAVCodecContext->max_b_frames = 2;
       outAVCodecContext->time_base.num = 1;
       outAVCodecContext->time_base.den = 30; // 15fps

       if (outAVCodecContext->codec_id == AV_CODEC_ID_H264)
       {
        av_opt_set(outAVCodecContext->priv_data, "preset", "slow", 0);
       }

       outAVCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);
       if( !outAVCodec )
       {
        printf("\n\nError : avcodec_find_encoder()");
        return -1;
       }

       /* Some container formats (like MP4) require global headers to be
    present
          Mark the encoder so that it behaves accordingly. */

       if ( outAVFormatContext->oformat->flags &amp; AVFMT_GLOBALHEADER)
       {
               outAVCodecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
       }

       value = avcodec_open2(outAVCodecContext, outAVCodec, NULL);
       if( value &lt; 0)
       {
               printf("\n\nError : avcodec_open2()");
               return -1;
       }

    /* create empty video file */
       if ( !(outAVFormatContext->flags &amp; AVFMT_NOFILE) )
       {
        if( avio_open2(&amp;outAVFormatContext->pb , video_dst_filename,
    AVIO_FLAG_WRITE ,NULL, NULL) &lt; 0 )
        {
         printf("\n\nError : avio_open2()");
        }
       }

       if(!outAVFormatContext->nb_streams)
       {
               printf("\n\nError : Output file dose not contain any stream");
         return -1;
       }

       /* imp: mp4 container or some advanced container file required header
    information*/
       value = avformat_write_header(outAVFormatContext , NULL);
       if(value &lt; 0)
       {
               printf("\n\nError : avformat_write_header()");
               return -1;
       }

       printf("\n\nOutput file information :\n\n");
       av_dump_format(outAVFormatContext , 0 ,video_dst_filename ,1);


       int flag;
       int frameFinished;


       value = 0;

       pAVPacket = (AVPacket *)av_malloc(sizeof(AVPacket));
       av_init_packet(pAVPacket);

       pAVFrame = av_frame_alloc();
       if( !pAVFrame )
       {
        printf("\n\nError : av_frame_alloc()");
        return -1;
       }

       outFrame = av_frame_alloc();//Allocate an AVFrame and set its fields to
    default values.
       if( !outFrame )
       {
        printf("\n\nError : av_frame_alloc()");
        return -1;
       }

       nbytes = av_image_get_buffer_size(outAVCodecContext-
    >pix_fmt,outAVCodecContext->width,outAVCodecContext->height,32);
       video_outbuf = (uint8_t*)av_malloc(nbytes);
       if( video_outbuf == NULL )
       {
       printf("\n\nError : av_malloc()");
       }


       value = av_image_fill_arrays( outFrame->data, outFrame->linesize,
    video_outbuf , AV_PIX_FMT_YUV420P, outAVCodecContext-
    >width,outAVCodecContext->height,1 ); // returns : the size in bytes
    required for src
       if(value &lt; 0)
       {
       printf("\n\nError : av_image_fill_arrays()");
       }

       SwsContext* swsCtx_ ;

       // Allocate and return swsContext.
       // a pointer to an allocated context, or NULL in case of error
       // Deprecated : Use sws_getCachedContext() instead.
       swsCtx_ = sws_getContext(video_dec_ctx->width,
                               video_dec_ctx->height,
                               video_dec_ctx->pix_fmt,
                               video_dec_ctx->width,
                               video_dec_ctx->height,
                               video_dec_ctx->pix_fmt,
                               SWS_BICUBIC, NULL, NULL, NULL);


       AVPacket outPacket;

       int got_picture;

       while( av_read_frame( fmt_ctx , pAVPacket ) >= 0 )
       {
               if(pAVPacket->stream_index == video_stream_idx)
               {
                       value = avcodec_decode_video2(video_dec_ctx , pAVFrame ,
     &amp;frameFinished , pAVPacket );
                       if( value &lt; 0)
                       {
                               printf("Error : avcodec_decode_video2()");
                       }

                       if(frameFinished)// Frame successfully decoded :)
                       {
                               sws_scale(swsCtx_, pAVFrame->data, pAVFrame-
    >linesize,0, video_dec_ctx->height, outFrame->data,outFrame->linesize);
    //                              sws_scale(swsCtx_, pAVFrame->data, pAVFrame-
    >linesize,0, video_dec_ctx->height, outFrame->data,outFrame->linesize);
                               av_init_packet(&amp;outPacket);
                               outPacket.data = NULL;    // packet data will be
    allocated by the encoder
                               outPacket.size = 0;

                               avcodec_encode_video2(outAVCodecContext ,
    &amp;outPacket ,outFrame , &amp;got_picture);

                               if(got_picture)
                               {
                                       if(outPacket.pts != AV_NOPTS_VALUE)
                                               outPacket.pts =
    av_rescale_q(outPacket.pts, video_st->codec->time_base, video_st-
    >time_base);
                                       if(outPacket.dts != AV_NOPTS_VALUE)
                                               outPacket.dts =
    av_rescale_q(outPacket.dts, video_st->codec->time_base, video_st-
    >time_base);

                                       printf("Write frame %3d (size= %2d)\n",
    j++, outPacket.size/1000);
                                       if(av_write_frame(outAVFormatContext ,
    &amp;outPacket) != 0)
                                       {
                                               printf("\n\nError :
    av_write_frame()");
                                       }

                               av_packet_unref(&amp;outPacket);
                               } // got_picture

                       av_packet_unref(&amp;outPacket);
                       } // frameFinished

               }
       }// End of while-loop

       value = av_write_trailer(outAVFormatContext);
       if( value &lt; 0)
       {
               printf("\n\nError : av_write_trailer()");
       }


       //THIS WAS ADDED LATER
       av_free(video_outbuf);

    end:
       avcodec_free_context(&amp;video_dec_ctx);
       avcodec_free_context(&amp;audio_dec_ctx);
       avformat_close_input(&amp;fmt_ctx);
       if (video_dst_file)
           fclose(video_dst_file);
      if (audio_dst_file)
          fclose(audio_dst_file);
      //av_frame_free(&amp;frame);
      av_free(video_dst_data[0]);
      return ret &lt; 0;
    }

    Problem with above code is that it rotates a video to left by 90 degree.

    Snapshot of video given as input to above program

    Snapshot of output video. It is rotated by 90 degree to left.

    I compiled program using below command :

    g++ -D__STDC_CONSTANT_MACROS -Wall -g ScreenRecorder.cpp -I/home/harry/Documents/compressor/ffmpeg-3.3/ -I/root/android-ndk-r14b/platforms/android-21/arch-x86_64/usr/include/ -c -o ScreenRecorder.o -w

    And linked it using below command :

    g++ -Wall -g ScreenRecorder.o -I/home/harry/Documents/compressor/ffmpeg-3.3/ -I/root/android-ndk-r14b/platforms/android-21/arch-x86_64/usr/include/ -L/usr/lib64 -L/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.7/ -L/home/harry/Documents/compressor/ffmpeg-3.3/ffmpeg-build -L/root/android-ndk-r14b/platforms/android-21/arch-x86_64/usr/lib64 -o ScreenRecorder.exe -lavformat -lavcodec -lavutil -lavdevice -lavfilter -lswscale -lx264 -lswresample -lm -lpthread -ldl -lstdc++ -lc -lrt

    Program is being run using below command :

    ./ScreenRecorder.exe vertical.MOV videoH.mp4 audioH.mp3

    Note :
    - Source video is taken from iphone and is of .mov format.
    - Output video is being stored in .mp4 file.

    Can anyone please tell me why it is rotating video by 90 degree ?

    One thing i noticed in dump is shown below :

     Duration: 00:00:06.04, start: 0.000000, bitrate: 17087 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17014 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
     rotate          : 90
     creation_time   : 2017-07-09T10:56:42.000000Z
     handler_name    : Core Media Data Handler
     encoder         : H.264
    Side data:
     displaymatrix: rotation of -90.00 degrees

    it says displaymatrix: rotation of -90.00 degrees. Is it responsible for rotating video by 90 degree ?

  • Revision ed2dc59c1b : Integral projection based motion estimation This commit introduces a new block

    13 février 2015, par Jingning Han

    Changed Paths :
     Modify /vp9/common/vp9_rtcd_defs.pl


     Modify /vp9/encoder/vp9_avg.c


     Modify /vp9/encoder/vp9_encodeframe.c


     Modify /vp9/encoder/x86/vp9_avg_intrin_sse2.c



    Integral projection based motion estimation

    This commit introduces a new block match motion estimation
    using integral projection measurement. The 2-D block and the nearby
    region is projected onto the horizontal and vertical 1-D vectors,
    respectively. It then runs vector match, instead of block match,
    over the two separate 1-D vectors to locate the motion compensated
    reference block.

    This process is run per 64x64 block to align the reference before
    choosing partitioning in speed 6. The overall CPU cycle cost due
    to this additional 64x64 block match (SSE2 version) takes around 2%
    at low bit-rate rtc speed 6. When strong motion activities exist in
    the video sequence, it substantially improves the partition
    selection accuracy, thereby achieving better compression performance
    and lower CPU cycles.

    The experiments were tested in RTC speed -6 setting :
    cloud 1080p 500 kbps
    17006 b/f, 37.086 dB, 5386 ms ->
    16669 b/f, 37.970 dB, 5085 ms (>0.9dB gain and 6% faster)

    pedestrian_area 1080p 500 kbps
    53537 b/f, 36.771 dB, 18706 ms ->
    51897 b/f, 36.792 dB, 18585 ms (4% bit-rate savings)

    blue_sky 1080p 500 kbps
    70214 b/f, 33.600 dB, 13979 ms ->
    53885 b/f, 33.645 dB, 10878 ms (30% bit-rate savings, 25% faster)

    jimred 400 kbps
    13380 b/f, 36.014 dB, 5723 ms ->
    13377 b/f, 36.087 dB, 5831 ms (2% bit-rate savings, 2% slower)

    Change-Id : Iffdb6ea5b16b77016bfa3dd3904d284168ae649c