Opened 10 years ago

Closed 9 years ago

#3497 closed defect (invalid)

multiple ffmpeg instances gives encoding error

Reported by: hemanth.he Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: libx264 hls
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hi, Can anyone help me figure out to fix the problem below

I am trying to encode multiple udp streams in HLS format. I run one by one instance (process) of encoding on the system. The application is working fine and I was able to encode, receive and play the streams using a player running on a STB (Set Top Box). The encoding was OK till running the 5 th instance. When I started running the 6th encoding instance on the system, the stream output starts freezing in all the 6 encoded outputs.

I am using a Intel Xeon based Server with 24 cores and 32GB of RAM

Here is my ffmpeg build info.


ffmpeg
ffmpeg version N-61057-gec6d043 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 4 2014 05:33:48 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx

I am using the below command to encode one channel:

ffmpeg -loglevel info -i "udp://@239.1.1.9:1009?fifo_size=1000000&overrun_nonfatal=1" -map 0:p:1:0 -map 0:p:1:1 -vcodec h264 -acodec aac -profile main -preset fast -g 12 -r 23.98 -s 256x144 -aspect 16:9 -b:v 166k -minrate 166k -maxrate 166k -bufsize 166k -vol 512 -b:a 128k -ac 2 -ar 48000 -strict experimental -flags -global_header -f ssegment -segment_time 10 -segment_wrap 30000 -segment_list Food_256x144_main_394.m3u8 -segment_list_flags +live -segment_list_size 6 -segment_format mpegts Food_256x144_main_394-%05d.ts -map 0:p:2:0 -map 0:p:2:1 -vcodec h264 -acodec aac -profile main -preset fast -g 12 -r 23.98 -s 640x360 -aspect 16:9 -b:v 722k -minrate 722k -maxrate 722k -bufsize 722k -vol 512 -b:a 128k -ac 2 -ar 48000 -strict experimental -flags -global_header -f ssegment -segment_time 10 -segment_wrap 30000 -segment_list Food_640x360_main_950.m3u8 -segment_list_flags +live -segment_list_size 6 -segment_format mpegts Food_640x360_main_950-%05d.ts -map 0:p:2:0 -map 0:p:2:1 -vcodec h264 -acodec aac -profile main -preset fast -g 12 -r 23.98 -s 960x540 -aspect 16:9 -b:v 1472k -minrate 1472k -maxrate 1472k -bufsize 1472k -vol 512 -b:a 128k -ac 2 -ar 48000 -strict experimental -flags -global_header -f ssegment -segment_time 10 -segment_wrap 30000 -segment_list Food_960x540_main_1700.m3u8 -segment_list_flags +live -segment_list_size 6 -segment_format mpegts Food_960x540_main_1700-%05d.ts -map 0:p:2:0 -map 0:p:2:1 -vcodec h264 -acodec aac -profile main -preset fast -g 12 -r 23.98 -s 1280x720 -aspect 16:9 -b:v 2772k -minrate 2772k -maxrate 2772k -bufsize 2772k -vol 512 -b:a 128k -ac 2 -ar 48000 -strict experimental -flags -global_header -f ssegment -segment_time 10 -segment_wrap 30000 -segment_list Food_1280x720_main_3000.m3u8 -segment_list_flags +live -segment_list_size 6 -segment_format mpegts Food_1280x720_main_3000-%05d.ts

I run the top command on the system and the output when I run the 6 th instance of the encoding is as follows

Tasks: 831 total, 7 running, 824 sleeping, 0 stopped, 0 zombie
Cpu(s): 42.0%us, 1.9%sy, 30.6%ni, 24.8%id, 0.0%wa, 0.0%hi, 0.7%si, 0.0%st
Mem: 32844180k total, 12389892k used, 20454288k free, 32536k buffers
Swap: 16490488k total, 7196k used, 16483292k free, 2747568k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
28365 root 20 0 12.1g 1.2g 3996 S 321.9 4.0 79:52.70 ffmpeg
28846 root 20 0 12.2g 1.1g 3720 R 315.0 3.5 76:45.76 ffmpeg
29334 root 20 0 11.8g 1.1g 4036 R 313.7 3.5 71:35.19 ffmpeg
30296 root 20 0 11.5g 1.1g 4036 R 296.2 3.5 67:50.69 ffmpeg
31405 root 20 0 11.9g 1.1g 4036 R 280.0 3.5 61:28.51 ffmpeg
29815 root 20 0 11.9g 1.1g 3952 S 255.6 3.4 60:18.52 ffmpeg


The sample error messages I am getting after adding the 6 th encoding instance is as below ( I have pasted only few lines of error message for reference as the log message is too long )


