[FFmpeg-user] MPEG-TS CBR?

Anjo Krank anjo at krank.net
Mon Apr 16 11:46:45 CEST 2012


Am 13.04.2012 um 21:34 schrieb Michael Niederbayer:

>>> Do you think it is possible to use a publicly available sample 
>>> as source for an encoding, run the resulting file through the 
>>> stream analyzer and post both the transport stream and the 
>>> analyzer text?

Here you go, ran with current HEAD:

anjo:~ ak$ /outgoing/bin/ffmpeg.Darwin -i matrixbench_mpeg2.mpg    -c:v mpeg2video -pix_fmt yuv420p -ec +deblock -vf yadif -r 25 -s 720x576 -b:v 4000k -minrate:v 4000k -maxrate:v 4000k  -bufsize 1000k -g 12 -bf 2 -flags +cgop -flags2 sgop -sc_threshold 1000000000 -streamid:v 0:480 -streamid:a 1:481 -packetsize 188  -c:a mp2 -ar 48000 -b:a 192k -f mpegts -y  mb2.mpg
ffmpeg version N-39845-g44c4170 Copyright (c) 2000-2012 the FFmpeg developers
  built on Apr 16 2012 10:56:07 with gcc 4.0.1 (Apple Inc. build 5493)
  configuration: --prefix=/Users/ak/sffmpeg/build --datadir=/Users/ak/sffmpeg/build/etc --arch=x86_64 --disable-shared --enable-static --enable-gpl --enable-version3 --enable-nonfree --disable-doc --disable-debug --disable-ffplay --disable-ffserver --disable-avdevice --disable-indevs --disable-outdevs --enable-runtime-cpudetect --enable-memalign-hack --extra-cflags=-I/Users/ak/sffmpeg/build/include --extra-cflags=--static --extra-cflags=-m64 --extra-ldflags=-L/Users/ak/sffmpeg/build/lib --extra-ldflags=-m64 --extra-ldflags=-arch --extra-ldflags=x86_64 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --disable-libspeex --enable-libx264 --disable-libxvid --disable-librtmp
  libavutil      51. 46.100 / 51. 46.100
  libavcodec     54. 14.101 / 54. 14.101
  libavformat    54.  3.100 / 54.  3.100
  libavfilter     2. 70.100 /  2. 70.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 11.100 /  0. 11.100
  libpostproc    52.  0.100 / 52.  0.100
[mpeg @ 0x10180a220] max_analyze_duration 5000000 reached at 5000000
Input #0, mpeg, from 'matrixbench_mpeg2.mpg':
  Duration: 00:03:07.63, start: 0.220000, bitrate: 5634 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x576 [SAR 16:15 DAR 4:3], 11421 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
[buffer @ 0x101101040] w:720 h:576 pixfmt:yuv420p tb:1/1000000 sar:16/15 sws_param:flags=2
[yadif @ 0x10110a7c0] mode:0 parity:-1 auto_enable:0
[mpegts @ 0x101813020] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'mb2.mpg':
  Metadata:
    encoder         : Lavf54.3.100
    Stream #0:0: Video: mpeg2video, yuv420p, 720x576 [SAR 16:15 DAR 4:3], q=2-31, 4000 kb/s, 90k tbn, 25 tbc
    Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 192 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> mpeg2video)
  Stream #0:1 -> #0:1 (mp2 -> mp2)
Press [q] to stop, [?] for help
frame= 4689 fps=239 q=2.5 Lsize=  104056kB time=00:03:07.52 bitrate=4545.8kbits/s    
video:91552kB audio:4398kB global headers:0kB muxing overhead 8.448276%

Original:

  http://samples.ffmpeg.org/benchmark/testsuite1/matrixbench_mpeg2.mpg

Resulting stream: 

  http://www.krank.net/mb2.mpg

Crosscheck output:

  http://www.krank.net/mb2.txt

Previous comment from a guy with way more knowledge than me was: 

"The problem seems to be related to the multiplexing that ffmpeg is carrying out, as although it is creating transport streams, these are not always liked by STB's due to the inaccuracy of the information (this is why some files work and some don't, as there is no consistency to ffmpeg's output). As well as this buffer underflow issues are being created by the lack of null packets padding out the stream. I was able to fix one of the faulty assets by re-multiplexing it using Manzanita (using a standard mux config)." 

He went on to say that there were no open-source solutions that provided compatible broadcast TS muxing. Which I find a bit strange, as it certainly can't be *that* hard, can it? From what I understood is that the muxing simply grabbed packets from the streams, interleaves them and pads out with NULL if appropriate… but then, what do I know :)

BTW, "crosscheck" has a demo version that checks the first 10 mins or so. You'd need to send them an email:

>> http://www.manzanitasystems.com/products/crosscheck-demo.html


Cheers, Anjo




More information about the ffmpeg-user mailing list