Transcoding timeout with ffmpeg/h.264 codec with embedded subtitle mkv file

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
User avatar
owlhuang
Posts: 5
Joined: Wed Aug 17, 2016 6:55 pm

Transcoding timeout with ffmpeg/h.264 codec with embedded subtitle mkv file

Post by owlhuang »

Hi all,

I spent some time tracing down the problem. It is because how ffmpeg handles the mkv file with embedded subtitles. Before ffmpeg starts to transcode the streams, it goes through ALL the subtitles, which takes more than 20 seconds if the file is large.

My question is, is there anyway to tell ffmpeg not to go through the file before doing the job? Or anything I could do to workaround this problem?

Logs are attached below. I attach the media info on one example file (it happens on all embedded subtitle MKV files) and also the part of the log about ffmpeg. Also how long it takes on to transcode 1 sec streams from that file (39 sec in this case.)

Thank you for the help.

UMS 6.6.0 on linux
ffmpeg64 from UMS 6.6.0

Code: Select all

TRACE 2017-04-17 02:03:13.609 [New I/O worker #3] Sleeping for 2500 milliseconds
TRACE 2017-04-17 02:03:16.109 [New I/O worker #3] Finished sleeping for 2500 milliseconds
DEBUG 2017-04-17 02:03:16.110 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:16.610 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:17.110 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:17.610 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:18.110 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:18.611 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:19.111 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:19.611 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:20.112 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
DEBUG 2017-04-17 02:03:20.612 [New I/O worker #3] External input stream instance is null... sounds not good, waiting 500ms
TRACE 2017-04-17 02:03:21.114 [New I/O worker #3] Did not send subtitle headers because dlna.getMedia returned null or configuration.isDisableSubtitles was true
ERROR 2017-04-17 02:03:21.114 [Hanging External Process Stopper] External input stream instance is null... stopping process
DEBUG 2017-04-17 02:03:21.114 [Hanging External Process Stopper] Stopping Unix process 3623: ffmpeg64-2
TRACE 2017-04-17 02:03:21.115 [Hanging External Process Stopper] Killing the Unix process: 3623
ERROR 2017-04-17 02:03:21.116 [New I/O worker #3] There is no inputstream to return for The Fall - 1080p_5.1 - 2006 {Sub:SubRip/English}
TRACE 2017-04-17 02:03:21.116 [New I/O worker #3] Sent to socket: Server: Linux-amd64-4.8.0-46-generic, UPnP/1.0 DLNADOC/1.50, UMS/6.6.0
TRACE 2017-04-17 02:03:21.116 [New I/O worker #3] Sent to socket: Content-Length: 0
DEBUG 2017-04-17 02:03:21.124 [Hanging External Process Stopper] Stopping Unix process 3619: mkfifo-3
TRACE 2017-04-17 02:03:21.125 [Hanging External Process Stopper] Killing the Unix process: 3619

Code: Select all

Unique ID                                : 63794059165875914917585039991702568552 (0x2FFE49F42E59543B3997C728D8483E68)
Complete name                            : /mnt/movies/00_RecentlyAdded/05 days - The Fall (2006)/The Fall - 1080p_5.1 - 2006.mkv
Format                                   : Matroska
Format version                           : Version 4 / Version 2
File size                                : 4.43 GiB
Duration                                 : 1h 56mn
Overall bit rate                         : 5 432 Kbps
Movie name                               : thefall. Done with HDConvertToX v.3.0.686.4609
Encoded date                             : UTC 2017-04-11 20:03:49
Writing application                      : mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
Writing library                          : libebml v1.3.4 + libmatroska v1.4.5

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 1h 56mn
Bit rate                                 : 5 049 Kbps
Width                                    : 1 920 pixels
Height                                   : 1 040 pixels
Display aspect ratio                     : 1.85:1
Frame rate mode                          : Constant
Frame rate                               : 24.000 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.105
Stream size                              : 4.12 GiB (93%)
Writing library                          : x264 core 107 r1745 4785e8e
Encoding settings                        : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x113 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=4 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=5049 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : A_AC3
Duration                                 : 1h 56mn
Bit rate mode                            : Constant
Bit rate                                 : 384 Kbps
Channel(s)                               : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 KHz
Frame rate                               : 31.250 fps (1536 spf)
Compression mode                         : Lossy
Delay relative to video                  : 8ms
Stream size                              : 321 MiB (7%)
Language                                 : English
Default                                  : No
Forced                                   : No

Text
ID                                       : 3
Format                                   : UTF-8
Codec ID                                 : S_TEXT/UTF8
Codec ID/Info                            : UTF-8 Plain Text
Duration                                 : 1h 47mn
Bit rate                                 : 40 bps
Count of elements                        : 988
Stream size                              : 31.8 KiB (0%)
Language                                 : English
Default                                  : No
Forced                                   : No

Menu
00:00:00.000                             : en:00:00:00.000
00:13:33.708                             : en:00:13:33.708
00:28:34.333                             : en:00:28:34.333
00:43:51.208                             : en:00:43:51.208
00:59:19.000                             : en:00:59:19.000
01:12:08.958                             : en:01:12:08.958
01:28:40.333                             : en:01:28:40.333
01:42:09.417                             : en:01:42:09.417

Code: Select all

dennis@dodo:~/t$ time ~/workspace/ums/linux/ffmpeg64 -y -loglevel info -i "/mnt/movies/00_RecentlyAdded/05 days - The Fall (2006)/The Fall - 1080p_5.1 - 2006.mkv" -filter_complex "subtitles=/mnt/movies/00_RecentlyAdded/05 days - The Fall (2006)/The Fall - 1080p_5.1 - 2006.mkv:si=0" -bufsize 31250k -maxrate 31250k -crf 19 -ab 640k -ar 48000 -c:a ac3 -c:v libx264 -tune zerolatency -preset ultrafast -level 31 -pix_fmt yuv420p -to 0:0:1 -f mpegts test.ts
ffmpeg version N-80363-g403a53c-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (Debian 5.4.0-4) 20160609
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --enable-frei0r --enable-libfribidi --disable-indev=sndio --disable-outdev=sndio --enable-librtmp --enable-libmfx --enable-libzimg --cc=gcc
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 46.100 / 57. 46.100
  libavformat    57. 38.100 / 57. 38.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.101 /  6. 46.101
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from '/mnt/movies/00_RecentlyAdded/05 days - The Fall (2006)/The Fall - 1080p_5.1 - 2006.mkv':
  Metadata:
    title           : thefall. Done with HDConvertToX v.3.0.686.4609
    encoder         : libebml v1.3.4 + libmatroska v1.4.5
    creation_time   : 2017-04-11 20:03:49
  Duration: 01:56:48.45, start: 0.000000, bitrate: 5431 kb/s
    Chapter #0:0: start 0.000000, end 813.708000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 813.708000, end 1714.333000
    Metadata:
      title           : 00:13:33.708
    Chapter #0:2: start 1714.333000, end 2631.208000
    Metadata:
      title           : 00:28:34.333
    Chapter #0:3: start 2631.208000, end 3559.000000
    Metadata:
      title           : 00:43:51.208
    Chapter #0:4: start 3559.000000, end 4328.958000
    Metadata:
      title           : 00:59:19.000
    Chapter #0:5: start 4328.958000, end 5320.333000
    Metadata:
      title           : 01:12:08.958
    Chapter #0:6: start 5320.333000, end 6129.417000
    Metadata:
      title           : 01:28:40.333
    Chapter #0:7: start 6129.417000, end 7008.449000
    Metadata:
      title           : 01:42:09.417
    Stream #0:0: Video: h264 (High), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
    Metadata:
      BPS             : 5046329
      BPS-eng         : 5046329
      DURATION        : 01:56:47.417000000
      DURATION-eng    : 01:56:47.417000000
      NUMBER_OF_FRAMES: 168178
      NUMBER_OF_FRAMES-eng: 168178
      NUMBER_OF_BYTES : 4420216608
      NUMBER_OF_BYTES-eng: 4420216608
      _STATISTICS_WRITING_APP: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2017-04-11 20:03:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-04-11 20:03:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s
    Metadata:
      BPS             : 384384
      BPS-eng         : 384384
      DURATION        : 01:56:48.441000000
      DURATION-eng    : 01:56:48.441000000
      NUMBER_OF_FRAMES: 219233
      NUMBER_OF_FRAMES-eng: 219233
      NUMBER_OF_BYTES : 336741888
      NUMBER_OF_BYTES-eng: 336741888
      _STATISTICS_WRITING_APP: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2017-04-11 20:03:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-04-11 20:03:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Subtitle: subrip
    Metadata:
      BPS             : 40
      BPS-eng         : 40
      DURATION        : 01:47:57.246000000
      DURATION-eng    : 01:47:57.246000000
      NUMBER_OF_FRAMES: 988
      NUMBER_OF_FRAMES-eng: 988
      NUMBER_OF_BYTES : 32571
      NUMBER_OF_BYTES-eng: 32571
      _STATISTICS_WRITING_APP: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2017-04-11 20:03:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-04-11 20:03:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[Parsed_subtitles_0 @ 0x415aa40] Shaper: FriBidi 0.19.7 (SIMPLE)
[Parsed_subtitles_0 @ 0x415aa40] Using font provider fontconfig
[Parsed_subtitles_0 @ 0x413b9c0] Shaper: FriBidi 0.19.7 (SIMPLE)
[Parsed_subtitles_0 @ 0x413b9c0] Using font provider fontconfig
[libx264 @ 0x4139760] using SAR=1/1
[libx264 @ 0x4139760] frame MB size (120x65) > level limit (3600)
[libx264 @ 0x4139760] VBV bitrate (31250) > level limit (14000)
[libx264 @ 0x4139760] VBV buffer (31250) > level limit (14000)
[libx264 @ 0x4139760] MB rate (187200) > level limit (108000)
[libx264 @ 0x4139760] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX LZCNT
[libx264 @ 0x4139760] profile Constrained Baseline, level 3.1
[mpegts @ 0x41336c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Last message repeated 1 times
Output #0, mpegts, to 'test.ts':
  Metadata:
    title           : thefall. Done with HDConvertToX v.3.0.686.4609
    encoder         : Lavf57.38.100
    Chapter #0:0: start 0.000000, end 1.000000
    Metadata:
      title           : 00:00:00.000
    Stream #0:0: Video: h264 (libx264), yuv420p, 1920x1040 [SAR 1:1 DAR 24:13], q=-1--1, 24 fps, 90k tbn, 24 tbc (default)
    Metadata:
      encoder         : Lavc57.46.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 31250000/0/0 buffer size: 31250000 vbv_delay: -1
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s
    Metadata:
      BPS             : 384384
      BPS-eng         : 384384
      DURATION        : 01:56:48.441000000
      DURATION-eng    : 01:56:48.441000000
      NUMBER_OF_FRAMES: 219233
      NUMBER_OF_FRAMES-eng: 219233
      NUMBER_OF_BYTES : 336741888
      NUMBER_OF_BYTES-eng: 336741888
      _STATISTICS_WRITING_APP: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v9.6.0 ('Slave To Your Mind') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2017-04-11 20:03:49
      _STATISTICS_WRITING_DATE_UTC-eng: 2017-04-11 20:03:49
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      encoder         : Lavc57.46.100 ac3
Stream mapping:
  Stream #0:0 (h264) -> subtitles (graph 0)
  subtitles (graph 0) -> Stream #0:0 (libx264)
  Stream #0:1 -> #0:1 (ac3 (native) -> ac3 (native))
Press [q] to stop, [?] for help
frame=   24 fps=0.0 q=8.0 Lsize=      99kB time=00:00:01.02 bitrate= 787.1kbits/s speed=4.81x    
video:8kB audio:80kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.393125%
[libx264 @ 0x4139760] frame I:1     Avg QP:16.00  size:  6754
[libx264 @ 0x4139760] frame P:23    Avg QP: 8.17  size:    50
[libx264 @ 0x4139760] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x4139760] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0x4139760] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x4139760] i16 v,h,dc,p: 94%  0%  6%  0%
[libx264 @ 0x4139760] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 0x4139760] kb/s:63.23

real	0m39.463s
user	0m0.408s
sys	0m7.300s
User avatar
owlhuang
Posts: 5
Joined: Wed Aug 17, 2016 6:55 pm

Re: Transcoding timeout with ffmpeg/h.264 codec with embedded subtitle mkv file

Post by owlhuang »

The forum upload quota is full. I don't think the detail logs are required since the problem is pretty obvious. If you really need the logs, please tell me where to upload them.
User avatar
owlhuang
Posts: 5
Joined: Wed Aug 17, 2016 6:55 pm

Re: Transcoding timeout with ffmpeg/h.264 codec with embedded subtitle mkv file

Post by owlhuang »

The time ffmpeg takes would reduce if I move the file to a faster file system. But even from a 400MB/s storage, it still takes more than 10s on a 1:56:00, 4.4GB video. It takes even longer if the video is longer. Also it takes considerable longer on the first time reading the file. A 2hr+ video would easily throw out the timeout error.
Post Reply