[FFmpeg-user] Frame loss, pixelation on STB in mosaic output created by ffmpeg
Sagar Lakhani
lakhani.sagar at gmail.com
Thu Mar 28 08:47:05 EET 2019
Dear all,
I am creating a mosaic from live input streams, i am trying to watch this
on setup box. there are two ways with which i am doing this.
I am using ffmpeg 2.8.15 and it is compiled with hardware acceleration
enabled. The input stream is MPEG2 and i want output of MPEG4 (h264)
##########################################################################################
ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static
--extra-cflags=-I/root/ffmpeg_build/include
--extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread
--extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libx264 --enable-libx265
--enable-libmfx --enable-nonfree
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Hyper fast Audio and Video encoder
######################################################################################
First, I have a multiple service TS and i am taking it directly to mosaic
and separating each stream with program number. In this method, initially
output is fine but after a short time the ffmpeg stops.
Command for method 1 -
ffmpeg -i udp://238.1.1.11:1111?fifo_size=1000000?overrun_nonfatal=1
-filter_complex "color=c=black:size=1920x1080 [base];
[0:p:2153:v]drawtext=text='Program1':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r1p1];
[0:p:2154:v]drawtext=text='Program2':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r1p2];
[0:p:2155:v]drawtext=text='Program3':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r1p3];
[0:p:2156:v]drawtext=text='Program4':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r1p4];
[0:p:2157:v]drawtext=text='Program5':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r2p1];
[0:p:2158:v]drawtext=text='Program6':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r2p2];
[0:p:2159:v]drawtext=text='Program7':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r2p3];
[0:p:2160:v]drawtext=text='Program8':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r2p4];
[0:p:2162:v]drawtext=text='Program9':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r3p1];
[0:p:2163:v]drawtext=text='Program10':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r3p2];
[0:p:2151:v]drawtext=text='Program11':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r3p3];
[0:p:2164:v]drawtext=text='Program12':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts=PTS-STARTPTS, scale=480x320, fifo [r3p4]; [base][r1p1]
overlay=shortest=1 [tmp1]; [tmp1][r1p2] overlay=shortest=1:x=480 [tmp2];
[tmp2][r1p3] overlay=shortest=1:x=960 [tmp3]; [tmp3][r1p4]
overlay=shortest=1:x=1440 [tmp4]; [tmp4][r2p1] overlay=shortest=1:y=360
[tmp5]; [tmp5][r2p2] overlay=shortest=1:x=480:y=360 [tmp6]; [tmp6][r2p3]
overlay=shortest=1:x=960:y=360 [tmp7]; [tmp7][r2p4]
overlay=shortest=1:x=1440:y=360 [tmp8]; [tmp8][r3p1]
overlay=shortest=1:y=640 [tmp9]; [tmp9][r3p2]
overlay=shortest=1:x=480:y=720 [tmp10]; [tmp10][r3p3]
overlay=shortest=1:x=960:y=720 [tmp11]; [tmp11][r3p4]
overlay=shortest=1:x=1440:y=720" -c:v h264_qsv -flags +ilme+ildct+cgop
-fflags genpts -b:v 6000000 -maxrate 6000000 -minrate 6000000 -muxrate
4355772 -an -bufsize 6000000 -f mpegts pipe:1 | tsplay -stdin
-pace-pcr2-pmt -q -buffer 1000 -mcastif 192.168.0.15 238.1.1.1:1111
#######################################################################################################
there is another way Method 2-
In this i am converting multiple program stream to single program transport
stream for all services,
ffmpeg -i udp://238.238.238.238:1000?fifo_size=1000000?overrun_nonfatal=1
-i udp://238.238.238.238:1001?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1002?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1003?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1004?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1005?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1006?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1007?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1008?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1009?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1010?fifo_size=1000000?overrun_nonfatal=1 -i udp://
238.238.238.238:1011?fifo_size=1000000?overrun_nonfatal=1 -filter_complex
"color=c=black:size=1920x1080 [base];
[0:v]drawtext=text='Program1':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r1p1];
[1:v]drawtext=text='Program2':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r1p2];
[2:v]drawtext=text='Program3':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r1p3];
[3:v]drawtext=text='Program4':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo
[r1p4];
[4:v]drawtext=text='Program5':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r2p1];
[5:v]drawtext=text='Program6':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r2p2];
[6:v]drawtext=text='Program7':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r2p3];
[7:v]drawtext=text='Program8':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo
[r2p4];
[8:v]drawtext=text='Program9':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r3p1];
[9:v]drawtext=text='Program10':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r3p2];
[10:v]drawtext=text='Program11':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r3p3];
[11:v]drawtext=text='Program12':x=(400-text_w):y=(500-text_h):fontfile=OpenSans.ttf:fontsize=30:fontcolor=white,
setpts='(RTCTIME - RTCSTART) / (TB * 1000000)', scale=480x320, fifo [r3p4];
[base][r1p1] overlay=shortest=1 [tmp1]; [tmp1][r1p2]
overlay=shortest=1:x=480 [tmp2]; [tmp2][r1p3] overlay=shortest=1:x=960
[tmp3]; [tmp3][r1p4] overlay=shortest=1:x=1440 [tmp4]; [tmp4][r2p1]
overlay=shortest=1:y=320 [tmp5]; [tmp5][r2p2]
overlay=shortest=1:x=480:y=320 [tmp6]; [tmp6][r2p3]
overlay=shortest=1:x=960:y=320 [tmp7]; [tmp7][r2p4]
overlay=shortest=1:x=1440:y=320 [tmp8]; [tmp8][r3p1]
overlay=shortest=1:y=640 [tmp9]; [tmp9][r3p2]
overlay=shortest=1:x=480:y=640 [tmp10]; [tmp10][r3p3]
overlay=shortest=1:x=960:y=640 [tmp11]; [tmp11][r3p4]
overlay=shortest=1:x=1440:y=640" -c:v h264_qsv -b:v 4000000 -maxrate
4000000 -minrate 4000000 -bufsize 4000000 -f mpegts pipe:1 | tsplay -stdin
-q -buffer 1500 -mcastif 192.168.0.15 238.1.1.1:1111
In the method 2 i am getting a lot of pixelation frame loss and the video
is not playable on setup box, only audio is coming from it. How to play
mosaic on setup box? Without any pixelation and frameloss.
More information about the ffmpeg-user
mailing list