VideoHelp Forum




+ Reply to Thread
Results 1 to 9 of 9
  1. I have just recently started downloading .ts files from video sites, and they play perfectly using mpv. However, for compatibility with certain devices (and to eliminate the high overhead in .ts files), I would like to move them to mkv containers (without reencoding, of course).

    I have linux only, and use mkvmerge and ffmpeg. The first few I did ("mkvmerge -o file.mkv file.ts") played flawlessly, but I am having a problem with the most recent few (actually from a different site).

    Ffmpeg barfs like this:

    Code:
    $ ffmpeg -i file.ts -c copy file.mkv
    ffmpeg version 2.6.3 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.8.4
      configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags=' ' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --enable-version3 --disable-indev=v4l2 --disable-outdev=v4l2 --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-gpl --enable-hardcoded-tables --enable-iconv --enable-lzma --enable-network --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --disable-vaapi --enable-vdpau --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --enable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --disable-libv4l2 --disable-libpulse --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libfdk-aac --disable-libopenjpeg --enable-libbluray --disable-libcelt --disable-libgme --enable-libgsm --disable-libmodplug --disable-libopus --disable-libquvi --enable-librtmp --disable-libssh --disable-libschroedinger --enable-libspeex --enable-libvorbis --disable-libvpx --disable-libzvbi --disable-libbs2b --disable-libflite --disable-frei0r --disable-libfribidi --enable-fontconfig --disable-ladspa --enable-libass --enable-libfreetype --disable-libsoxr --enable-pthreads --enable-libvo-aacenc --disable-libvo-amrwbenc --enable-libmp3lame --disable-libaacplus --disable-libfaac --enable-libtheora --disable-libtwolame --disable-libwavpack --disable-libwebp --enable-libx264 --disable-libx265 --enable-libxvid --disable-amd3dnow --disable-amd3dnowext --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-xop --cpu=host
      libavutil      54. 20.100 / 54. 20.100
      libavcodec     56. 26.100 / 56. 26.100
      libavformat    56. 25.101 / 56. 25.101
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 11.102 /  5. 11.102
      libavresample   2.  1.  0 /  2.  1.  0
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, mpegts, from 'file.ts':
      Duration: 00:42:30.00, start: 10.000000, bitrate: 2101 kb/s
      Program 1 
        Stream #0:0[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
        Stream #0:1[0x102]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 155 kb/s
    [matroska @ 0x18c90f0] Error parsing AAC extradata, unable to determine samplerate.
    Output #0, matroska, to 'file.mkv':
      Metadata:
        encoder         : Lavf56.25.101
        Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 90k tbc
        Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, 155 kb/s
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
    Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
    Mkvmerge appears to mux fine, but when I try to play the output, the sound synchronization (A-V) wanders back and forth between about -0.3 seconds and +0.3 seconds, which is not exactly pleasant to watch. Is there some way of fixing this? Thank you in advance.
    Last edited by Nuzhna Pomoshch; 15th Aug 2015 at 18:56. Reason: clarify
    Quote Quote  
  2. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    My suggestion: try demuxing (to elementary streams) with TSmuxer, and only then use MKVtoolnix.

    The transport stream format is VERY flexible, and both ffmpeg and mkvmerge do not support all its possible variations : -/
    Quote Quote  
  3. Member
    Join Date
    Jan 2007
    Location
    United States
    Search Comp PM
    i think maybe you need to use MediaInfo on your troublesome files
    either they are variable frame rate or the audio is not constant
    i'm thinking the video is VFR
    i'm not familiar with command line use of ffmpeg
    i would try a command that fixes the frame rate to CFR of what ever the expected rate is supposed to be say 25fps

    i'm sure somebody will correct me with better advice
    yep good advice before i couls even get posted
    Quote Quote  
  4. You are right, mediainfo does show a variable frame rate (never heard of that before):

    Code:
    $ mediainfo file.ts
    General
    ID                                       : 1 (0x1)
    Complete name                            : file.ts
    Format                                   : MPEG-TS
    File size                                : 637 MiB
    Duration                                 : 42mn 30s
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 2 102 Kbps
    
    Video
    ID                                       : 257 (0x101)
    Menu ID                                  : 1 (0x1)
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : Baseline@L3.1
    Format settings, CABAC                   : No
    Format settings, ReFrames                : 3 frames
    Codec ID                                 : 27
    Duration                                 : 42mn 30s
    Nominal bit rate                         : 1 950 Kbps
    Width                                    : 1 280 pixels
    Height                                   : 720 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Variable
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Writing library                          : x264 core 118
    Encoding settings                        : cabac=0 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=90 / keyint_min=9 / scenecut=40 / intra_refresh=0 / rc_lookahead=0 / rc=2pass / mbtree=1 / bitrate=1950 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=1950 / vbv_bufsize=1950 / nal_hrd=none / ip_ratio=1.40 / aq=1:1.00
    
    Audio
    ID                                       : 258 (0x102)
    Menu ID                                  : 1 (0x1)
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format version                           : Version 4
    Format profile                           : LC
    Muxing mode                              : ADTS
    Codec ID                                 : 15
    Duration                                 : 42mn 30s
    Bit rate mode                            : Variable
    Channel(s)                               : 2 channels
    Channel positions                        : Front: L R
    Sampling rate                            : 44.1 KHz
    Compression mode                         : Lossy
    That gives me something to search for (and I will take a look at tsmuxer, too). Thanks.
    Quote Quote  
  5. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    Thanks for the MediaInfo log, it shows that the creator of those files didn't know what he/she was doing.
    Transports streams are not supposed to use VFR, and the x264 command-line should have included the --force-cfr switch.
    Quote Quote  
  6. Originally Posted by El Heggunte View Post
    Thanks for the MediaInfo log, it shows that the creator of those files didn't know what he/she was doing.
    Transports streams are not supposed to use VFR, and the x264 command-line should have included the --force-cfr switch.
    So is there a definite way to fix that? It seems that tsMuxer is 32-bit only (I don't have any 32-bit libraries installed or the ability to run 32-bit programs compiled into the kernel), so I can't check it out right now. [rant]I don't know why software makers keep pushing 32-bit binaries (especially for linux). Have they even made 32-bit processors in the past few years (I remember Mozilla saying for a long time "you don't need a 64-bit browser" - yes, I do. I am unable to run the 32-bit version).[/rant] If tsMuxer will work, I guess I can download a 32-but live DVD of some linux distribution, and boot into it, but that is a PITA.
    Quote Quote  
  7. Member netmask56's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Search Comp PM
    You could use ProjectX. It is available for Windows MAC and Linux. If you have any problems setting it up pm me and I will send the ini file that will set it up. Also I noted AAC audio with mixing mode ADTS this has been known to cause problems for some media players. By demuxing it will be an easy job to convert the audio to something else. AC3 or MP3 etc...
    SONY 75" Full array 200Hz LED TV, Yamaha A1070 amp, Zidoo UHD3000, BeyonWiz PVR V2 (Enigma2 clone), Chromecast, Windows 11 Professional, QNAP NAS TS851
    Quote Quote  
  8. So I have sort of an acceptable solution. The trick is to process (copy) the file with ffmpeg first.

    Code:
    $ ffmpeg -i file.ts -c copy file-ffmpeg.ts
    So that adds about 40 MB to a 650 MB file, but also adds (according to mediainfo):

    Code:
    Menu
    ID                                       : 4096 (0x1000)
    Menu ID                                  : 1 (0x1)
    Duration                                 : 42mn 30s
    List                                     : 257 (0x100) (AVC) / 258 (0x101) (AAC)
    Service name                             : Service01
    Service provider                         : FFmpeg
    Service type                             : digital television
    Then if I do:

    Code:
    $ mkvmerge -o file.mkv file-ffmpeg.ts
    I end up with an acceptable (though not perfect) mkv file (smaller than the original .ts file). When I play it, the sound synchronization still wanders around, but it is usually between +/- 0.050 seconds, and only goes above 0.100 seconds a few times a minute, so it is barely noticeable.
    Quote Quote  
  9. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    FWIW:

    http://forum.doom9.org/showthread.php?t=152419

    Caveat: "win32 only" --- so you would have to use WINE as well.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!