Convert TS files to DVD in Linux
I have a dreambox satellite receiver and it records to a transport stream (TS) mpeg2 form. Since dvd's are also in mpeg2 format there is no need to transcode the TS files. I have put together a script that will do the job very quickly. I borrowed some code that I found in forums and on some websites. I also had a little help from the ubuntu forums to get some of the zenity options working correctly.
This script only requires that you have previously installed dvdauthor, mkisofs, and mencoder. Some distrobutions may not already have these packages installed.
The TS2ISO script will also require that you have some extra room on your hard disk for the new iso file and also the temp files. Generally at least double the size of the original TS file.
When you run the script you will be asked what file you would like to convert. Then you will be asked what you would like to name the output file.
Next you will be asked what the audio pid of the file is.
(This was due to multiple audio tracks in the stream)
Some recordings have multiple audio in the stream and some do not.
At this point 'mencoder' will find out the details of the video and if it has several languages in the stream. This is an example of what you will be looking for
VIDEO MPEG2(pid=4898) AUDIO MPA(pid=4899)
If the the video and the audio pid are only one number apart you can just enter the audio pid number. If the numbers are two numbers apart, ie: 4898 and 4900 then there is more than one audio language in the stream. (maybe spanish).
If you would like to select english then select the number between the audio pid and the video pid.
If you would like to burn in the other language then select the actual audio pid number.
Once the script has completed, the tmp folder will be deleted and there will be a file in the same folder that you ran the script from named "output".iso.
You are now ready to use your favorite burning software to burn the iso to disk.
Or if you are using nautilus you can just right click on the iso file and select 'write to disk'
That's it.
I have only tested this on Ubuntu but it should work in any other distribution.
I have had trouble with older dvd players, playing the video back properly.
Inside the script you will see that I have set the chapters to 5 minute intervals.
As you will see in the script, it is easily changed to 10 minutes.
I do recommend testing the script to see if the language is ok and that there are no video problems. I like to use vlc media player to test the iso files.
If you would like to make changes to this script and submit them to me, I would gladly give credit here on my site.
Screenshots




Update:
Added detection of user cancelation
Update:
I finally turned this script into a nautilus script Pay close attension to the way that the audio pid is presented to the user.
The only was I was able to make this work was to output some information to a text file and then have 'ts2iso' open the file in 'gedit' so that you can provide your audio pid. If you have a different choise of text editor you can simply change it in the script.
Just save the script to '~/.gnome2/nautilus-scripts/', make the script is executable
chmod +x ~/.gnome2/nautilus-scripts/ts2iso
Then all you have to do is right click on the .ts file and select Scripts>ts2iso.
- Add new comment
- 1345 reads


Editing TS files
Hi, Fantastic script!
but as always, there those who want more...
Is there a way to cut some unwanted frames (at start and the end of a TS file)?
I looked at DVBCUT, but it outputs an MPEG file, which could no longer be used with your script (or could it?)
Thanks for any ideas
Mat
Editing TS files
I have not tried dvbcut but I think the script should still work. If mencoder can still see the file as mpeg2, you shouldn't have any problems.
I haven't used it for a while but avidemux can trim all kinds of video files including ts. Just remember to change the "FORMAT" option in the left column from avi to mpeg-ts before you save the file.
I tried the script on an ogg file that I created the other day with recordmydesktop and it worked.
script isn't working right
everything is working but the script doesn't give the pid number.
This is all it gives me.
MEncoder dev-SVN-r26936-4.3.0 (C) 2000-2008 MPlayer Team
CPU: AMD Athlon(tm) XP 1800+ (Family: 6, Model: 8, Stepping: 1)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled with runtime CPU detection.
success: format: 0 data: 0x0 - 0x1000
Exiting...
any ideas?
script isn't working right
The first file is just a script. Run the script and select the file you want to convert.
The second one is a nautilus script. If you just run this script without passing the file name to it, ie:
then it will act as you say.
Try running the command:
If this does the trick, download the first one and run that one from the command line.
The nautilus script will give you a context menu under "scripts" when you right click on the .ts file.
ts2iso
Great, just what I have been looking for. Script works a treat. I edited the script so that all the files are created in the working directory, where the script lives, so instead of /tmp/vob I used ./tmp/vob. This was simply because of space issues in my home and filesystem.
If I can figure out how it does it, I'll try to add a background image and menu as well.
Many thanks
Jose