LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-15-2014, 11:36 PM   #1
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Rep: Reputation: 22
Media newbie: How do I stitch together multiple .ts files into a single video?


I have a digital TV recorder. It saves recordings in a directory named for the show I am recording e.g. 'ABC1-01012014-2210-ABC News Late Edition.pvr', as a sequence of .ts files e.g. 'data0001.ts' , 'data0002.ts', 'data0003.ts' and a text file called 'MM_PLAY_TIME.ini'.

A web search indicated that .ts files are MPEG2 Transport Stream files and can be converted to MPEG2 Program Stream (.ps) files, for better interoperability with a wide range of players.

I can play all the .ts files, sequentially, on my Fedora 19 box, using VLC Media Player, but is there a way to stitch them together into a single file, so I can see the whole program without interruption?

If I can get that far, I believe a tool like avidemux will allow me to convert the file to .ps - does that sound right?

Any help would be appreciated.
 
Old 01-16-2014, 03:15 PM   #2
ukiuki
Senior Member
 
Registered: May 2010
Location: Planet Earth
Distribution: Debian
Posts: 1,030

Rep: Reputation: 385Reputation: 385Reputation: 385Reputation: 385
There is a video editor for GNU/Linux, Openshot, with that you may be able to merge the videos. It is probably available in Fedora repositories.

Regards

Last edited by ukiuki; 01-16-2014 at 03:19 PM.
 
Old 01-17-2014, 03:51 PM   #3
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Thanks ukiuki. I will explore Openshot and see what it can do.
 
Old 01-17-2014, 04:28 PM   #4
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I would think concatenating them with 'cat' might work. No harm in trying, just output to a different file.
 
Old 01-18-2014, 12:28 AM   #5
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Thanks, metaschima. Unfortunately, each of the first three files is 2.1Gb, so cat tries to create a humungous file, which does not work on my 32 bit platform. I only know, because I tried and it went 'bang' <grin>.
 
Old 01-18-2014, 01:15 AM   #6
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Hmmmm .... I was wrong about the file size issue. I used avidemux, which opened the first file in the sequence and noticed the rest were sequentially numbered, so offered to open them all. I did this, set the output format to 'Mpeg-PS Muxer(ff)' and chose to 'Save', which asked for a target filename, then happily created a 6.5Gb file out of it. I have yet to play the file, so cannot assert everything went well, but the indications so far are good.

If the new file plays nicely, I will try using Openshot, to trim the opening and closing extra few minutes I recorded, to make sure I captured the whole movie. So far, so good.
 
Old 01-18-2014, 01:29 AM   #7
RootMason
Member
 
Registered: Oct 2012
Location: Tucson, AZ
Distribution: Debian/CentOS
Posts: 124

Rep: Reputation: 5
In Linux a simple "cat file2.ts >> file1.ts" will add file2.ts to the end of file1.ts.
 
Old 01-18-2014, 02:26 AM   #8
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Well, OpenShot just died when I tried to play the file, so I used avidemux to trim the unwanted parts and ended up with a three-hour movie, which is what I wanted.

Thanks all for your help
 
Old 01-19-2014, 09:49 PM   #9
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Sequel:

The movie I eneded up with was a 5.8Gb file. To shrink it to fit a DVD, I used ffmpeg and specified a lower bit rate per second. As this was going to be a shrunk file, I told ffmpeg to output to 'shrunk.mpg'. When I was sure it was small enough (4.7Gb), I checked that Brasero would accept it for writing to a DVD. Brasero was happy with 'shrunk.mpg', but when I renamed the file to '<real movie name>.mpg', Braseo reported the error "<real movie name.mpg> is not suitable for audio or video media". I renamed it back to 'shrunk.mpg' and Brasero was happy again, so it seems Brasero checks the content of the file, to ensure some internal identifier matches the filename. Weird, to a newbie, but glad it is solved.

For the sake of anyone following this thread, the ffmpeg command line I used, to shrink a 5.8Gb file at 4150 kbits per second, to a 4.7Gb file, was:
ffmpeg -i <big filename>.mpg -c:v mpeg2video -b:v 3200k shrunk.mpg

