[FFmpeg-user] Combining -muxrate and -copyts results in unexpected high bitrates

Moritz Barsnick barsnick at gmx.net
Wed Oct 16 17:23:24 EEST 2019


On Wed, Oct 16, 2019 at 14:10:58 +0200, Roman Huy-Prech wrote:
> and the least amount of arguments needed to reproduce:
> https://bitdash-a.akamaihd.net/content/sintel/hls/1500kbit/seq-38.ts

Incorrect URL, this is the correct one:
https://bitdash-a.akamaihd.net/content/sintel/hls/video/1500kbit/seq-38.ts

> Original Chunk:
> Duration: 00:00:02.00, start: 76.083333, bitrate: 919 kb/s
>
> Using -copyts I can copy over the timings. Good. But I want 300k.
> ffmpeg -i seq-38.ts -vf scale=320:240 -f mpegts -muxdelay 0 -copyts
> -vcodec libx264 -crf 19 -y seq-38-copyts.ts && ffprobe seq-38-copyts.ts
> Duration: 00:00:02.00, start: 76.083333, bitrate: 245 kb/s

You should always provide us with the command and its complete, uncut
console output. In this case, thanks to the sample (almost), we can
reproduce, but it's nicer to see *your* actual results, not our own.

> Now I'm combining the two, I have the correct start time again, but wtf?
> 11696 kb/s?
> ffmpeg -i seq-38.ts -vf scale=320:240 -f mpegts -muxdelay 0 -copyts
> -vcodec libx264 -crf 19 -y -muxrate 300k seq-38-copyts.ts && ffprobe
> seq-38-copyts.ts
> Duration: 00:00:02.00, start: 76.083333, bitrate: 11696 kb/s

Apparently, ffmpeg is taking the additional 78 seconds offset from the
copyts into consideration:

> frame=   48 fps= 15 q=-1.0 Lsize=    2856kB time=00:01:17.95 bitrate= 300.1kbits/s speed=24.3x
> video:54kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5149.501953%

(This is what we ask for the complete output for - we can point out
where iut shows you the issue!)

Note that ffmpeg thinks it encoded 1:17.95 (not 0:02.00) at
300.1kbits/s. (See all that muxing overhead!)

Looking at my resulting file size, that's even quite precisely correct:
(no. of bytes in filesize, times bits in a byte, divided by assumed
length in seconds, is the bit rate:)

$ calc "2924340 / 77.95 * 8"
        ~300124.69531751122514432328

Except that the resulting video isn't actually 77.95 seconds long. ;-)
Therefore, the resulting overall bit rate is wrong.

So I believe copyts is confusing the muxrate calculation, pretty much
like the guess in your second e-mail. I consider it a bug.

(BTW, there do exist other external tools to pad an MPEG-TS to a CBR.
ffmpeg's MPEG-TS does have some deficits, but this isn't supposed to be
one of them.)

Cheers,
Moritz


More information about the ffmpeg-user mailing list