Stuttering on .TS files on certain players

Server Version#: 1.13.7.5369

I’m having a weird issue where I get several seconds of stutter on recordings. The stutter manifests itself as a couple seconds of very fast playback with no audio. It happens every 10 minutes or so.
I thought it might be a signal issue on my HDHR Connect, but signal quality is near perfect with my new HDHR Quatro.
If I play the files on VLC or through the web app or through Plex Media Player (on Windows), it plays fine with no stutter, so I’ve narrowed it down to playback on the WebOS TV. I also tested using XPLAY and it stuttered in exactly the same place.
It happens with multiple (almost all) recordings.
The TV has a wired, gigabit connection to the server. The web and PMP were tested on a laptop over wifi and VLC was tested on the server itself.

I thought the problem was the TV, but the more I dug in, the more weirdness I’m finding in the .ts file itself.

ffprobe list the video bitrate as 14589 kb/s

ffprobe dance.ts
ffprobe version N-92086-gd702769213 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20180813
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 31.102 / 58. 31.102
  libavformat    58. 18.103 / 58. 18.103
  libavdevice    58.  4.105 / 58.  4.105
  libavfilter     7. 33.100 /  7. 33.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mpegts, from 'dance.ts':
  Duration: 01:59:58.87, start: 1.400000, bitrate: 14589 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x102](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 192 kb/s

If I re-container the file using ffmpeg
ffmpeg -i dance.ts -vcodec copy -c:a copy -map 0 dance2.mkv
then the file plays just fine on all players.
…but the bitrate changed?!

ffprobe dance2.mkv
ffprobe version N-92086-gd702769213 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20180813
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 31.102 / 58. 31.102
  libavformat    58. 18.103 / 58. 18.103
  libavdevice    58.  4.105 / 58.  4.105
  libavfilter     7. 33.100 /  7. 33.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, matroska,webm, from 'dance2.mkv':
  Metadata:
    ENCODER         : Lavf58.18.103
  Duration: 01:59:58.87, start: 0.000000, bitrate: 13475 kb/s
    Stream #0:0: Video: mpeg2video (Main), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      DURATION        : 01:59:58.870000000
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
    Metadata:
      DURATION        : 01:59:58.858000000
    Stream #0:2(spa): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Metadata:
      DURATION        : 01:59:58.848000000

It can’t possibly be re-encoding the video while it converts at 50x on my 15W laptop.

Has anyone else seen issues with the .ts files? Am I missing something with the re-containering?
Is this the right solution (for now)? Is there a way to automate this process?

I’ve now confirmed this on many files. Some are practically unwatchable before (skipping every 60 seconds or so) and play perfectly afterwards.

I can’t tell if there is actually something borderline wrong with the .ts files Plex is creating, or if it is a problem with WebOS.

Is there a way to automatically run a script to execute this ffmpeg command when a new file is added?

There are a few links to .ts to .mkv scripts that can be added as post processing scripts, here is one for Linux:

Just add it in dvr settings under postprocessing. I still wish there was an option to keep this as a standard recording format as post processing adds delay after recording before it can be watched, where it used to be immediate in the old DVR betas.

Thanks! I wrote a Python script that uses a watchdog observer to look for new .ts files, but this seems much more straightforward. Is there a link to what kinds of scripts are supported by this setting? (Plus, I’m on Windows).

the typical replacement for a Linux sh file is a windows bat file, it can run just about anything though if your system can I believe bat file could be a wrapper as well here’s a powershell example of some post processing stuff Windows Power Shell script for PostProcessing

Thanks for the pointers! I re-wrote my script to work this way (there’s some extra imports still and I need to change the prints to log to a file, but it works)

batch script:

@echo off
echo %*
C:\Python\Python37-32\python.exe e:\ts_mod.py %*

ts_mod.py:

import time
import sys
import os
from ctypes import windll
import time
import subprocess
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler

def process_file(src_path):
    #the file will be processed there
    print (src_path) #print for debug

    parts = (src_path).split('\\')

    ccextract_str = 'c:\ccextractor\ccextractorwin.exe  -autoprogram  -out=srt -bom -utf8 ' + '\"' + src_path
    ccextract_cmd = ['c:\ccextractor\ccextractorwin.exe', '-autoprogram',  '-out=srt', '-bom', '-utf8', src_path]
    print(ccextract_str + ' ...')
    subprocess.call(ccextract_cmd) #creates srt

    ffmpeg_str = r'c:\ffmpeg\bin\ffmpeg.exe -i ' + src_path + ' -i ' + src_path[:-2] + 'srt ' + \
                 '-map 0 -map 1:s -c:v copy -c:a copy -c:s srt ' + src_path[:-2] + 'mkv'
    ffmpeg_cmd = [r'c:\ffmpeg\bin\ffmpeg.exe', '-i', src_path, '-i', src_path[:-2] + 'srt',
                 '-map', '0', '-map', '1:s', '-c:v', 'copy', '-c:a', 'copy', '-c:s', 'srt', src_path[:-2] + 'mkv']
    print(ffmpeg_str + ' ...')
    subprocess.call(ffmpeg_cmd)

    print('Conversion complete.')

    print('Moving .ts file...')

    parts = (src_path).split('\\')
    filename = parts[-1]

    move_str = 'move "' + src_path + '" ' + r'e:\ts_files'
    move_cmd = ['move', src_path, r'e:\ts_files']
    print(move_str)

    subprocess.call(move_str, shell=True)
        


if __name__ == '__main__':
    args = sys.argv[1:]
    path = args[0]

    process_file(path)

I do wish the Plex people would say something about this problem and why this seems to fix it…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.