Incidentally, I first tried limiting the file size by using the file size limit option to ffmpeg as '-fs 4700MiB', but this option was ignored, which is why I had to play around with the bit rate, until I ended up with an output file small enough to burn to DVD. Of course, I may have used incorrect syntax for this option, but I checked that it follows what the man page said. Also, first attempts had ffmpeg convert the output to mpeg1video, which is why I had to specify mpeg2video for the video stream. Curious.
 
1 members found this post helpful.
Old 01-25-2015, 02:08 AM   #10
CaptSaltyJack
LQ Newbie
 
Registered: May 2013
Posts: 6

Rep: Reputation: Disabled
Quote:
Originally Posted by RootMason View Post
In Linux a simple "cat file2.ts >> file1.ts" will add file2.ts to the end of file1.ts.
This guy right here has the answer. No crazy software needed.

cat file1.ts file2.ts file3.ts file4.ts > full_video.ts

Done.
 
Old 01-26-2015, 06:43 PM   #11
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by CaptSaltyJack View Post
cat file1.ts file2.ts file3.ts file4.ts > full_video.ts
Thanks CaptSaltyJack. I was unsure if video files contained any wrappers or similar to specify their start and end points, in which case a simple cat might have resulted in unreadable output. I'm glad to have it clarified. "8-)
 
Old 01-27-2015, 04:49 PM   #12
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by Doug Hutcheson View Post
Thanks CaptSaltyJack. I was unsure if video files contained any wrappers or similar to specify their start and end points, in which case a simple cat might have resulted in unreadable output. I'm glad to have it clarified. "8-)
Actually, this is often a concern. It will likely work, but you won't be able to seek, files will play far past their limit (cat 2 30sec files together and you get a clip that says it's 30 sec long but plays for 60 sec)
This is with files that aren't intended to be split or combined (eg mp4, ogg, mp3)
If your files were split after being encoded, the below doesn't apply.

I would consider cat the quick & dirty fix - since it works, but I would suggest using ffmpeg to put them together is you want it to look nice

Here's a guide.
https://trac.ffmpeg.org/wiki/Concatenate

Last edited by Miati; 01-27-2015 at 04:55 PM.
 
Old 01-27-2015, 04:51 PM   #13
CaptSaltyJack
LQ Newbie
 
Registered: May 2013
Posts: 6

Rep: Reputation: Disabled
Strange, I used the cat method to concatenate 500 separate TS files together, then load into Adobe Premiere to export as MP4. Worked totally fine. Maybe I got lucky.

Will use ffmpeg next time, thanks for the tip!
 
Old 01-27-2015, 05:04 PM   #14
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by CaptSaltyJack View Post
Strange, I used the cat method to concatenate 500 separate TS files together, then load into Adobe Premiere to export as MP4. Worked totally fine. Maybe I got lucky.
It's important to consider when / why it's being split or combined.

I'm not familiar with .ts files, but if they are simply a sequential organized parts of a file with the first containing all info needed, concatenating them is fine (& the right thing to do)
On the other hand, concatenating a ogg file with another will likely make it work until the first song ends - then do something (good or bad)
Then using ffmpeg to re-write the correct info is the right thing to do in that scenario.

From the OP, it looks like they were mpeg2 files, so I would go with ffmpeg.
However, if a simple cat did it & there's no issues with seek or anything - go with it (it's easier).
 
Old 01-27-2015, 05:07 PM   #15
CaptSaltyJack
LQ Newbie
 
Registered: May 2013
Posts: 6

Rep: Reputation: Disabled
TS = MPEG2 parts.

Any seek issues would've been eliminated when I converted it to H.264 MP4, I would think?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete a single E-mail / multiple mbox files mgichoga Debian 0 02-18-2007 08:42 PM
Adding Multiple Files In A Single Gz File onacorpuscle Linux - Newbie 3 08-31-2006 03:18 AM
How To Merge multiple files into a single PDF ? kkempter Linux - Software 1 10-28-2005 01:02 PM
Is there a simple utility that can stitch multiple images into one? davee Linux - Software 3 08-09-2004 02:28 AM
One Machine, Multiple NICs, and a single Newbie CozyMel Linux - Networking 2 10-09-2002 12:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration