Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: HOWTO: Convert .ts to .mkv

  1. #1
    Join Date
    Apr 2007
    Beans
    44

    Lightbulb HOWTO: Convert .ts to .mkv

    Hello,

    I searched several hours to do this conversation, thats why im sharing this here. MPEG transport stream, which is usullay a .ts files, is often used in TV broadcasting. So with this guide you can convert recorded TV-streams (HDTV and SDTV) into mkv files. Note: There is no reencoding/compression of video or sound streams! When it is MPEG-2 before, its MPEG-2 after too!

    Motivation
    Why would I want to convert a .ts file to .mkv? There are two main reasons for me: First, Matroska (mkv) is an open Video Container with broad support. Second, Matroska files are smaller then .ts files (around 3%, without additional compression, just less overhead!). Additional, you can define more Metainformation for the streams (e.x. audio language)

    Demuxing .ts file
    I did this with TsRemux from dmz01 over at doom9.org. There is no native Linux version! It's written in .NET, so we can use Mono to run it under Linux (tested with 0.21.2).

    First we need to install additional Mono libraries.
    Code:
      $ sudo aptitude install libmono-winforms2.0-cil
    Then you have to download TsRemux from this thread in the doom9.org Forum.

    To start this TsRemux use this command:
    Code:
      $ mono TsRemux.exe


    At the main window you can open your .ts-file. Once opened, you should see a stream list in the left box. Right click an a stream and select "Demux ... to elementary stream". A filename you can use anything you want, its probably a good idea to name it after the content, for example out.mpeg or out.avc.

    Once demuxed, you can get over and remux it to a mkv-file.

    Muxing to a .mkv file

    This is done using mkvmerge from the mkvtoolnix program suite. We also need mplayer do determine the fps of the .ts stream. There may be an easier method... It doesnt matter from where you now the fps of your .ts stream, the number is all that counts ! It is all contained in the repository, so we use a little aptitude magic again:
    Code:
      $ sudo aptitude install mkvtoolnix mkvtoolnix-gui mplayer
    You can run the GUI using this command:
    Code:
      $ mmg
    Now you can add the streams demuxed before with the add button.


    You may get a warning that the number of frames per seconds could not be determined. We can do this using mplayer from the console on the original .ts file:

    Code:
      $ mplayer input.ts
    You get an output like this:
    Code:
    MPlayer 1.0rc2-4.2.3 (C) 2000-2007 MPlayer Team
    CPU: AMD Athlon(tm) 64 Processor 3200+ (Family: 15, Model: 31, Stepping: 0)
    CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
    Compiled with runtime CPU detection.
    mplayer: could not connect to socket
    mplayer: No such file or directory
    Failed to open LIRC support. You will not be able to use your remote control.
    
    Playing Desktop/arte.hd.ts.
    TS file format detected.
    VIDEO H264(pid=120) AUDIO MPA(pid=131) NO SUBS (yet)!  PROGRAM N. 3585
    FPS seems to be: 25.000000
    xscreensaver_disable: Could not find XScreenSaver window.
    ==========================================================================
    Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
    Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
    ==========================================================================
    ==========================================================================
    Forced audio codec: mad
    Opening audio decoder: [libmad] libmad mpeg audio decoder
    AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
    Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
    ==========================================================================
    AO: [pulse] Failed to connect to server: Connection refused
    [AO_ALSA] alsa-lib: pcm_hw.c:1099:(snd_pcm_hw_open) open /dev/snd/pcmC0D0p failed: Device or resource busy
    [AO_ALSA] alsa-lib: pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
    [AO_ALSA] Playback open error: Device or resource busy
    [AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy
    [AO_ALSA] alsa-lib: pcm_hw.c:1099:(snd_pcm_hw_open) open /dev/snd/pcmC0D0p failed: Device or resource busy
    [AO_ALSA] alsa-lib: pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
    [AO_ALSA] Playback open error: Device or resource busy
    [AO ARTS] loading the aRts backend "/usr/lib/libartscbackend.la" failed
    [AO ESD] latency: [server: 0.24s, net: 0.00s] (adjust 0.24s)
    AO: [esd] 48000Hz 2ch s16le (2 bytes per sample)
    Starting playback...
    You have to set this frame rate in the "Format specific options" Tab of the Video stream under "FPS".

    Once all streams are added, you can define an output filename and start muxing! You're done!

    If audio is not sync with video, you may have taken a wrong FPS-rate....
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Beans
    2

    Re: HOWTO: Convert .ts to .mkv

    Thank you falstaff. It is very useful to know the TsRemux.exe program can run in linux.

  3. #3
    Join Date
    Apr 2006
    Beans
    1

    Re: HOWTO: Convert .ts to .mkv

    This...

    Code:
    ffmpeg -i input.ts -vcodec copy -sameq -acodec copy -f matroska output.mkv
    ...works as well, and doesn't require installing mono.

  4. #4
    Join Date
    Nov 2005
    Location
    Connecticut
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Convert .ts to .mkv

    Quote Originally Posted by EzInKy View Post
    This...

    Code:
    ffmpeg -i input.ts -vcodec copy -sameq -acodec copy -f matroska output.mkv
    ...works as well, and doesn't require installing mono.
    When i try that i get the response of

    Code:
     Unable for find a suitable output format for 'output.mkv'
    Did you have to compile your version of FFMpeg a certain way?

  5. #5
    Join Date
    Oct 2007
    Location
    Croatia
    Beans
    71
    Distro
    Ubuntu Development Release

    Re: HOWTO: Convert .ts to .mkv

    it doesnt work for me with ffmpeg...can you help me.?

  6. #6
    Join Date
    Sep 2006
    Beans
    3,713

    Re: HOWTO: Convert .ts to .mkv

    Quote Originally Posted by bebox View Post
    it doesnt work for me with ffmpeg...can you help me.?
    Show the complete FFmpeg output.

  7. #7
    Join Date
    Nov 2005
    Location
    Connecticut
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Convert .ts to .mkv

    Quote Originally Posted by jimmah6786 View Post
    When i try that i get the response of

    Code:
     Unable for find a suitable output format for 'output.mkv'
    Did you have to compile your version of FFMpeg a certain way?
    GOT IT!!
    Have to compile ffmpeg from source. Follow this link http://ubuntuforums.org/showthread.p...ht=ffmpeg+m2ts

  8. #8
    Join Date
    Sep 2010
    Beans
    26
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Convert .ts to .mkv

    It works.Thank you for tips.
    Last edited by tsx2424; January 22nd, 2012 at 07:45 PM.

  9. #9
    Join Date
    May 2013
    Beans
    1

    Re: HOWTO: Convert .ts to .mkv

    You don't have to demux TS input sources for mkvmerge GUI (/usr/bin/mmg). You can give it the TS as the input source, and it will see the A/V sources therein, and you can remux it without the intermediary step.

    Running 12.04LTS, which includes mkvmerge 5.1.0.

  10. #10
    Join Date
    Apr 2007
    Beans
    4

    Re: HOWTO: Convert .ts to .mkv

    [QUOTE=EzInKy;6013396]This...

    Code:
    ffmpeg -i input.ts -vcodec copy -sameq -acodec copy -f matroska output.mkv
    Change the code to this, It worked for me

    Code:
    ffmpeg -i input.ts -sn -vcodec copy -sameq -acodec copy -f matroska output.mkv

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •