Opened 12 years ago

Closed 12 years ago

#1732 closed defect (invalid)

avienc: inserts too many (>90%) empty packets

Reported by: Andrew Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: avi
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
avienc insert 99% empty packets.

What for a strange code below?
How it is possible to compare the (pkt->dts) to the (avist->)packet_count?

avi_write_packet()
    while(enc->block_align==0 && \
          pkt->dts != AV_NOPTS_VALUE && \
          pkt->dts > avist->packet_count && \
          enc->codec_id != AV_CODEC_ID_XSUB){
        AVPacket empty_packet;

        if( pkt->dts - avist->packet_count > 60000){

How to reproduce:
Apply avienc_show_emtied.diff patch (see attachment).

% ./ffmpeg -rtsp_transport tcp -i 'rtsp://axis1031/axis-media/media.amp?videocodec=mpeg4&audio=0&video=1' -vcodec copy -acodec copy -y /var/tmp/a.avi
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
[rtsp @ 0x996c5e0] Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://axis1031/axis-media/media.amp?videocodec=mpeg4&audio=0&video=1':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.131567, bitrate: N/A
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 30.08 tbr, 90k tbn, 1k tbc
Output #0, avi, to '/var/tmp/a.avi':
  Metadata:
    INAM            : Media Presentation
    ISFT            : Lavf54.27.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 2k tbn, 2k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[avi @ 0x997f780] V: insert 198 empty pkt, total empty 198 from 200, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 397 from 400, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 596 from 600, 99%
[avi @ 0x997f780] V: insert 198 empty pkt, total empty 794 from 799, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 993 from 999, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 1192 from 1199, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 1391 from 1399, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 1590 from 1599, 99%
[avi @ 0x997f780] V: insert 199 empty pkt, total empty 1789 from 1799, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 1851 from 1862, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 1913 from 1925, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 1985 from 1998, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 2048 from 2062, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2110 from 2125, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 2182 from 2198, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 2245 from 2262, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2307 from 2325, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 2379 from 2398, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2441 from 2461, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 2504 from 2525, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2566 from 2588, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 2638 from 2661, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 2701 from 2725, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2763 from 2788, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 2835 from 2861, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 2897 from 2924, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 2960 from 2988, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 3032 from 3061, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3094 from 3124, 99%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 3157 from 3188, 99%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 3229 from 3261, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3291 from 3324, 99%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3353 from 3387, 98%
[avi @ 0x997f780] V: insert 73 empty pkt, total empty 3426 from 3461, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3488 from 3524, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3550 from 3587, 98%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 3622 from 3660, 98%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 3685 from 3724, 98%
V: insert 62 empty pkt, total empty 3747 from 3787, 98%1.86 bitrate=1210.7kbits/s    
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 3819 from 3860, 98%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 3882 from 3924, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 3944 from 3987, 98%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 4016 from 4060, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4078 from 4123, 98%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 4141 from 4187, 98%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 4213 from 4260, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4275 from 4323, 98%
[avi @ 0x997f780] V: insert 63 empty pkt, total empty 4338 from 4387, 98%
[avi @ 0x997f780] V: insert 72 empty pkt, total empty 4410 from 4460, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4472 from 4523, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4534 from 4586, 98%
[avi @ 0x997f780] V: insert 73 empty pkt, total empty 4607 from 4660, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4669 from 4723, 98%
[avi @ 0x997f780] V: insert 62 empty pkt, total empty 4731 from 4786, 98%
V: insert 73 empty pkt, total empty 4804 from 4860, 98%2.39 bitrate=1236.6kbits/s    
frame=   57 fps= 51 q=-1.0 Lsize=     443kB time=00:00:02.43 bitrate=1492.0kbits/s    
video:323kB audio:0kB subtitle:0 global headers:0kB muxing overhead 37.036578%

Attachments (1)

avienc_show_emtied.diff (1.8 KB ) - added by Andrew 12 years ago.

Download all attachments as: .zip

Change History (6)

by Andrew, 12 years ago

Attachment: avienc_show_emtied.diff added

comment:1 by Carl Eugen Hoyos, 12 years ago

Keywords: avi added

Is this only reproducible with network input or also if you use an input file?

comment:2 by Andrew, 12 years ago

Is this only reproducible with network input or also if you use an

input file?

muxing file: insert 1 empty per packet

% ./ffmpeg -i /tmp/7b0de690da55.mp4 -vcodec copy -an -frames 20 -y /var/tmp/a.avi 
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/7b0de690da55.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 1942-06-26 18:41:39
  Duration: 00:00:59.76, start: 0.000000, bitrate: 364 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 464x348, 265 kb/s, 30 fps, 30 tbr, 60 tbn, 60 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 95 kb/s
    Metadata:
      creation_time   : 1942-06-26 18:41:39
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Output #0, avi, to '/var/tmp/a.avi':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    ISFT            : Lavf54.27.100
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 464x348, q=2-31, 265 kb/s, 30 fps, 60 tbn, 60 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 1 from 2, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 2 from 4, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 3 from 6, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 4 from 8, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 5 from 10, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 6 from 12, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 7 from 14, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 8 from 16, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 9 from 18, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 10 from 20, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 11 from 22, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 12 from 24, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 13 from 26, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 14 from 28, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 15 from 30, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 16 from 32, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 17 from 34, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 18 from 36, 50%
[avi @ 0x9ce6340] V: insert 1 empty pkt, total empty 19 from 38, 50%
frame=   20 fps=0.0 q=-1.0 Lsize=      40kB time=00:00:00.65 bitrate= 501.8kbits/s    
video:33kB audio:0kB subtitle:0 global headers:0kB muxing overhead 19.547307%

muxing file with transcoding : have no inserted empty packet

% ./ffmpeg -i /tmp/7b0de690da55.mp4 -vcodec mpeg4 -an -frames 100 -y /var/tmp/a.avi 
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/7b0de690da55.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 1942-06-26 18:41:39
  Duration: 00:00:59.76, start: 0.000000, bitrate: 364 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 464x348, 265 kb/s, 30 fps, 30 tbr, 60 tbn, 60 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 95 kb/s
    Metadata:
      creation_time   : 1942-06-26 18:41:39
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
Output #0, avi, to '/var/tmp/a.avi':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    ISFT            : Lavf54.27.100
    Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 464x348, q=2-31, 200 kb/s, 30 tbn, 30 tbc
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
Press [q] to stop, [?] for help
frame=  100 fps=0.0 q=4.3 Lsize=     181kB time=00:00:03.33 bitrate= 443.8kbits/s    
video:173kB audio:0kB subtitle:0 global headers:0kB muxing overhead 4.600627%

videolinux2 2 avi muxing: - insert 1 empty per packet

% ./ffmpeg -f video4linux2 -i /dev/video0 -vcodec copy -frames 10 -y /var/tmp/a.avi 
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
[video4linux2,v4l2 @ 0x8fd2560] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1347609615.886965, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 tbr, 1000k tbn, 25 tbc
Output #0, avi, to '/var/tmp/a.avi':
  Metadata:
    ISFT            : Lavf54.27.100
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, q=2-31, 165888 kb/s, 50 tbn, 50 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 1 from 2, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 2 from 4, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 3 from 6, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 4 from 8, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 5 from 10, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 6 from 12, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 7 from 14, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 8 from 16, 50%
[avi @ 0x8fcc960] V: insert 1 empty pkt, total empty 9 from 18, 50%
frame=   10 fps=0.0 q=-1.0 Lsize=    8106kB time=00:00:00.38 bitrate=174748.2kbits/s    
video:8100kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.074002%

videolinux2 2 avi muxing with encoding: - have no inserted empty packet

% ./ffmpeg -f video4linux2 -i /dev/video0 -vcodec mjpeg -frames 10 -y /var/tmp/a.avi
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
[video4linux2,v4l2 @ 0xafa8560] Estimating duration from bitrate, this may be inaccurate
Input #0, video4linux2,v4l2, from '/dev/video0':
  Duration: N/A, start: 1347609689.123361, bitrate: 165888 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 720x576, 165888 kb/s, 25 tbr, 1000k tbn, 25 tbc
Output #0, avi, to '/var/tmp/a.avi':
  Metadata:
    ISFT            : Lavf54.27.100
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 720x576, q=2-31, 200 kb/s, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mjpeg)
Press [q] to stop, [?] for help
frame=   10 fps=0.0 q=0.0 Lsize=      93kB time=00:00:00.40 bitrate=1911.4kbits/s    
video:88kB audio:0kB subtitle:0 global headers:0kB muxing overhead 6.610446%

rtsp 2 avi muxing with transcoding: have no inserted empty packet after
first 9 packets

% ./ffmpeg -rtsp_transport tcp -i 'rtsp://axis1031/axis-media/media.amp?videocodec=mpeg4&video=1&audio=0' -vcodec mjpeg -an -y /var/tmp/b.avi
ffmpeg version N-44432-g59db014 Copyright (c) 2000-2012 the FFmpeg developers
  built on Sep 13 2012 19:13:56 with gcc 4.4.5 (Debian 4.4.5-8)
  configuration: --enable-version3 --enable-runtime-cpudetect
  libavutil      51. 73.100 / 51. 73.100
  libavcodec     54. 55.100 / 54. 55.100
  libavformat    54. 27.100 / 54. 27.100
  libavdevice    54.  2.100 / 54.  2.100
  libavfilter     3. 16.103 /  3. 16.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
[rtsp @ 0x9dc35e0] Estimating duration from bitrate, this may be inaccurate
Input #0, rtsp, from 'rtsp://axis1031/axis-media/media.amp?videocodec=mpeg4&video=1&audio=0':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.099878, bitrate: N/A
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 30.08 tbr, 90k tbn, 1k tbc
Output #0, avi, to '/var/tmp/b.avi':
  Metadata:
    INAM            : Media Presentation
    ISFT            : Lavf54.27.100
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30.08 tbn, 30.08 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> mjpeg)
Press [q] to stop, [?] for help
[avi @ 0x9dd67a0] V: insert 1 empty pkt, total empty 1 from 3, 33%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 3 from 6, 50%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 5 from 9, 55%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 7 from 12, 58%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 9 from 15, 60%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 11 from 18, 61%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 13 from 21, 61%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 15 from 24, 62%
[avi @ 0x9dd67a0] V: insert 2 empty pkt, total empty 17 from 27, 62%
frame=  239 fps= 32 q=0.0 Lsize=    2672kB time=00:00:08.50 bitrate=2572.4kbits/s    
video:2660kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.442286%

comment:3 by reimar, 12 years ago

I believe that behaviour is as expected/intended.

Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 2k tbn, 2k tbc

Your stream time base is 2kHz, the only way to handle that for AVI is to have 2000 packets for each second of video. The 2kHz time base is necessary to accurately represent all possible time stamps of the input stream (actually 1 kHz might be enough, but 1 kHz or 2 kHz does not make much of a difference).
If that is not what you want, specify whatever time base/frame rate you want FFmpeg to use.

comment:4 by Andrew, 12 years ago

the only way to handle that for AVI is to have 2000 packets for each second of video.

Yes, You’re quite, it is "feature" the avi format.

comment:5 by Carl Eugen Hoyos, 12 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.