619 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
619 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 3 times
619 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24c91e0] Invalid frame dimensions 0x0.
619 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Invalid frame dimensions 0x0.
619 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 1 times
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Invalid frame dimensions 0x0.
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 1 times
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24c91e0] Invalid frame dimensions 0x0.
620 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
621 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24c91e0] Invalid frame dimensions 0x0.
621 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
622 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 1 times
622 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24c91e0] Invalid frame dimensions 0x0.
622 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Invalid frame dimensions 0x0.
622 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
638 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 2 times
638 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24c91e0] Invalid frame dimensions 0x0.
638 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24ccb00] Invalid frame dimensions 0x0.
100219 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Last message repeated 12 times
100220 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 40 38
100221 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Warning MVs not available
122531 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] invalid mb type in P Frame at 80 15
122533 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Warning MVs not available
133228 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] invalid mb type in B Frame at 49 62
290481 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] Warning MVs not available
434875 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] skipped MB in I frame at 84 40
482051 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] invalid cbp 0 at 105 39
482052 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 107 41
733548 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] exponent out-of-range
733549 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] error decoding the audio block
733563 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] frame sync error
733563 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Error while decoding stream #0:4: Invalid data found when processing input
1070401 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 100 59
1133263 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 9 11
1133321 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] exponent out-of-range
1133321 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] error decoding the audio block
1133324 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] frame sync error
1133324 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Error while decoding stream #0:4: Invalid data found when processing input
1270788 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 55 65
1270832 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 44 1
1432386 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 78 19
1454356 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 119 48
1483269 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] skipped MB in I frame at 86 23
1636633 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] exponent out-of-range
1636633 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] error decoding the audio block
1636637 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] frame sync error
1636637 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Error while decoding stream #0:4: Invalid data found when processing input
1763064 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] invalid mb type in I Frame at 61 52
1763064 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] invalid mb type in I Frame at 6 53
1863322 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] skipped MB in I frame at 66 5
2021368 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] skipped MB in I frame at 98 50
2070210 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 110 44
2090358 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 97 0
2090383 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] exponent out-of-range
2090383 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] error decoding the audio block
2090386 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [ac3 @ 0x24cf0c0] frame sync error
2090386 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : Error while decoding stream #0:4: Invalid data found when processing input
2156757 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 26 2
2342374 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 63 60
2342375 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 53 59
2380228 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 103 60
2380228 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] slice mismatch
2470407 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 83 17
2470408 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 104 21
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 29 67
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 1 1
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 1 2
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 1 3
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 10 4
2563489 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 1 5
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 10 6
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 33 7
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 37 8
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] slice mismatch
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 10 10
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 5 11
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 2 12
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 1 13
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 16 14
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 4 15
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 13 16
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 6 17
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 24 18
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 25 19
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 4 20
2563490 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 28 21
2563491 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] slice mismatch
2563491 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] ac-tex damaged at 38 23
2563491 [main] DEBUG com.ivz.streamer.FFmpegStreamer - Stream from process : [mpeg2video @ 0x24d2100] 00 motion_type at 14 24


Change History (11)

comment:1 by Carl Eugen Hoyos, 10 years ago

Priority: criticalnormal

Aren't you just reporting a performance issue?

in reply to:  1 comment:2 by hemanth.he, 10 years ago

yes it is performance problem..!

comment:3 by Carl Eugen Hoyos, 10 years ago

Did you test -preset ultrafast for all streams?

in reply to:  3 comment:4 by hemanth.he, 10 years ago

yes i tested with -preset ultrafast but no use. still having same problem.

comment:5 by Carl Eugen Hoyos, 10 years ago

What happens if you use a much slower preset? Are five instances still supported or does that change the limit?

in reply to:  5 ; comment:6 by hemanth.he, 10 years ago

If i use -preset slow then i can run only 2 instances. Starting 3rd one will create problem to the previous running instances, they start giving errors and video as well as audio starts getting disturbances.

The 2 successfully running instances have minor pixelization/tiling problem.
This problem shows up every 1-2 minutes.

Please help to resolve this issue.

comment:7 by Mista_D, 10 years ago

Try running it as root

in reply to:  7 ; comment:8 by Cigaes, 10 years ago

Replying to Mista_D:

Try running it as root

This is usually very bad advice. Not just for ffmpeg, for any program. Unless you know the program requires privileges, and you understand why it does, you should not try running it as root just to see if it works.

in reply to:  8 comment:9 by Mista_D, 10 years ago

Replying to Cigaes:

Replying to Mista_D:

Try running it as root

This is usually very bad advice. Not just for ffmpeg, for any program. Unless you know the program requires privileges, and you understand why it does, you should not try running it as root just to see if it works.

Agree that it is an unsafe advice, but there's a possible thread limitation associated to a specific user. Processing a live feed within allocated timing parameter requires all available hardware resources. AFAIK root has no limitations in that regard.

comment:10 by hemanth.he, 9 years ago

yes i'm running it as root user.

in reply to:  6 comment:11 by Carl Eugen Hoyos, 9 years ago

Keywords: libx264 hls added
Resolution: invalid
Status: newclosed

Replying to hemanth.he:

If i use -preset slow then i can run only 2 instances. Starting 3rd one will create problem to the previous running instances,

Sounds as if this is a x264 performance issue that cannot be fixed within FFmpeg.

Note: See TracTickets for help on using tickets.