[FFmpeg-devel] FW: Transport streams with change in channels/sample rate result in huge silence insertion

Sailaja Mahendrakar smahendrakar at rgbnetworks.com
Mon Jan 28 20:15:42 CET 2013


Hi Michael,

I have uploaded the content

incoming/network44-Ad48.ts

to upload.ffmpeg.org.

This transport stream has change with sample rate and channels. Please note the transcoded output with the below command:

./ffmpeg -psnr  -y -loglevel verbose -i ../network44-Ad48.ts -vsync 1 -async 2 -f mpegts -map 0:0 -streamid 0:48 -codec:v:0 mpeg2video -map 0:1 -streamid 0:49 -codec:a:0 mp2 -b:a:0 384000 -ar:a:0 48000 -ac:a:0 2 ../network.ts

There is a silence of 630283 audio samples, getting added at the change in the sample rate, which is in correct and will result in
-       no audio at the transition, when the stream to stream audio transcodes are performed.
-       in-correct audio at the end of the file, in the case of File-to-File transcodes.

This is happening as the s->outpts, variable gets reset to zero whenever there is transition in the sample rate or channels.


-async is forwarded to lavfi similarly to -af aresample=async=2:min_hard_comp=0.100000.
[graph 1 aresample for input stream 0:1 @ 0x17a97c0] chl:2.1 fmt:fltp r:48000Hz -> chl:stereo fmt:s16 r:48000Hz
change in ingest samplerate or channels sr:48000,prev_sr:44100,ch:11,prev_ch:3
[graph 1 aresample for input stream 0:1 @ 0x17a97c0] [SWR @ 0x15ad760] adding 630283 audio samples of silence

The patch I have attached earlier is going to re-calculate the s->outpts at the transition.

Complete ffmpeg log:

./ffmpeg -psnr  -y -loglevel verbose -i ../network44-Ad48.ts -vsync 1 -async 2 -f mpegts -map 0:0 -streamid 0:48 -codec:v:0 mpeg2video -map 0:1 -streamid 0:49 -codec:a:0 mp2 -b:a:0 384000 -ar:a:0 48000 -ac:a:0 2 ../network_wofix.ts
ffmpeg version N-48604-ga572cc8 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jan 25 2013 11:26:50 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-avfilter --enable-nonfree --disable-stripping --disable-ffplay --enable-debug --enable-nonfree --enable-pthreads
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 86.100 / 54. 86.100
  libavformat    54. 59.106 / 54. 59.106
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
[mpeg2video @ 0x15be7e0] 0x0 is invalid
    Last message repeated 3 times
[mpegts @ 0x15ba8c0] DTS discontinuity in stream 1: packet 3 with DTS 5035936195, packet 4 with DTS 5035939329
[mpegts @ 0x15ba8c0] max_analyze_duration 5000000 reached at 5014400
[mpegts @ 0x15ba8c0] PES packet size mismatch
Input #0, mpegts, from '../network44-Ad48.ts':
  Duration: 00:01:56.50, start: 55954.776944, bitrate: 37921 kb/s
  Program 3
    Metadata:
      service_name    : P_26
      service_provider:
    Stream #0:0[0x23]: Video: mpeg2video (Simple) ([2][0][0][0] / 0x0002), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x25]: Audio: ac3 ([6][0][0][0] / 0x0006), 44100 Hz, stereo, fltp, 192 kb/s
[graph 0 input from stream 0:0 @ 0x15bf880] w:720 h:480 pixfmt:yuv420p tb:1/90000 fr:30000/1001 sar:8/9 sws_param:flags=2
[graph 1 input from stream 0:1 @ 0x15be2c0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
-async is forwarded to lavfi similarly to -af aresample=async=2:min_hard_comp=0.100000.
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] chl:stereo fmt:fltp r:44100Hz -> chl:stereo fmt:s16 r:48000Hz
[mpegts @ 0x15bd1a0] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to '../network_wofix.ts':
  Metadata:
    encoder         : Lavf54.59.106
    Stream #0:0: Video: mpeg2video, yuv420p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 29.97 tbc
    Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> mpeg2video)
  Stream #0:1 -> #0:1 (ac3 -> mp2)
Press [q] to stop, [?] for help
[ac3 @ 0x15bf160] frame sync error
Error while decoding stream #0:1: Operation not permitted
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] adding 1536 audio samples of silence
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034830 compensation:-2 in:48000
*** 11 dup!
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034830 compensation:-2 in:48000
    Last message repeated 359 times
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034807 compensation:-2 in:48000
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034830 compensation:-2 in:48000
    Last message repeated 5 times
[mpeg2video @ 0x15be7e0] warning: first frame is no keyframe
Input stream #0:0 frame changed from size:720x480 fmt:yuv420p to size:704x480 fmt:yuv420p
[graph 0 input from stream 0:0 @ 0x17a8b80] w:704 h:480 pixfmt:yuv420p tb:1/90000 fr:30000/1001 sar:10/11 sws_param:flags=2
[scaler for output stream 0:0 @ 0x1bdff40] w:720 h:480 flags:'0x4' interl:0
[scaler for output stream 0:0 @ 0x1bdff40] w:704 h:480 fmt:yuv420p sar:10/11 -> w:720 h:480 fmt:yuv420p sar:8/9 flags:0x4
*** 1 dup!
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034830 compensation:-2 in:48000
    Last message repeated 2 times
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034807 compensation:-2 in:48000
[graph 1 aresample for input stream 0:1 @ 0x17aa3c0] [SWR @ 0x15ad760] compensating audio timestamp drift:-0.034830 compensation:-2 in:48000
    Last message repeated 2 times
Input stream #0:1 frame changed from rate:44100 fmt:fltp ch:2 chl:stereo to rate:48000 fmt:fltp ch:3 chl:2.1
[graph 1 input from stream 0:1 @ 0x17a9320] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0xb
-async is forwarded to lavfi similarly to -af aresample=async=2:min_hard_comp=0.100000.
[graph 1 aresample for input stream 0:1 @ 0x17a97c0] chl:2.1 fmt:fltp r:48000Hz -> chl:stereo fmt:s16 r:48000Hz
change in ingest samplerate or channels sr:48000,prev_sr:44100,ch:11,prev_ch:3
[graph 1 aresample for input stream 0:1 @ 0x17a97c0] [SWR @ 0x15ad760] adding 630283 audio samples of silence
[mpegts @ 0x15bd1a0] st:0 PTS: -902 DTS: -902 < 1180619 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 1258 DTS: 1258 < 1180620 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 3418 DTS: 3418 < 1180621 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 5578 DTS: 5578 < 1180622 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 7738 DTS: 7738 < 1180623 invalid, clipping
st:0 PTS: 9898 DTS: 9898 < 1180624 invalid, clipping.35 *:35.00 size=    3450kB time=00:00:13.24 bitrate=2133.5kbits/s dup=12 drop=0
[mpegts @ 0x15bd1a0] st:0 PTS: 12058 DTS: 12058 < 1180625 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 14218 DTS: 14218 < 1180626 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 16378 DTS: 16378 < 1180627 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 18538 DTS: 18538 < 1180628 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 20698 DTS: 20698 < 1180629 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 22858 DTS: 22858 < 1180630 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 25018 DTS: 25018 < 1180631 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 27178 DTS: 27178 < 1180632 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 29338 DTS: 29338 < 1180633 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 31498 DTS: 31498 < 1180634 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 33658 DTS: 33658 < 1180635 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 35818 DTS: 35818 < 1180636 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 37978 DTS: 37978 < 1180637 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 40138 DTS: 40138 < 1180638 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 42298 DTS: 42298 < 1180639 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 44458 DTS: 44458 < 1180640 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 46618 DTS: 46618 < 1180641 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 48778 DTS: 48778 < 1180642 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 50938 DTS: 50938 < 1180643 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 53098 DTS: 53098 < 1180644 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 55258 DTS: 55258 < 1180645 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 57418 DTS: 57418 < 1180646 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 59578 DTS: 59578 < 1180647 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 61738 DTS: 61738 < 1180648 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 63898 DTS: 63898 < 1180649 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 66058 DTS: 66058 < 1180650 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 68218 DTS: 68218 < 1180651 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 70378 DTS: 70378 < 1180652 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 72538 DTS: 72538 < 1180653 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 74698 DTS: 74698 < 1180654 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 76858 DTS: 76858 < 1180655 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 79018 DTS: 79018 < 1180656 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 81178 DTS: 81178 < 1180657 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 83338 DTS: 83338 < 1180658 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 85498 DTS: 85498 < 1180659 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 87658 DTS: 87658 < 1180660 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 89818 DTS: 89818 < 1180661 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 91978 DTS: 91978 < 1180662 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 94138 DTS: 94138 < 1180663 invalid, clipping
[mpegts @ 0x15bd1a0] st:0 PTS: 96298 DTS: 96298 < 1180664 invalid, clipping

...............


[mpegts @ 0x305d1a0] st:0 PTS: 6610858 DTS: 6610858 < 6618297 invalid, clipping
[mpegts @ 0x305d1a0] st:0 PTS: 6613018 DTS: 6613018 < 6618298 invalid, clipping
[mpegts @ 0x305d1a0] st:0 PTS: 6615178 DTS: 6615178 < 6618299 invalid, clipping
[mpegts @ 0x305d1a0] st:0 PTS: 6617338 DTS: 6617338 < 6618300 invalid, clipping
[mpegts @ 0x305a8c0] PES packet size mismatch
[mpeg2video @ 0x305e7e0] ac-tex damaged at 32 27
[mpeg2video @ 0x305e7e0] Warning MVs not available
[mpeg2video @ 0x305e7e0] concealing 135 DC, 135 AC, 135 MV errors in P frame
[ac3 @ 0x305f160] incomplete frame
st:0 PTS: 11619574 DTS: 11619574 < 11621099 invalid, clipping75 size=   21754kB time=00:01:56.44 bitrate=1530.4kbits/s dup=13 drop=0
No more output streams to write to, finishing.
frame= 3492 fps=520 q=31.0 LPSNR=Y:31.02 U:39.79 V:40.08 *:32.51 size=   24356kB time=00:02:09.15 bitrate=1544.8kbits/s dup=13 drop=0
video:11575kB audio:10180kB subtitle:0 global headers:0kB muxing overhead 11.956417%


Thanks,
Sailaja

-----Original Message-----
From: ffmpeg-devel-bounces at ffmpeg.org [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of Michael Niedermayer
Sent: Friday, January 25, 2013 5:14 PM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] FW: Transport streams with change in channels/sample rate result in huge silence insertion

On Fri, Jan 25, 2013 at 05:40:19PM +0000, Sailaja Mahendrakar wrote:
> Hi Michael,
>
> Where can I upload the test sample with audio channels and sample rate change?

our bugtracker if its small or ftp if its larger please see "Submitting Sample Media" at http://ffmpeg.org/bugreports.html

also dont forget to tell us that you uploaded something and where

thanks

[...]
--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle



More information about the ffmpeg-devel mailing list