merge/join/concatenate hundreds of ts files into one ts file
up vote
3
down vote
favorite
Downloading a video stream with curl, I ended up with ~400 *.ts files, each about 1MB in size. They are sequentially numbered video1.ts, video2.ts, ...video400.ts. I now need to concatenate them into one file, obviously in the right order (so video10.ts should be followed by video11.ts and not video110.ts).
I've tried to come up with something like "for i in *.ts; do ...." but I just can't figure it out. Also ffmepg and avconv are too complicated for me.
Who knows how to join these 400 files in the right oreder, into a new file? Thx!
ubuntu video merge
add a comment |
up vote
3
down vote
favorite
Downloading a video stream with curl, I ended up with ~400 *.ts files, each about 1MB in size. They are sequentially numbered video1.ts, video2.ts, ...video400.ts. I now need to concatenate them into one file, obviously in the right order (so video10.ts should be followed by video11.ts and not video110.ts).
I've tried to come up with something like "for i in *.ts; do ...." but I just can't figure it out. Also ffmepg and avconv are too complicated for me.
Who knows how to join these 400 files in the right oreder, into a new file? Thx!
ubuntu video merge
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Downloading a video stream with curl, I ended up with ~400 *.ts files, each about 1MB in size. They are sequentially numbered video1.ts, video2.ts, ...video400.ts. I now need to concatenate them into one file, obviously in the right order (so video10.ts should be followed by video11.ts and not video110.ts).
I've tried to come up with something like "for i in *.ts; do ...." but I just can't figure it out. Also ffmepg and avconv are too complicated for me.
Who knows how to join these 400 files in the right oreder, into a new file? Thx!
ubuntu video merge
Downloading a video stream with curl, I ended up with ~400 *.ts files, each about 1MB in size. They are sequentially numbered video1.ts, video2.ts, ...video400.ts. I now need to concatenate them into one file, obviously in the right order (so video10.ts should be followed by video11.ts and not video110.ts).
I've tried to come up with something like "for i in *.ts; do ...." but I just can't figure it out. Also ffmepg and avconv are too complicated for me.
Who knows how to join these 400 files in the right oreder, into a new file? Thx!
ubuntu video merge
ubuntu video merge
edited Jul 28 '14 at 19:10
An Dorfer
1,2032713
1,2032713
asked Oct 22 '13 at 13:36
user140222
2613
2613
add a comment |
add a comment |
6 Answers
6
active
oldest
votes
up vote
1
down vote
What sort of does the trick:
for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done
but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).
add a comment |
up vote
1
down vote
This is an old question but I hope the answer may add value for others.
Based on this reference, the following script will do the job, assuming ffmpeg 1.1
and later.
#!/bin/bash
for i in `seq 0 $totalNumberOfTsFiles`; do echo file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt -c copy output.ts
1
The entirefor
loop can probably be replaced by something likeseq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.
– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output ofls
is a pipe, it uses-1
mode automatically. You can see this by running plainls
and thenls | cat
. (2)ls
sorts its output by name unless you tell it not to, so you don’t needls | sort
.
– Scott
Oct 29 '17 at 18:09
add a comment |
up vote
0
down vote
Try the following command:
cat video?.ts video??.ts video???.ts > out.ts
The duration ofout.ts
will likely be that of the first video.
– Geremia
Feb 4 at 1:16
add a comment |
up vote
0
down vote
Best Solution:
Download TSSplitter, click "JOIN" tab and drag all files into the window!
add a comment |
up vote
0
down vote
filenames="`ls -rt1 $input | tr 'n' '|' | sed '$ s/.$//'`"
ffmpeg -i "concat:$filenames" -c copy out.ts
,
where $input
is the filename(s) or escaped regexp (e.g., *.ts).
add a comment |
up vote
0
down vote
All the answers to this question that mislead readers to concatenate the TS files before running ffmpeg are incorrect. To ensure the audio and video do not fall out of sync during the assembly of the mp4 stream, the poorly documented but important "-f concat" feature of ffmpeg should be used.
delimiterBeforeFileNumber="-"
ls |egrep '[.]ts$'
|sort "-t$delimiterBeforeFileNumber" -k2,2n
|sed -r "s/(.*)/file '1'/" >ts.files.txt
ffmpeg -f concat -i ts.files.txt -c copy tsw.014.ts.mp4
The two preparatory lines of code just create a file containing a list of TS files in this line format, which is used by ffmpeg like a playlist.
file 'seg-37-a.ts'
add a comment |
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
What sort of does the trick:
for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done
but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).
add a comment |
up vote
1
down vote
What sort of does the trick:
for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done
but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).
add a comment |
up vote
1
down vote
up vote
1
down vote
What sort of does the trick:
for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done
but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).
What sort of does the trick:
for i in `seq 1 400`; do cat "video$i.ts" >> newvideo.ts; done
but now the audio is out of sync by ~0.5s and there are ~0.5s silences every few seconds (presumably when fragments are glued together).
answered Oct 23 '13 at 13:43
user140222
2613
2613
add a comment |
add a comment |
up vote
1
down vote
This is an old question but I hope the answer may add value for others.
Based on this reference, the following script will do the job, assuming ffmpeg 1.1
and later.
#!/bin/bash
for i in `seq 0 $totalNumberOfTsFiles`; do echo file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt -c copy output.ts
1
The entirefor
loop can probably be replaced by something likeseq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.
– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output ofls
is a pipe, it uses-1
mode automatically. You can see this by running plainls
and thenls | cat
. (2)ls
sorts its output by name unless you tell it not to, so you don’t needls | sort
.
– Scott
Oct 29 '17 at 18:09
add a comment |
up vote
1
down vote
This is an old question but I hope the answer may add value for others.
Based on this reference, the following script will do the job, assuming ffmpeg 1.1
and later.
#!/bin/bash
for i in `seq 0 $totalNumberOfTsFiles`; do echo file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt -c copy output.ts
1
The entirefor
loop can probably be replaced by something likeseq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.
– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output ofls
is a pipe, it uses-1
mode automatically. You can see this by running plainls
and thenls | cat
. (2)ls
sorts its output by name unless you tell it not to, so you don’t needls | sort
.
– Scott
Oct 29 '17 at 18:09
add a comment |
up vote
1
down vote
up vote
1
down vote
This is an old question but I hope the answer may add value for others.
Based on this reference, the following script will do the job, assuming ffmpeg 1.1
and later.
#!/bin/bash
for i in `seq 0 $totalNumberOfTsFiles`; do echo file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt -c copy output.ts
This is an old question but I hope the answer may add value for others.
Based on this reference, the following script will do the job, assuming ffmpeg 1.1
and later.
#!/bin/bash
for i in `seq 0 $totalNumberOfTsFiles`; do echo file "'${i}.ts'" >> Input.txt ; done
/home/hq6/bin/ffmpeg-2.3.3/ffmpeg -f concat -i Input.txt -c copy output.ts
answered Sep 15 '14 at 6:14
merlin2011
67431022
67431022
1
The entirefor
loop can probably be replaced by something likeseq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.
– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output ofls
is a pipe, it uses-1
mode automatically. You can see this by running plainls
and thenls | cat
. (2)ls
sorts its output by name unless you tell it not to, so you don’t needls | sort
.
– Scott
Oct 29 '17 at 18:09
add a comment |
1
The entirefor
loop can probably be replaced by something likeseq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.
– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output ofls
is a pipe, it uses-1
mode automatically. You can see this by running plainls
and thenls | cat
. (2)ls
sorts its output by name unless you tell it not to, so you don’t needls | sort
.
– Scott
Oct 29 '17 at 18:09
1
1
The entire
for
loop can probably be replaced by something like seq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.– a CVn
Aug 28 '15 at 19:12
The entire
for
loop can probably be replaced by something like seq -f '%g.ts' 0 $totalNumberOfTsFiles
for a similar result with a much cleaner command line.– a CVn
Aug 28 '15 at 19:12
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output of
ls
is a pipe, it uses -1
mode automatically. You can see this by running plain ls
and then ls | cat
. (2) ls
sorts its output by name unless you tell it not to, so you don’t need ls | sort
.– Scott
Oct 29 '17 at 18:09
James Ivey: If you have a new idea for a different way to solve this problem, don’t try to post it in a comment (and don’t edit it into somebody else’s answer); post it as a new answer (in the “Your Answer” box at the bottom of the page). In case you’ve forgotten what you wanted to submit, you can review it here. Notes: (1) When the output of
ls
is a pipe, it uses -1
mode automatically. You can see this by running plain ls
and then ls | cat
. (2) ls
sorts its output by name unless you tell it not to, so you don’t need ls | sort
.– Scott
Oct 29 '17 at 18:09
add a comment |
up vote
0
down vote
Try the following command:
cat video?.ts video??.ts video???.ts > out.ts
The duration ofout.ts
will likely be that of the first video.
– Geremia
Feb 4 at 1:16
add a comment |
up vote
0
down vote
Try the following command:
cat video?.ts video??.ts video???.ts > out.ts
The duration ofout.ts
will likely be that of the first video.
– Geremia
Feb 4 at 1:16
add a comment |
up vote
0
down vote
up vote
0
down vote
Try the following command:
cat video?.ts video??.ts video???.ts > out.ts
Try the following command:
cat video?.ts video??.ts video???.ts > out.ts
edited Aug 28 '15 at 20:17
kenorb
10.6k1577109
10.6k1577109
answered Aug 28 '15 at 18:44
Roadowl
9215
9215
The duration ofout.ts
will likely be that of the first video.
– Geremia
Feb 4 at 1:16
add a comment |
The duration ofout.ts
will likely be that of the first video.
– Geremia
Feb 4 at 1:16
The duration of
out.ts
will likely be that of the first video.– Geremia
Feb 4 at 1:16
The duration of
out.ts
will likely be that of the first video.– Geremia
Feb 4 at 1:16
add a comment |
up vote
0
down vote
Best Solution:
Download TSSplitter, click "JOIN" tab and drag all files into the window!
add a comment |
up vote
0
down vote
Best Solution:
Download TSSplitter, click "JOIN" tab and drag all files into the window!
add a comment |
up vote
0
down vote
up vote
0
down vote
Best Solution:
Download TSSplitter, click "JOIN" tab and drag all files into the window!
Best Solution:
Download TSSplitter, click "JOIN" tab and drag all files into the window!
answered Apr 21 '17 at 16:23
T.Todua
1,40731628
1,40731628
add a comment |
add a comment |
up vote
0
down vote
filenames="`ls -rt1 $input | tr 'n' '|' | sed '$ s/.$//'`"
ffmpeg -i "concat:$filenames" -c copy out.ts
,
where $input
is the filename(s) or escaped regexp (e.g., *.ts).
add a comment |
up vote
0
down vote
filenames="`ls -rt1 $input | tr 'n' '|' | sed '$ s/.$//'`"
ffmpeg -i "concat:$filenames" -c copy out.ts
,
where $input
is the filename(s) or escaped regexp (e.g., *.ts).
add a comment |
up vote
0
down vote
up vote
0
down vote
filenames="`ls -rt1 $input | tr 'n' '|' | sed '$ s/.$//'`"
ffmpeg -i "concat:$filenames" -c copy out.ts
,
where $input
is the filename(s) or escaped regexp (e.g., *.ts).
filenames="`ls -rt1 $input | tr 'n' '|' | sed '$ s/.$//'`"
ffmpeg -i "concat:$filenames" -c copy out.ts
,
where $input
is the filename(s) or escaped regexp (e.g., *.ts).
answered Feb 4 at 1:20
Geremia
190116
190116
add a comment |
add a comment |
up vote
0
down vote
All the answers to this question that mislead readers to concatenate the TS files before running ffmpeg are incorrect. To ensure the audio and video do not fall out of sync during the assembly of the mp4 stream, the poorly documented but important "-f concat" feature of ffmpeg should be used.
delimiterBeforeFileNumber="-"
ls |egrep '[.]ts$'
|sort "-t$delimiterBeforeFileNumber" -k2,2n
|sed -r "s/(.*)/file '1'/" >ts.files.txt
ffmpeg -f concat -i ts.files.txt -c copy tsw.014.ts.mp4
The two preparatory lines of code just create a file containing a list of TS files in this line format, which is used by ffmpeg like a playlist.
file 'seg-37-a.ts'
add a comment |
up vote
0
down vote
All the answers to this question that mislead readers to concatenate the TS files before running ffmpeg are incorrect. To ensure the audio and video do not fall out of sync during the assembly of the mp4 stream, the poorly documented but important "-f concat" feature of ffmpeg should be used.
delimiterBeforeFileNumber="-"
ls |egrep '[.]ts$'
|sort "-t$delimiterBeforeFileNumber" -k2,2n
|sed -r "s/(.*)/file '1'/" >ts.files.txt
ffmpeg -f concat -i ts.files.txt -c copy tsw.014.ts.mp4
The two preparatory lines of code just create a file containing a list of TS files in this line format, which is used by ffmpeg like a playlist.
file 'seg-37-a.ts'
add a comment |
up vote
0
down vote
up vote
0
down vote
All the answers to this question that mislead readers to concatenate the TS files before running ffmpeg are incorrect. To ensure the audio and video do not fall out of sync during the assembly of the mp4 stream, the poorly documented but important "-f concat" feature of ffmpeg should be used.
delimiterBeforeFileNumber="-"
ls |egrep '[.]ts$'
|sort "-t$delimiterBeforeFileNumber" -k2,2n
|sed -r "s/(.*)/file '1'/" >ts.files.txt
ffmpeg -f concat -i ts.files.txt -c copy tsw.014.ts.mp4
The two preparatory lines of code just create a file containing a list of TS files in this line format, which is used by ffmpeg like a playlist.
file 'seg-37-a.ts'
All the answers to this question that mislead readers to concatenate the TS files before running ffmpeg are incorrect. To ensure the audio and video do not fall out of sync during the assembly of the mp4 stream, the poorly documented but important "-f concat" feature of ffmpeg should be used.
delimiterBeforeFileNumber="-"
ls |egrep '[.]ts$'
|sort "-t$delimiterBeforeFileNumber" -k2,2n
|sed -r "s/(.*)/file '1'/" >ts.files.txt
ffmpeg -f concat -i ts.files.txt -c copy tsw.014.ts.mp4
The two preparatory lines of code just create a file containing a list of TS files in this line format, which is used by ffmpeg like a playlist.
file 'seg-37-a.ts'
answered Nov 23 at 7:39
Douglas Daseeco
1011
1011
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f663687%2fmerge-join-concatenate-hundreds-of-ts-files-into-one-ts-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown