Recherche avancée

Médias (0)

Mot : - Tags -/auteurs

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

Autres articles (3)

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Qualité du média après traitement

    21 juin 2013, par

    Le bon réglage du logiciel qui traite les média est important pour un équilibre entre les partis ( bande passante de l’hébergeur, qualité du média pour le rédacteur et le visiteur, accessibilité pour le visiteur ). Comment régler la qualité de son média ?
    Plus la qualité du média est importante, plus la bande passante sera utilisée. Le visiteur avec une connexion internet à petit débit devra attendre plus longtemps. Inversement plus, la qualité du média est pauvre et donc le média devient dégradé voire (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (3589)

  • Decode MP4 h264 RTP Video Stream C++

    26 juin 2022, par laurrrr

    I want to send a mp4 video which is h264 encoded to another C++ Application and get raw video data.

    


    I'm sending rtp packets using ffmpeg using following command :

    


    ffmpeg -re -i video.mp4  -pix_fmt rgb24  -vcodec libx264 -b:v 10506k -bufsize 64000k -r 30.0 -f mp4 -f rtp rtp://192.168.1.101:4500?pkt_size=1316 


    


    and this is ffmpeg output after video has been played :

    


    Output #0, rtp, to 'rtp://192.168.1.101:4500?pkt_size=1316':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(und): Video: h264 (libx264), yuv444p, 1280x720, q=-1--1, 10506 kb/s, 30 fps, 90k tbn, 30 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/10506000 buffer size: 64000000 vbv_delay: -1
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.101
t=0 0
a=tool:libavformat 58.29.100
m=video 4500 RTP/AVP 96
b=AS:10506
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1

frame= 1802 fps= 24 q=-1.0 Lsize=   78043kB time=00:00:59.96 bitrate=10661.4kbits/s speed=0.793x     
video:77209kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.080008%
[libx264 @ 0x55c75bcc0f00] frame I:8     Avg QP:20.85  size:175353
[libx264 @ 0x55c75bcc0f00] frame P:654   Avg QP:24.51  size: 68884
[libx264 @ 0x55c75bcc0f00] frame B:1140  Avg QP:30.52  size: 28604
[libx264 @ 0x55c75bcc0f00] consecutive B-frames: 12.9%  6.1%  6.7% 74.4%
[libx264 @ 0x55c75bcc0f00] mb I  I16..4: 20.2%  0.0% 79.8%
[libx264 @ 0x55c75bcc0f00] mb P  I16..4:  8.5%  0.0% 16.2%  P16..4: 31.2% 22.3% 11.2%  0.0%  0.0%    skip:10.7%
[libx264 @ 0x55c75bcc0f00] mb B  I16..4:  2.3%  0.0%  3.6%  B16..8: 42.1% 21.3%  6.3%  direct: 5.8%  skip:18.5%  L0:53.9% L1:27.7% BI:18.4%
[libx264 @ 0x55c75bcc0f00] coded y,u,v intra: 63.6% 18.5% 5.0% inter: 36.9% 3.5% 1.3%
[libx264 @ 0x55c75bcc0f00] i16 v,h,dc,p: 23% 30% 25% 22%
[libx264 @ 0x55c75bcc0f00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 23% 23%  6%  6%  5%  7%  4%  7%
[libx264 @ 0x55c75bcc0f00] Weighted P-Frames: Y:26.3% UV:10.4%
[libx264 @ 0x55c75bcc0f00] ref P L0: 67.4% 18.1% 10.9%  2.9%  0.7%
[libx264 @ 0x55c75bcc0f00] ref B L0: 97.4%  2.1%  0.5%
[libx264 @ 0x55c75bcc0f00] ref B L1: 98.8%  1.2%
[libx264 @ 0x55c75bcc0f00] kb/s:10529.89


    


    On my C++ Application I'm using a 3rd party rtp library for capturing rtp frames and this is what I get during video stream :

    


    TS = 4178129015 | RTP Payload = 96 | SeqNr = 618 | Len = 25
Payload Data : 
67 f4 0 20 91 9b 28 a 0 b7 42 0 0 3 0 2 0 0 3 0 
78 1e 30 63 2c 
TS = 4178129015 | RTP Payload = 96 | SeqNr = 618 | Len = 5
Payload Data : 
68 eb ec 44 80 
TS = 4178129015 | RTP Payload = 96 | SeqNr = 618 | Len = 760
Payload Data : 
6 5 ff ff f4 dc 45 e9 bd e6 d9 48 b7 96 2c d8 20 d9 23 ee 
ef 78 32 36 34 20 2d 20 63 6f 72 65 20 31 35 35 20 72 32 39 
31 37 20 30 61 38 34 64 39 38 20 2d 20 48 2e 32 36 34 2f 4d 
50 45 47 2d 34 20 41 56 43 20 63 6f 64 65 63 20 2d 20 43 6f 
70 79 6c 65 66 74 20 32 30 30 33 2d 32 30 31 38 20 2d 20 68 
74 74 70 3a 2f 2f 77 77 77 2e 76 69 64 65 6f 6c 61 6e 2e 6f 
72 67 2f 78 32 36 34 2e 68 74 6d 6c 20 2d 20 6f 70 74 69 6f 
6e 73 3a 20 63 61 62 61 63 3d 31 20 72 65 66 3d 33 20 64 65 
62 6c 6f 63 6b 3d 31 3a 30 3a 30 20 61 6e 61 6c 79 73 65 3d 
30 78 31 3a 30 78 31 31 31 20 6d 65 3d 68 65 78 20 73 75 62 
6d 65 3d 37 20 70 73 79 3d 31 20 70 73 79 5f 72 64 3d 31 2e 
30 30 3a 30 2e 30 30 20 6d 69 78 65 64 5f 72 65 66 3d 31 20 
6d 65 5f 72 61 6e 67 65 3d 31 36 20 63 68 72 6f 6d 61 5f 6d 
65 3d 31 20 74 72 65 6c 6c 69 73 3d 31 20 38 78 38 64 63 74 
3d 30 20 63 71 6d 3d 30 20 64 65 61 64 7a 6f 6e 65 3d 32 31 
2c 31 31 20 66 61 73 74 5f 70 73 6b 69 70 3d 31 20 63 68 72 
6f 6d 61 5f 71 70 5f 6f 66 66 73 65 74 3d 34 20 74 68 72 65 
61 64 73 3d 36 20 6c 6f 6f 6b 61 68 65 61 64 5f 74 68 72 65 
61 64 73 3d 31 20 73 6c 69 63 65 64 5f 74 68 72 65 61 64 73 
3d 30 20 6e 72 3d 30 20 64 65 63 69 6d 61 74 65 3d 31 20 69 
6e 74 65 72 6c 61 63 65 64 3d 30 20 62 6c 75 72 61 79 5f 63 
6f 6d 70 61 74 3d 30 20 63 6f 6e 73 74 72 61 69 6e 65 64 5f 
69 6e 74 72 61 3d 30 20 62 66 72 61 6d 65 73 3d 33 20 62 5f 
70 79 72 61 6d 69 64 3d 32 20 62 5f 61 64 61 70 74 3d 31 20 
62 5f 62 69 61 73 3d 30 20 64 69 72 65 63 74 3d 31 20 77 65 
69 67 68 74 62 3d 31 20 6f 70 65 6e 5f 67 6f 70 3d 30 20 77 
65 69 67 68 74 70 3d 32 20 6b 65 79 69 6e 74 3d 32 35 30 20 
6b 65 79 69 6e 74 5f 6d 69 6e 3d 32 35 20 73 63 65 6e 65 63 
75 74 3d 34 30 20 69 6e 74 72 61 5f 72 65 66 72 65 73 68 3d 
30 20 72 63 5f 6c 6f 6f 6b 61 68 65 61 64 3d 34 30 20 72 63 
3d 63 62 72 20 6d 62 74 72 65 65 3d 31 20 62 69 74 72 61 74 
65 3d 31 30 35 30 36 20 72 61 74 65 74 6f 6c 3d 31 2e 30 20 
71 63 6f 6d 70 3d 30 2e 36 30 20 71 70 6d 69 6e 3d 30 20 71 
70 6d 61 78 3d 36 39 20 71 70 73 74 65 70 3d 34 20 76 62 76 
5f 6d 61 78 72 61 74 65 3d 31 30 35 30 36 20 76 62 76 5f 62 
75 66 73 69 7a 65 3d 36 34 30 30 30 20 6e 61 6c 5f 68 72 64 
3d 6e 6f 6e 65 20 66 69 6c 6c 65 72 3d 30 20 69 70 5f 72 61 
74 69 6f 3d 31 2e 34 30 20 61 71 3d 31 3a 31 2e 30 30 0 80 
[rtplib][rtpPkt_Handler]Found a key frame at ts 4178129015

TS = 4178129015 | RTP Payload = 96 | SeqNr = 775 | Len = 203612
TS = 4178141015 | RTP Payload = 96 | SeqNr = 930 | Len = 201080
TS = 4178135015 | RTP Payload = 96 | SeqNr = 1021 | Len = 118373
TS = 4178132015 | RTP Payload = 96 | SeqNr = 1055 | Len = 44227
TS = 4178138015 | RTP Payload = 96 | SeqNr = 1102 | Len = 60864
TS = 4178153015 | RTP Payload = 96 | SeqNr = 1255 | Len = 198229
TS = 4178147015 | RTP Payload = 96 | SeqNr = 1350 | Len = 123610
TS = 4178144015 | RTP Payload = 96 | SeqNr = 1396 | Len = 59191
TS = 4178150015 | RTP Payload = 96 | SeqNr = 1442 | Len = 58868
TS = 4178165015 | RTP Payload = 96 | SeqNr = 1551 | Len = 141741
TS = 4178159015 | RTP Payload = 96 | SeqNr = 1614 | Len = 81817
TS = 4178156015 | RTP Payload = 96 | SeqNr = 1648 | Len = 43884
TS = 4178162015 | RTP Payload = 96 | SeqNr = 1681 | Len = 42230
TS = 4178177015 | RTP Payload = 96 | SeqNr = 1755 | Len = 95284
TS = 4178171015 | RTP Payload = 96 | SeqNr = 1792 | Len = 47881
TS = 4178168015 | RTP Payload = 96 | SeqNr = 1814 | Len = 28005
TS = 4178174015 | RTP Payload = 96 | SeqNr = 1834 | Len = 25660
TS = 4178189015 | RTP Payload = 96 | SeqNr = 1904 | Len = 90654
TS = 4178183015 | RTP Payload = 96 | SeqNr = 1939 | Len = 45065
TS = 4178180015 | RTP Payload = 96 | SeqNr = 1959 | Len = 25709
TS = 4178186015 | RTP Payload = 96 | SeqNr = 1978 | Len = 23450
TS = 4178201015 | RTP Payload = 96 | SeqNr = 2049 | Len = 91892
TS = 4178195015 | RTP Payload = 96 | SeqNr = 2084 | Len = 45078
TS = 4178192015 | RTP Payload = 96 | SeqNr = 2105 | Len = 26696
TS = 4178198015 | RTP Payload = 96 | SeqNr = 2124 | Len = 23850
TS = 4178213015 | RTP Payload = 96 | SeqNr = 2190 | Len = 85902
TS = 4178207015 | RTP Payload = 96 | SeqNr = 2224 | Len = 43719
TS = 4178204015 | RTP Payload = 96 | SeqNr = 2243 | Len = 24694
TS = 4178210015 | RTP Payload = 96 | SeqNr = 2262 | Len = 23765
TS = 4178225015 | RTP Payload = 96 | SeqNr = 2343 | Len = 104406
TS = 4178219015 | RTP Payload = 96 | SeqNr = 2392 | Len = 63009
TS = 4178216015 | RTP Payload = 96 | SeqNr = 2416 | Len = 31117
TS = 4178222015 | RTP Payload = 96 | SeqNr = 2434 | Len = 22376
TS = 4178237015 | RTP Payload = 96 | SeqNr = 2504 | Len = 90636
TS = 4178231015 | RTP Payload = 96 | SeqNr = 2538 | Len = 43938
TS = 4178228015 | RTP Payload = 96 | SeqNr = 2558 | Len = 25073
TS = 4178234015 | RTP Payload = 96 | SeqNr = 2577 | Len = 24516
TS = 4178249015 | RTP Payload = 96 | SeqNr = 2646 | Len = 88641
TS = 4178243015 | RTP Payload = 96 | SeqNr = 2681 | Len = 45242
TS = 4178240015 | RTP Payload = 96 | SeqNr = 2702 | Len = 26106
TS = 4178246015 | RTP Payload = 96 | SeqNr = 2721 | Len = 24228
TS = 4178261015 | RTP Payload = 96 | SeqNr = 2790 | Len = 89584
TS = 4178255015 | RTP Payload = 96 | SeqNr = 2826 | Len = 45774
TS = 4178252015 | RTP Payload = 96 | SeqNr = 2846 | Len = 25992
TS = 4178258015 | RTP Payload = 96 | SeqNr = 2865 | Len = 24716
TS = 4178273015 | RTP Payload = 96 | SeqNr = 2934 | Len = 89608
TS = 4178267015 | RTP Payload = 96 | SeqNr = 2971 | Len = 46979
TS = 4178264015 | RTP Payload = 96 | SeqNr = 2992 | Len = 27101
TS = 4178270015 | RTP Payload = 96 | SeqNr = 3012 | Len = 25055
TS = 4178285015 | RTP Payload = 96 | SeqNr = 3080 | Len = 87833
TS = 4178279015 | RTP Payload = 96 | SeqNr = 3116 | Len = 45751
TS = 4178276015 | RTP Payload = 96 | SeqNr = 3137 | Len = 26313
TS = 4178282015 | RTP Payload = 96 | SeqNr = 3156 | Len = 24665
TS = 4178291015 | RTP Payload = 96 | SeqNr = 3208 | Len = 66681
TS = 4178288015 | RTP Payload = 96 | SeqNr = 3229 | Len = 26074
TS = 4178303015 | RTP Payload = 96 | SeqNr = 3299 | Len = 90940
TS = 4178297015 | RTP Payload = 96 | SeqNr = 3337 | Len = 48731
TS = 4178294015 | RTP Payload = 96 | SeqNr = 3369 | Len = 41596
TS = 4178300015 | RTP Payload = 96 | SeqNr = 3390 | Len = 26159
TS = 4178315015 | RTP Payload = 96 | SeqNr = 3465 | Len = 96905
TS = 4178309015 | RTP Payload = 96 | SeqNr = 3511 | Len = 58885
TS = 4178306015 | RTP Payload = 96 | SeqNr = 3532 | Len = 26598
TS = 4178312015 | RTP Payload = 96 | SeqNr = 3550 | Len = 22520
TS = 4178327015 | RTP Payload = 96 | SeqNr = 3614 | Len = 82414
TS = 4178321015 | RTP Payload = 96 | SeqNr = 3648 | Len = 43939
TS = 4178318015 | RTP Payload = 96 | SeqNr = 3668 | Len = 25528
TS = 4178324015 | RTP Payload = 96 | SeqNr = 3686 | Len = 23091
TS = 4178339015 | RTP Payload = 96 | SeqNr = 3751 | Len = 84627
TS = 4178333015 | RTP Payload = 96 | SeqNr = 3785 | Len = 43869
TS = 4178330015 | RTP Payload = 96 | SeqNr = 3806 | Len = 26256
TS = 4178336015 | RTP Payload = 96 | SeqNr = 3825 | Len = 24184
TS = 4178351015 | RTP Payload = 96 | SeqNr = 3890 | Len = 83748
TS = 4178345015 | RTP Payload = 96 | SeqNr = 3924 | Len = 43836
TS = 4178342015 | RTP Payload = 96 | SeqNr = 3945 | Len = 26086
TS = 4178348015 | RTP Payload = 96 | SeqNr = 3963 | Len = 23001
TS = 4178363015 | RTP Payload = 96 | SeqNr = 4028 | Len = 84626
TS = 4178357015 | RTP Payload = 96 | SeqNr = 4063 | Len = 44595
TS = 4178354015 | RTP Payload = 96 | SeqNr = 4083 | Len = 25859
TS = 4178360015 | RTP Payload = 96 | SeqNr = 4101 | Len = 22622
TS = 4178375015 | RTP Payload = 96 | SeqNr = 4161 | Len = 78088
TS = 4178369015 | RTP Payload = 96 | SeqNr = 4195 | Len = 44047
TS = 4178366015 | RTP Payload = 96 | SeqNr = 4214 | Len = 24542
TS = 4178372015 | RTP Payload = 96 | SeqNr = 4232 | Len = 22894
TS = 4178381015 | RTP Payload = 96 | SeqNr = 4276 | Len = 56471
TS = 4178378015 | RTP Payload = 96 | SeqNr = 4295 | Len = 24404
TS = 4178384015 | RTP Payload = 96 | SeqNr = 4353 | Len = 75515
TS = 4178396015 | RTP Payload = 96 | SeqNr = 4415 | Len = 79455
TS = 4178390015 | RTP Payload = 96 | SeqNr = 4452 | Len = 47364
TS = 4178387015 | RTP Payload = 96 | SeqNr = 4474 | Len = 27695
TS = 4178393015 | RTP Payload = 96 | SeqNr = 4495 | Len = 27081
TS = 4178408015 | RTP Payload = 96 | SeqNr = 4569 | Len = 95325
TS = 4178402015 | RTP Payload = 96 | SeqNr = 4615 | Len = 59411
TS = 4178399015 | RTP Payload = 96 | SeqNr = 4647 | Len = 41437
TS = 4178405015 | RTP Payload = 96 | SeqNr = 4669 | Len = 28354
TS = 4178414015 | RTP Payload = 96 | SeqNr = 4720 | Len = 65840
TS = 4178411015 | RTP Payload = 96 | SeqNr = 4747 | Len = 34226
TS = 4178420015 | RTP Payload = 96 | SeqNr = 4802 | Len = 71528
TS = 4178417015 | RTP Payload = 96 | SeqNr = 4823 | Len = 26761
TS = 4178432015 | RTP Payload = 96 | SeqNr = 4888 | Len = 83339
TS = 4178426015 | RTP Payload = 96 | SeqNr = 4920 | Len = 40835
TS = 4178423015 | RTP Payload = 96 | SeqNr = 4939 | Len = 23688
TS = 4178429015 | RTP Payload = 96 | SeqNr = 4956 | Len = 21807
TS = 4178444015 | RTP Payload = 96 | SeqNr = 5022 | Len = 85391
TS = 4178438015 | RTP Payload = 96 | SeqNr = 5054 | Len = 41269
TS = 4178435015 | RTP Payload = 96 | SeqNr = 5073 | Len = 24672
TS = 4178441015 | RTP Payload = 96 | SeqNr = 5090 | Len = 21854
TS = 4178456015 | RTP Payload = 96 | SeqNr = 5154 | Len = 83320
TS = 4178450015 | RTP Payload = 96 | SeqNr = 5187 | Len = 42363
TS = 4178447015 | RTP Payload = 96 | SeqNr = 5206 | Len = 24737
TS = 4178453015 | RTP Payload = 96 | SeqNr = 5223 | Len = 22089
TS = 4178468015 | RTP Payload = 96 | SeqNr = 5282 | Len = 76070
TS = 4178462015 | RTP Payload = 96 | SeqNr = 5315 | Len = 42528
TS = 4178459015 | RTP Payload = 96 | SeqNr = 5334 | Len = 24044
TS = 4178465015 | RTP Payload = 96 | SeqNr = 5352 | Len = 23265
TS = 4178471015 | RTP Payload = 96 | SeqNr = 5412 | Len = 77301
TS = 4178483015 | RTP Payload = 96 | SeqNr = 5478 | Len = 85933
TS = 4178477015 | RTP Payload = 96 | SeqNr = 5515 | Len = 47230
TS = 4178474015 | RTP Payload = 96 | SeqNr = 5535 | Len = 25610
TS = 4178480015 | RTP Payload = 96 | SeqNr = 5552 | Len = 22000
TS = 4178495015 | RTP Payload = 96 | SeqNr = 5625 | Len = 94404
TS = 4178489015 | RTP Payload = 96 | SeqNr = 5675 | Len = 64617
TS = 4178486015 | RTP Payload = 96 | SeqNr = 5696 | Len = 26179
TS = 4178492015 | RTP Payload = 96 | SeqNr = 5714 | Len = 22167
TS = 4178507015 | RTP Payload = 96 | SeqNr = 5777 | Len = 80743
TS = 4178501015 | RTP Payload = 96 | SeqNr = 5812 | Len = 45236
TS = 4178498015 | RTP Payload = 96 | SeqNr = 5835 | Len = 28904
TS = 4178504015 | RTP Payload = 96 | SeqNr = 5854 | Len = 24198
TS = 4178513015 | RTP Payload = 96 | SeqNr = 5899 | Len = 57574
TS = 4178510015 | RTP Payload = 96 | SeqNr = 5919 | Len = 25511
TS = 4178516015 | RTP Payload = 96 | SeqNr = 5964 | Len = 58529
TS = 4178528015 | RTP Payload = 96 | SeqNr = 6019 | Len = 70689
TS = 4178522015 | RTP Payload = 96 | SeqNr = 6045 | Len = 33240
TS = 4178519015 | RTP Payload = 96 | SeqNr = 6060 | Len = 19501
TS = 4178525015 | RTP Payload = 96 | SeqNr = 6075 | Len = 19503
TS = 4178540015 | RTP Payload = 96 | SeqNr = 6135 | Len = 77926
TS = 4178534015 | RTP Payload = 96 | SeqNr = 6163 | Len = 35622
TS = 4178531015 | RTP Payload = 96 | SeqNr = 6181 | Len = 22316
TS = 4178537015 | RTP Payload = 96 | SeqNr = 6196 | Len = 19279
TS = 4178552015 | RTP Payload = 96 | SeqNr = 6257 | Len = 78483
TS = 4178546015 | RTP Payload = 96 | SeqNr = 6286 | Len = 37405
TS = 4178543015 | RTP Payload = 96 | SeqNr = 6303 | Len = 22036
TS = 4178549015 | RTP Payload = 96 | SeqNr = 6319 | Len = 19656
TS = 4178564015 | RTP Payload = 96 | SeqNr = 6379 | Len = 78060
TS = 4178558015 | RTP Payload = 96 | SeqNr = 6408 | Len = 37508
TS = 4178555015 | RTP Payload = 96 | SeqNr = 6426 | Len = 22218
TS = 4178561015 | RTP Payload = 96 | SeqNr = 6441 | Len = 18979
TS = 4178576015 | RTP Payload = 96 | SeqNr = 6500 | Len = 75989
TS = 4178570015 | RTP Payload = 96 | SeqNr = 6530 | Len = 38004
TS = 4178567015 | RTP Payload = 96 | SeqNr = 6547 | Len = 21787
TS = 4178573015 | RTP Payload = 96 | SeqNr = 6562 | Len = 18969
TS = 4178588015 | RTP Payload = 96 | SeqNr = 6627 | Len = 83366
TS = 4178582015 | RTP Payload = 96 | SeqNr = 6663 | Len = 46304
TS = 4178579015 | RTP Payload = 96 | SeqNr = 6684 | Len = 26835
TS = 4178585015 | RTP Payload = 96 | SeqNr = 6699 | Len = 19021
TS = 4178594015 | RTP Payload = 96 | SeqNr = 6752 | Len = 68186
TS = 4178591015 | RTP Payload = 96 | SeqNr = 6771 | Len = 24380
TS = 4178600015 | RTP Payload = 96 | SeqNr = 6831 | Len = 77136
TS = 4178597015 | RTP Payload = 96 | SeqNr = 6850 | Len = 24150
TS = 4178612015 | RTP Payload = 96 | SeqNr = 6922 | Len = 93448
TS = 4178606015 | RTP Payload = 96 | SeqNr = 6957 | Len = 44424
TS = 4178603015 | RTP Payload = 96 | SeqNr = 6978 | Len = 26159
TS = 4178609015 | RTP Payload = 96 | SeqNr = 6996 | Len = 22294
TS = 4178624015 | RTP Payload = 96 | SeqNr = 7068 | Len = 92843
TS = 4178618015 | RTP Payload = 96 | SeqNr = 7103 | Len = 44945
TS = 4178615015 | RTP Payload = 96 | SeqNr = 7123 | Len = 25716
TS = 4178621015 | RTP Payload = 96 | SeqNr = 7141 | Len = 23051
TS = 4178633015 | RTP Payload = 96 | SeqNr = 7202 | Len = 79105
TS = 4178627015 | RTP Payload = 96 | SeqNr = 7226 | Len = 31208
TS = 4178630015 | RTP Payload = 96 | SeqNr = 7245 | Len = 24539
TS = 4178645015 | RTP Payload = 96 | SeqNr = 7318 | Len = 94486
TS = 4178639015 | RTP Payload = 96 | SeqNr = 7354 | Len = 46353
TS = 4178636015 | RTP Payload = 96 | SeqNr = 7376 | Len = 27837
TS = 4178642015 | RTP Payload = 96 | SeqNr = 7391 | Len = 18464
TS = 4178657015 | RTP Payload = 96 | SeqNr = 7459 | Len = 87444
TS = 4178651015 | RTP Payload = 96 | SeqNr = 7492 | Len = 42915
TS = 4178648015 | RTP Payload = 96 | SeqNr = 7511 | Len = 24244
TS = 4178654015 | RTP Payload = 96 | SeqNr = 7529 | Len = 22765
TS = 4178669015 | RTP Payload = 96 | SeqNr = 7614 | Len = 109811
TS = 4178663015 | RTP Payload = 96 | SeqNr = 7654 | Len = 51149
TS = 4178660015 | RTP Payload = 96 | SeqNr = 7674 | Len = 25790
TS = 4178666015 | RTP Payload = 96 | SeqNr = 7698 | Len = 30557
TS = 4178681015 | RTP Payload = 96 | SeqNr = 7775 | Len = 100006
TS = 4178675015 | RTP Payload = 96 | SeqNr = 7818 | Len = 55775
TS = 4178672015 | RTP Payload = 96 | SeqNr = 7836 | Len = 22547
TS = 4178678015 | RTP Payload = 96 | SeqNr = 7861 | Len = 31820
TS = 4178687015 | RTP Payload = 96 | SeqNr = 7918 | Len = 74185
TS = 4178684015 | RTP Payload = 96 | SeqNr = 7939 | Len = 26901
TS = 4178696015 | RTP Payload = 96 | SeqNr = 8012 | Len = 94094
TS = 4178690015 | RTP Payload = 96 | SeqNr = 8043 | Len = 39379
TS = 4178693015 | RTP Payload = 96 | SeqNr = 8064 | Len = 26557
TS = 4178708015 | RTP Payload = 96 | SeqNr = 8149 | Len = 109681
TS = 4178702015 | RTP Payload = 96 | SeqNr = 8192 | Len = 54915
TS = 4178699015 | RTP Payload = 96 | SeqNr = 8216 | Len = 30514
TS = 4178705015 | RTP Payload = 96 | SeqNr = 8238 | Len = 27367
TS = 4178717015 | RTP Payload = 96 | SeqNr = 8308 | Len = 90131
TS = 4178711015 | RTP Payload = 96 | SeqNr = 8334 | Len = 32961
TS = 4178714015 | RTP Payload = 96 | SeqNr = 8355 | Len = 27081
TS = 4178729015 | RTP Payload = 96 | SeqNr = 8437 | Len = 106749
TS = 4178723015 | RTP Payload = 96 | SeqNr = 8478 | Len = 52274
TS = 4178720015 | RTP Payload = 96 | SeqNr = 8502 | Len = 30586
TS = 4178726015 | RTP Payload = 96 | SeqNr = 8524 | Len = 28276
TS = 4178738015 | RTP Payload = 96 | SeqNr = 8603 | Len = 101756
TS = 4178732015 | RTP Payload = 96 | SeqNr = 8632 | Len = 37331
TS = 4178735015 | RTP Payload = 96 | SeqNr = 8657 | Len = 31258
TS = 4178747015 | RTP Payload = 96 | SeqNr = 8736 | Len = 102742
TS = 4178741015 | RTP Payload = 96 | SeqNr = 8768 | Len = 41296
TS = 4178744015 | RTP Payload = 96 | SeqNr = 8794 | Len = 32827
TS = 4178750015 | RTP Payload = 96 | SeqNr = 8828 | Len = 43353
TS = 4178759015 | RTP Payload = 96 | SeqNr = 8932 | Len = 134339
TS = 4178753015 | RTP Payload = 96 | SeqNr = 8965 | Len = 42271
TS = 4178756015 | RTP Payload = 96 | SeqNr = 8992 | Len = 34494
TS = 4178771015 | RTP Payload = 96 | SeqNr = 9082 | Len = 117077
TS = 4178765015 | RTP Payload = 96 | SeqNr = 9132 | Len = 64136
TS = 4178762015 | RTP Payload = 96 | SeqNr = 9157 | Len = 31835
TS = 4178768015 | RTP Payload = 96 | SeqNr = 9183 | Len = 32990
TS = 4178774015 | RTP Payload = 96 | SeqNr = 9223 | Len = 51844
TS = 4178777015 | RTP Payload = 96 | SeqNr = 9263 | Len = 51143
TS = 4178789015 | RTP Payload = 96 | SeqNr = 9353 | Len = 116785
TS = 4178783015 | RTP Payload = 96 | SeqNr = 9405 | Len = 66992
TS = 4178780015 | RTP Payload = 96 | SeqNr = 9436 | Len = 39209
TS = 4178786015 | RTP Payload = 96 | SeqNr = 9462 | Len = 33617
TS = 4178801015 | RTP Payload = 96 | SeqNr = 9553 | Len = 117615
TS = 4178795015 | RTP Payload = 96 | SeqNr = 9605 | Len = 66893
TS = 4178792015 | RTP Payload = 96 | SeqNr = 9634 | Len = 37267
TS = 4178798015 | RTP Payload = 96 | SeqNr = 9662 | Len = 35443
TS = 4178813015 | RTP Payload = 96 | SeqNr = 9749 | Len = 112092
TS = 4178807015 | RTP Payload = 96 | SeqNr = 9797 | Len = 61440
TS = 4178804015 | RTP Payload = 96 | SeqNr = 9825 | Len = 36268
TS = 4178810015 | RTP Payload = 96 | SeqNr = 9853 | Len = 35378
TS = 4178825015 | RTP Payload = 96 | SeqNr = 9943 | Len = 116165
TS = 4178819015 | RTP Payload = 96 | SeqNr = 9994 | Len = 65623
TS = 4178816015 | RTP Payload = 96 | SeqNr = 10022 | Len = 36234
TS = 4178822015 | RTP Payload = 96 | SeqNr = 10051 | Len = 36878
TS = 4178837015 | RTP Payload = 96 | SeqNr = 10140 | Len = 115073
TS = 4178831015 | RTP Payload = 96 | SeqNr = 10192 | Len = 66763
TS = 4178828015 | RTP Payload = 96 | SeqNr = 10218 | Len = 33436
TS = 4178834015 | RTP Payload = 96 | SeqNr = 10244 | Len = 33796
TS = 4178849015 | RTP Payload = 96 | SeqNr = 10341 | Len = 125177
TS = 4178843015 | RTP Payload = 96 | SeqNr = 10401 | Len = 77900
TS = 4178840015 | RTP Payload = 96 | SeqNr = 10429 | Len = 35232
TS = 4178846015 | RTP Payload = 96 | SeqNr = 10459 | Len = 38179
TS = 4178858015 | RTP Payload = 96 | SeqNr = 10535 | Len = 98892
TS = 4178852015 | RTP Payload = 96 | SeqNr = 10563 | Len = 35531
TS = 4178855015 | RTP Payload = 96 | SeqNr = 10596 | Len = 41990
TS = 4178864015 | RTP Payload = 96 | SeqNr = 10665 | Len = 88820
TS = 4178861015 | RTP Payload = 96 | SeqNr = 10704 | Len = 49955
TS = 4178867015 | RTP Payload = 96 | SeqNr = 10762 | Len = 74508
TS = 4178870015 | RTP Payload = 96 | SeqNr = 10803 | Len = 52987
TS = 4178876015 | RTP Payload = 96 | SeqNr = 10860 | Len = 73161
TS = 4178873015 | RTP Payload = 96 | SeqNr = 10893 | Len = 42383
TS = 4178879015 | RTP Payload = 96 | SeqNr = 10894 | Len = 25
Payload Data : 
67 f4 0 20 91 9b 28 a 0 b7 42 0 0 3 0 2 0 0 3 0 
78 1e 30 63 2c 
TS = 4178879015 | RTP Payload = 96 | SeqNr = 10894 | Len = 5
Payload Data : 
68 eb ec 44 80 
TS = 4178879015 | RTP Payload = 96 | SeqNr = 11034 | Len = 182277

...
TS = 4179620015 | RTP Payload = 96 | SeqNr = 19953 | Len = 17574
TS = 4179626015 | RTP Payload = 96 | SeqNr = 19954 | Len = 25
Payload Data : 
67 f4 0 20 91 9b 28 a 0 b7 42 0 0 3 0 2 0 0 3 0 
78 1e 30 63 2c 
TS = 4179626015 | RTP Payload = 96 | SeqNr = 19954 | Len = 5
Payload Data : 
68 eb ec 44 80 
TS = 4179626015 | RTP Payload = 96 | SeqNr = 20034 | Len = 103235
TS = 4179638015 | RTP Payload = 96 | SeqNr = 20099 | Len = 83915
TS = 4179632015 | RTP Payload = 96 | SeqNr = 20136 | Len = 47878
...
TS = 4180367015 | RTP Payload = 96 | SeqNr = 28375 | Len = 74904
TS = 4180364015 | RTP Payload = 96 | SeqNr = 28397 | Len = 28493
TS = 4180373015 | RTP Payload = 96 | SeqNr = 28439 | Len = 54554
TS = 4180370015 | RTP Payload = 96 | SeqNr = 28459 | Len = 25420
TS = 4180376015 | RTP Payload = 96 | SeqNr = 28460 | Len = 25
Payload Data : 
67 f4 0 20 91 9b 28 a 0 b7 42 0 0 3 0 2 0 0 3 0 
78 1e 30 63 2c 
TS = 4180376015 | RTP Payload = 96 | SeqNr = 28460 | Len = 5
Payload Data : 
68 eb ec 44 80 
TS = 4180376015 | RTP Payload = 96 | SeqNr = 28560 | Len = 129431
TS = 4180388015 | RTP Payload = 96 | SeqNr = 28630 | Len = 90901
TS = 4180382015 | RTP Payload = 96 | SeqNr = 28675 | Len = 57964
TS = 4180379015 | RTP Payload = 96 | SeqNr = 28703 | Len = 35260
...
TS = 4183529015 | RTP Payload = 96 | SeqNr = 62224 | Len = 34771

Total Bytes Received = 79054651
Total Packets  = 1819


    


    After streaming starts I get 1 rtp packet len 25 , 1 rtp packet len 5 and 1 rtp packet len 760. After I received the packet with len 760 I get this message :

    


    [rtplib][rtpPkt_Handler]Found a key frame at ts 4178129015


    


    Can someone please explain to me what this rtp messages with len 25,5 and 760 means and what key frame means in this context ?

    


    Also I have rtp packets of size 5 and 25 in the middle of transmission.

    


    As you can see ffmpeg is saying 1802 frames were sent and Total packets received in C++ Application is 1819 because I receive 8 rtp packets of len 25, 8 rtp packets of len 5 and 1 rtp packet of size 760. If we substract this, it's exactly 1802 frames.

    


    My questions would be :

    


    How to get frame raw pixel data based on rtp packets payload data I receive ? eg. 1280x720 3 Channels ( thats the mp4 video resolution )

    


    Can someone tell me what those packets of len 25,5,760 on the beggining means and packets of len 25,5 in the middle of transmission means ?

    


    Thanks in advance !!!

    


  • Buffered encoded images not saved

    26 mars 2021, par xyfix

    I have an issue with the first 12 images not being saved to file. I have attached the relevant files in this issue. I have also attached a log file to show that the first 12 images aren't written to the file that is generated. The frame rate is 24 fps and the recording is 5 sec, so there should be 120 frames written to the output file. This can be seen in the 4th column. The lines in the log files are as follows :

    


    image num [unique num from camera] [temp image num for recording seq] [time in ms]

    


    The image class is actually a simple wrapper around OpenCV's mat class with some additional members. The output file that I currently get is around 10 MB and when I open it in VLC it doesn't run for 5 seconds but more like 1 - 2 seconds but I can see whatever I have recorded. Can anyone explain to me why the files not written and the duration isn't 5 secs (minus 12 frames missing) as expected . As you can see I have tried with "av_interleaved_write_frame" but that didn't help

    


    xcodec.h

    


    #ifndef XCODEC_H
#define XCODEC_H

#include "image/Image.h"

extern "C"
{
    #include "Codec/include/libavcodec/avcodec.h"
    #include "Codec/include/libavdevice/avdevice.h"
    #include "Codec/include/libavformat/avformat.h"
    #include "Codec/include/libavutil/avutil.h"
    #include "Codec/include/libavformat/avio.h"
    #include "Codec/include/libavutil/imgutils.h"
    #include "Codec/include/libavutil/opt.h"
    #include "Codec/include/libswscale/swscale.h"
}


class XCodec
{
public:

    XCodec(const char *filename);

    ~XCodec();

    void encodeImage( const Image& image );

    void encode( AVFrame *frame, AVPacket *pkt );

    void add_stream();

    void openVideoCodec();

    void write_video_frame(const Image &image);

    void createFrame( const Image& image );

    void close();

private:

    static int s_frameCount;

    int m_timeVideo = 0;

    std::string m_filename;


    AVCodec* m_encoder = NULL;

    AVOutputFormat* m_outputFormat = NULL;

    AVFormatContext* m_formatCtx = NULL;

    AVCodecContext* m_codecCtx = NULL;

    AVStream* m_streamOut = NULL;

    AVFrame* m_frame = NULL;

    AVPacket* m_packet = NULL;

};

#endif


    


    xcodec.cpp

    


    #include "XCodec.h"&#xA;&#xA;#include <qdebug>&#xA;&#xA;&#xA;#define STREAM_DURATION   5.0&#xA;#define STREAM_FRAME_RATE 24&#xA;#define STREAM_NB_FRAMES  ((int)(STREAM_DURATION * STREAM_FRAME_RATE))&#xA;#define STREAM_PIX_FMT    AV_PIX_FMT_YUV420P /* default pix_fmt */&#xA;#define OUTPUT_CODEC AV_CODEC_ID_H264&#xA;&#xA;int XCodec::s_frameCount = 0;&#xA;&#xA;XCodec::XCodec( const char* filename ) :&#xA;    m_filename( filename ),&#xA;    m_encoder( avcodec_find_encoder( OUTPUT_CODEC ))&#xA;{&#xA;    av_log_set_level(AV_LOG_VERBOSE);&#xA;&#xA;    int ret(0);&#xA;&#xA;&#xA;    // allocate the output media context&#xA;    ret = avformat_alloc_output_context2( &amp;m_formatCtx, m_outputFormat, NULL, m_filename.c_str());&#xA;&#xA;    if (!m_formatCtx)&#xA;        return;&#xA;&#xA;    m_outputFormat = m_formatCtx->oformat;&#xA;&#xA;    // Add the video stream using H264 codec&#xA;    add_stream();&#xA;&#xA;    // Open video codec and allocate the necessary encode buffers&#xA;    if (m_streamOut)&#xA;        openVideoCodec();&#xA;&#xA;    // Print detailed information about input and output&#xA;    av_dump_format( m_formatCtx, 0, m_filename.c_str(), 1);&#xA;&#xA;    // Open the output media file, if needed&#xA;    if (!( m_outputFormat->flags &amp; AVFMT_NOFILE))&#xA;    {&#xA;        ret = avio_open( &amp;m_formatCtx->pb, m_filename.c_str(), AVIO_FLAG_WRITE);&#xA;&#xA;        if (ret &lt; 0)&#xA;        {&#xA;            char error[255];&#xA;            ret = av_strerror( ret, error, 255);&#xA;            fprintf(stderr, "Could not open &#x27;%s&#x27;: %s\n", m_filename.c_str(), error);&#xA;            return ;&#xA;        }&#xA;    }&#xA;    else&#xA;    {&#xA;        return;&#xA;    }&#xA;&#xA;    // Write media header&#xA;    ret = avformat_write_header( m_formatCtx, NULL );&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        char error[255];&#xA;        av_strerror(ret, error, 255);&#xA;        fprintf(stderr, "Error occurred when opening output file: %s\n", error);&#xA;        return;&#xA;    }&#xA;&#xA;    if ( m_frame )&#xA;           m_frame->pts = 0;&#xA;}&#xA;&#xA;&#xA;&#xA;XCodec::~XCodec()&#xA;{}&#xA;&#xA;/* Add an output stream. */&#xA;void XCodec::add_stream()&#xA;{&#xA;    AVCodecID codecId = OUTPUT_CODEC;&#xA;&#xA;    if (!( m_encoder ))&#xA;    {&#xA;        fprintf(stderr, "Could not find encoder for &#x27;%s&#x27;\n",&#xA;            avcodec_get_name(codecId));&#xA;        return;&#xA;    }&#xA;&#xA;    // Get the stream for codec&#xA;    m_streamOut = avformat_new_stream(m_formatCtx, m_encoder);&#xA;&#xA;    if (!m_streamOut) {&#xA;        fprintf(stderr, "Could not allocate stream\n");&#xA;        return;&#xA;    }&#xA;&#xA;    m_streamOut->id = m_formatCtx->nb_streams - 1;&#xA;&#xA;    m_codecCtx = avcodec_alloc_context3( m_encoder);&#xA;&#xA;    switch (( m_encoder)->type)&#xA;    {&#xA;    case AVMEDIA_TYPE_VIDEO:&#xA;        m_streamOut->codecpar->codec_id = codecId;&#xA;        m_streamOut->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;        m_streamOut->codecpar->bit_rate = 400000;&#xA;        m_streamOut->codecpar->width = 800;&#xA;        m_streamOut->codecpar->height = 640;&#xA;        m_streamOut->codecpar->format = STREAM_PIX_FMT;&#xA;        m_streamOut->time_base = { 1, STREAM_FRAME_RATE };&#xA;&#xA;        avcodec_parameters_to_context( m_codecCtx, m_streamOut->codecpar);&#xA;&#xA;        m_codecCtx->gop_size = 12; /* emit one intra frame every twelve frames at most */&#xA;        m_codecCtx->max_b_frames = 1;&#xA;        m_codecCtx->time_base = { 1, STREAM_FRAME_RATE };&#xA;        m_codecCtx->framerate = { STREAM_FRAME_RATE, 1 };&#xA;        m_codecCtx->pix_fmt = STREAM_PIX_FMT;&#xA;        m_codecCtx->profile = FF_PROFILE_H264_HIGH;&#xA;&#xA;        break;&#xA;&#xA;    default:&#xA;        break;&#xA;    }&#xA;&#xA;    if (m_streamOut->codecpar->codec_id == OUTPUT_CODEC)&#xA;    {&#xA;      av_opt_set( m_codecCtx, "preset", "ultrafast", 0 );&#xA;    }&#xA;&#xA;/&#xA;//    /* Some formats want stream headers to be separate. */&#xA;    if (m_formatCtx->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;            m_codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;&#xA;&#xA;    int ret = avcodec_parameters_from_context( m_streamOut->codecpar, m_codecCtx );&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        char error[255];&#xA;        av_strerror(ret, error, 255);&#xA;        fprintf(stderr, "avcodec_parameters_from_context returned (%d) - %s", ret, error);&#xA;        return;&#xA;    }&#xA;}&#xA;&#xA;&#xA;void XCodec::openVideoCodec()&#xA;{&#xA;    int ret;&#xA;&#xA;    /* open the codec */&#xA;    ret = avcodec_open2(m_codecCtx, m_encoder, NULL);&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        char error[255];&#xA;        av_strerror(ret, error, 255);&#xA;        fprintf(stderr, "Could not open video codec: %s\n", error);&#xA;        return;&#xA;    }&#xA;&#xA;    /* allocate and init a re-usable frame */&#xA;//    m_frame = av_frame_alloc();&#xA;&#xA;}&#xA;&#xA;&#xA;void XCodec::encodeImage(const Image &amp;image)&#xA;{&#xA;    // Compute video time from last added video frame&#xA;    m_timeVideo = image.timeStamp(); //(double)m_frame->pts) * av_q2d(m_streamOut->time_base);&#xA;&#xA;    // Stop media if enough time&#xA;    if (!m_streamOut /*|| m_timeVideo >= STREAM_DURATION*/)&#xA;       return;&#xA;&#xA;&#xA;    // Add a video frame&#xA;    write_video_frame( image );&#xA;&#xA;}&#xA;&#xA;&#xA;void XCodec::write_video_frame( const Image&amp; image )&#xA;{&#xA;    int ret;&#xA;&#xA;qDebug() &lt;&lt; "image num " &lt;&lt; image.uniqueImageNumber() &lt;&lt; " " &lt;&lt; s_frameCount;&#xA;&#xA;    if ( s_frameCount >= STREAM_NB_FRAMES)&#xA;    {&#xA;        /* No more frames to compress. The codec has a latency of a few&#xA;         * frames if using B-frames, so we get the last frames by&#xA;         * passing the same picture again. */&#xA;        int p( 0 ) ;&#xA;    }&#xA;    else&#xA;    {&#xA;         createFrame( image );&#xA;    }&#xA;&#xA;    // Increase frame pts according to time base&#xA;//    m_frame->pts &#x2B;= av_rescale_q(1, m_codecCtx->time_base, m_streamOut->time_base);&#xA;    m_frame->pts = int64_t( image.timeStamp()) ;&#xA;&#xA;&#xA;    if (m_formatCtx->oformat->flags &amp; 0x0020 )&#xA;    {&#xA;        /* Raw video case - directly store the picture in the packet */&#xA;        AVPacket pkt;&#xA;        av_init_packet(&amp;pkt);&#xA;&#xA;        pkt.flags |= AV_PKT_FLAG_KEY;&#xA;        pkt.stream_index = m_streamOut->index;&#xA;        pkt.data = m_frame->data[0];&#xA;        pkt.size = sizeof(AVPicture);&#xA;&#xA;//        ret = av_interleaved_write_frame(m_formatCtx, &amp;pkt);&#xA;        ret = av_write_frame( m_formatCtx, &amp;pkt );&#xA;    }&#xA;    else&#xA;    {&#xA;        AVPacket pkt;&#xA;        av_init_packet(&amp;pkt);&#xA;&#xA;        /* encode the image */&#xA;        ret = avcodec_send_frame(m_codecCtx, m_frame);&#xA;&#xA;        if (ret &lt; 0)&#xA;        {&#xA;            char error[255];&#xA;            av_strerror(ret, error, 255);&#xA;            fprintf(stderr, "Error encoding video frame: %s\n", error);&#xA;            return;&#xA;        }&#xA;&#xA;        /* If size is zero, it means the image was buffered. */&#xA;        ret = avcodec_receive_packet(m_codecCtx, &amp;pkt);&#xA;&#xA;        if( !ret &amp;&amp; pkt.size)&#xA;        {&#xA;qDebug() &lt;&lt; "write frame " &lt;&lt; m_frame->display_picture_number;&#xA;            pkt.stream_index = m_streamOut->index;&#xA;&#xA;            /* Write the compressed frame to the media file. */&#xA;//            ret = av_interleaved_write_frame(m_formatCtx, &amp;pkt);&#xA;            ret = av_write_frame( m_formatCtx, &amp;pkt );&#xA;        }&#xA;        else&#xA;        {&#xA;            ret = 0;&#xA;        }&#xA;    }&#xA;&#xA;    if (ret != 0)&#xA;    {&#xA;        char error[255];&#xA;        av_strerror(ret, error, 255);&#xA;        fprintf(stderr, "Error while writing video frame: %s\n", error);&#xA;        return;&#xA;    }&#xA;&#xA;    s_frameCount&#x2B;&#x2B;;&#xA;}&#xA;&#xA;&#xA;void XCodec::createFrame( const Image&amp; image /*, AVFrame *m_frame, int frame_index, int width, int height*/)&#xA;{&#xA;    /**&#xA;     * \note allocate frame&#xA;     */&#xA;    m_frame = av_frame_alloc();&#xA;    int ret = av_frame_make_writable( m_frame );&#xA;&#xA;    m_frame->format = STREAM_PIX_FMT;&#xA;    m_frame->width = image.width();&#xA;    m_frame->height = image.height();&#xA;//    m_frame->pict_type = AV_PICTURE_TYPE_I;&#xA;    m_frame->display_picture_number = image.uniqueImageNumber();&#xA;&#xA;    ret = av_image_alloc(m_frame->data, m_frame->linesize, m_frame->width,  m_frame->height, STREAM_PIX_FMT, 1);&#xA;&#xA;    if (ret &lt; 0)&#xA;    {&#xA;        return;&#xA;    }&#xA;&#xA;    struct SwsContext* sws_ctx = sws_getContext((int)image.width(), (int)image.height(), AV_PIX_FMT_RGB24,&#xA;                                                (int)image.width(), (int)image.height(), STREAM_PIX_FMT, 0, NULL, NULL, NULL);&#xA;&#xA;    const uint8_t* rgbData[1] = { (uint8_t* )image.getData() };&#xA;    int rgbLineSize[1] = { 3 * image.width() };&#xA;&#xA;    sws_scale(sws_ctx, rgbData, rgbLineSize, 0, image.height(), m_frame->data, m_frame->linesize);&#xA;&#xA;//cv::Mat yuv420p( m_frame->height &#x2B; m_frame->height/2, m_frame->width, CV_8UC1, m_frame->data[0]);&#xA;//cv::Mat cvmIm;&#xA;//cv::cvtColor(yuv420p,cvmIm,CV_YUV420p2BGR);&#xA;//std::ostringstream ss;&#xA;//ss &lt;&lt; "c:\\tmp\\YUVoriginal_" &lt;&lt; image.uniqueImageNumber() &lt;&lt; ".png";&#xA;//cv::imwrite( ss.str().c_str(), cvmIm);&#xA;}&#xA;&#xA;&#xA;void XCodec::close()&#xA;{&#xA;    /* reset the framecount */&#xA;    s_frameCount = 0 ;&#xA;&#xA;    int ret( 0 );&#xA;&#xA;    /* flush the encoder */&#xA;    while( ret >= 0 )&#xA;        ret = avcodec_send_frame(m_codecCtx, NULL);&#xA;&#xA;    // Write media trailer&#xA;    if( m_formatCtx )&#xA;        ret = av_write_trailer( m_formatCtx );&#xA;&#xA;    /* Close each codec. */&#xA;    if ( m_streamOut )&#xA;    {&#xA;        if( m_frame )&#xA;        {&#xA;            av_free( m_frame->data[0]);&#xA;            av_frame_free( &amp;m_frame );&#xA;        }&#xA;&#xA;        if( m_packet )&#xA;            av_packet_free( &amp;m_packet );&#xA;    }&#xA;&#xA;    if (!( m_outputFormat->flags &amp; AVFMT_NOFILE))&#xA;        /* Close the output file. */&#xA;        ret = avio_close( m_formatCtx->pb);&#xA;&#xA;&#xA;    /* free the stream */&#xA;    avformat_free_context( m_formatCtx );&#xA;&#xA;    fflush( stdout );&#xA;}&#xA;</qdebug>

    &#xA;

    image.h

    &#xA;

    #ifndef IMAGE_H&#xA;#define IMAGE_H&#xA;&#xA;#include  &#xA;&#xA;class Image &#xA;{&#xA;public:&#xA;&#xA;    Image();&#xA;&#xA;    Image( const cv::Mat&amp; mat );&#xA;&#xA;    Image(const Image&amp; other) = default;&#xA;&#xA;    Image(Image&amp;&amp; other) = default;&#xA;&#xA;    ~Image();&#xA;&#xA;&#xA;    inline const cv::Mat&amp; matrix() const{ return m_matrix; }&#xA;&#xA;    inline const int uniqueImageNumber() const{ return m_uniqueId; }&#xA;&#xA;    inline const int timeStamp() const { return m_timeStamp; }&#xA;&#xA;    inline const int width() const { return m_matrix.cols(); }&#xA;    &#xA;    inline const int height() const { return m_matrix.rows(); }&#xA;&#xA;private:&#xA;&#xA;    cv::Mat   m_matrix;&#xA;&#xA;    int       m_timeStamp;&#xA;&#xA;    int       m_uniqueId;&#xA;&#xA;};&#xA;&#xA;#endif&#xA;

    &#xA;

    logtxt

    &#xA;

     image num  1725   0   0&#xA; image num  1727   1   40&#xA; image num  1729   2   84&#xA; image num  1730   3   126&#xA; image num  1732   4   169&#xA; image num  1734   5   211&#xA; image num  1736   6   259&#xA; image num  1738   7   297&#xA; image num  1740   8   340&#xA; image num  1742   9   383&#xA; image num  1744   10   425&#xA; image num  1746   11   467&#xA; image num  1748   12   511&#xA; image num  1750   13   553&#xA; write frame  1750&#xA; image num  1752   14   600&#xA; write frame  1752&#xA; image num  1753   15   637&#xA; write frame  1753&#xA; image num  1755   16   680&#xA; write frame  1755&#xA; image num  1757   17   723&#xA; write frame  1757&#xA; image num  1759   18   766&#xA; write frame  1759&#xA; image num  1761   19   808&#xA; write frame  1761&#xA; image num  1763   20   854&#xA; write frame  1763&#xA; image num  1765   21   893&#xA; write frame  1765&#xA; image num  1767   22   937&#xA; write frame  1767&#xA; image num  1769   23   979&#xA; write frame  1769&#xA; image num  1770   24   1022&#xA; write frame  1770&#xA; image num  1772   25   1064&#xA; write frame  1772&#xA; image num  1774   26   1108&#xA; write frame  1774&#xA; image num  1776   27   1150&#xA; write frame  1776&#xA; image num  1778   28   1192&#xA; write frame  1778&#xA; image num  1780   29   1235&#xA; write frame  1780&#xA; image num  1782   30   1277&#xA; write frame  1782&#xA; image num  1784   31   1320&#xA; write frame  1784&#xA; image num  1786   32   1362&#xA; write frame  1786&#xA; image num  1787   33   1405&#xA; write frame  1787&#xA; image num  1789   34   1450&#xA; write frame  1789&#xA; image num  1791   35   1493&#xA; write frame  1791&#xA; image num  1793   36   1536&#xA; write frame  1793&#xA; image num  1795   37   1578&#xA; write frame  1795&#xA; image num  1797   38   1621&#xA; write frame  1797&#xA; image num  1799   39   1663&#xA; write frame  1799&#xA; image num  1801   40   1709&#xA; write frame  1801&#xA; image num  1803   41   1748&#xA; write frame  1803&#xA; image num  1805   42   1791&#xA; write frame  1805&#xA; image num  1807   43   1833&#xA; write frame  1807&#xA; image num  1808   44   1876&#xA; write frame  1808&#xA; image num  1810   45   1920&#xA; write frame  1810&#xA; image num  1812   46   1962&#xA; write frame  1812&#xA; image num  1814   47   2004&#xA; write frame  1814&#xA; image num  1816   48   2048&#xA; write frame  1816&#xA; image num  1818   49   2092&#xA; write frame  1818&#xA; image num  1820   50   2133&#xA; write frame  1820&#xA; image num  1822   51   2175&#xA; write frame  1822&#xA; image num  1824   52   2221&#xA; write frame  1824&#xA; image num  1826   53   2277&#xA; write frame  1826&#xA; image num  1828   54   2319&#xA; write frame  1828&#xA; image num  1830   55   2361&#xA; write frame  1830&#xA; image num  1832   56   2405&#xA; write frame  1832&#xA; image num  1833   57   2447&#xA; write frame  1833&#xA; image num  1835   58   2491&#xA; write frame  1835&#xA; image num  1837   59   2533&#xA; write frame  1837&#xA; image num  1839   60   2576&#xA; write frame  1839&#xA; image num  1841   61   2619&#xA; write frame  1841&#xA; image num  1843   62   2662&#xA; write frame  1843&#xA; image num  1845   63   2704&#xA; write frame  1845&#xA; image num  1847   64   2746&#xA; write frame  1847&#xA; image num  1849   65   2789&#xA; write frame  1849&#xA; image num  1851   66   2831&#xA; write frame  1851&#xA; image num  1852   67   2874&#xA; write frame  1852&#xA; image num  1854   68   2917&#xA; write frame  1854&#xA; image num  1856   69   2959&#xA; write frame  1856&#xA; image num  1858   70   3003&#xA; write frame  1858&#xA; image num  1860   71   3045&#xA; write frame  1860&#xA; image num  1862   72   3088&#xA; write frame  1862&#xA; image num  1864   73   3130&#xA; write frame  1864&#xA; image num  1866   74   3173&#xA; write frame  1866&#xA; image num  1868   75   3215&#xA; write frame  1868&#xA; image num  1870   76   3257&#xA; write frame  1870&#xA; image num  1872   77   3306&#xA; write frame  1872&#xA; image num  1873   78   3347&#xA; write frame  1873&#xA; image num  1875   79   3389&#xA; write frame  1875&#xA; image num  1877   80   3433&#xA; write frame  1877&#xA; image num  1879   81   3475&#xA; write frame  1879&#xA; image num  1883   82   3562&#xA; write frame  1883&#xA; image num  1885   83   3603&#xA; write frame  1885&#xA; image num  1887   84   3660&#xA; write frame  1887&#xA; image num  1889   85   3704&#xA; write frame  1889&#xA; image num  1891   86   3747&#xA; write frame  1891&#xA; image num  1893   87   3789&#xA; write frame  1893&#xA; image num  1895   88   3832&#xA; write frame  1895&#xA; image num  1897   89   3874&#xA; write frame  1897&#xA; image num  1899   90   3917&#xA; write frame  1899&#xA; image num  1900   91   3959&#xA; write frame  1900&#xA; image num  1902   92   4001&#xA; write frame  1902&#xA; image num  1904   93   4044&#xA; write frame  1904&#xA; image num  1906   94   4086&#xA; write frame  1906&#xA; image num  1908   95   4130&#xA; write frame  1908&#xA; image num  1910   96   4174&#xA; write frame  1910&#xA; image num  1912   97   4216&#xA; write frame  1912&#xA; image num  1914   98   4257&#xA; write frame  1914&#xA; image num  1915   99   4303&#xA; write frame  1915&#xA; image num  1918   100   4344&#xA; write frame  1918&#xA; image num  1919   101   4387&#xA; write frame  1919&#xA; image num  1922   102   4451&#xA; write frame  1922&#xA; image num  1924   103   4494&#xA; write frame  1924&#xA; image num  1926   104   4541&#xA; write frame  1926&#xA; image num  1927   105   4588&#xA; write frame  1927&#xA; image num  1931   106   4665&#xA; write frame  1931&#xA; image num  1933   107   4707&#xA; write frame  1933&#xA; image num  1935   108   4750&#xA; write frame  1935&#xA; image num  1937   109   4794&#xA; write frame  1937&#xA; image num  1939   110   4836&#xA; write frame  1939&#xA; image num  1941   111   4879&#xA; write frame  1941&#xA; image num  1943   112   4922&#xA; write frame  1943&#xA; image num  1945   113   4965&#xA; write frame  1945&#xA; image num  1947   114   5007&#xA; write frame  1947&#xA; image num  1948   115   5050&#xA; write frame  1948&#xA; image num  1950   116   5093&#xA; write frame  1950&#xA; image num  1952   117   5136&#xA; write frame  1952&#xA; image num  1954   118   5178&#xA; write frame  1954&#xA; image num  1956   119   5221&#xA; write frame  1956&#xA; MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;0, 8-bit&#xA;Not writing &#x27;clli&#x27; atom. No content light level info.&#xA;Not writing &#x27;mdcv&#x27; atom. Missing mastering metadata.&#xA; 2 seeks, 41 writeouts&#xA;

    &#xA;

  • ffmpeg http slower than downloading first

    9 août 2017, par Krylic

    When trying to get a clip of a video from a remote source
    Input source :

    ffprobe version 3.3.2-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2017 the FFmpeg developers
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://website.com/video.mp4':
     Metadata:
       major_brand     : mp42
       minor_version   : 0
       compatible_brands: mp42mp41
       creation_time   : 2017-07-13T15:44:58.000000Z
     Duration: 00:57:32.42, start: 0.000000, bitrate: 1939 kb/s
       Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 720x480 [SAR 10:11 DAR 15:11], 1745 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 2017-07-13T15:44:58.000000Z
         handler_name    : Mainconcept MP4 Video Media Handler
         encoder         : AVC Coding
       Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
       Metadata:
         creation_time   : 2017-07-13T15:44:58.000000Z
         handler_name    : Mainconcept MP4 Sound Media Handler

    Current command :
    ffmpeg version 3.3.2-static
    ffmpeg.linux -threads 2 -y -ss 3273 -i "http://website.com/video.mp4" -an -movflags +faststart -preset veryfast -codec copy /outputfolder/trimmed_video.mp4
    This 5m35.102s to create a 45mb 2min file.

    If I download the file using wget it takes 28s and using ffmpeg only takes 0.243s

    If I add -vn OR -an to the output portion of the command it completes the trim in about 2.101s. Meaning it’s faster to download the two stream and merge them myself.

    Can anyone explain this behaviour and why my first command takes so long when on a lot of other video files it’s very fast ?