How can I convert a .ts file to a single .m3u8 file using ffmpeg?
up vote
0
down vote
favorite
I have a .ts file, but I don't have the source file(video file). I need to generate a m3u8 file from the .ts file itself without creating other .ts files. I used the following command.
ffmpeg -i mytsfile.ts -hls_list_size 0 mym3u8.m3u8 -hide_banner
When I used the above command, it has created almost 590 ts files with the name of mym3u8N.ts(where N is number from 1 to 590). I dont want ts files. I need only m3u8 file.
ffmpeg
New contributor
add a comment |
up vote
0
down vote
favorite
I have a .ts file, but I don't have the source file(video file). I need to generate a m3u8 file from the .ts file itself without creating other .ts files. I used the following command.
ffmpeg -i mytsfile.ts -hls_list_size 0 mym3u8.m3u8 -hide_banner
When I used the above command, it has created almost 590 ts files with the name of mym3u8N.ts(where N is number from 1 to 590). I dont want ts files. I need only m3u8 file.
ffmpeg
New contributor
2
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a .ts file, but I don't have the source file(video file). I need to generate a m3u8 file from the .ts file itself without creating other .ts files. I used the following command.
ffmpeg -i mytsfile.ts -hls_list_size 0 mym3u8.m3u8 -hide_banner
When I used the above command, it has created almost 590 ts files with the name of mym3u8N.ts(where N is number from 1 to 590). I dont want ts files. I need only m3u8 file.
ffmpeg
New contributor
I have a .ts file, but I don't have the source file(video file). I need to generate a m3u8 file from the .ts file itself without creating other .ts files. I used the following command.
ffmpeg -i mytsfile.ts -hls_list_size 0 mym3u8.m3u8 -hide_banner
When I used the above command, it has created almost 590 ts files with the name of mym3u8N.ts(where N is number from 1 to 590). I dont want ts files. I need only m3u8 file.
ffmpeg
ffmpeg
New contributor
New contributor
edited Nov 13 at 11:13
New contributor
asked Nov 13 at 10:43
emb-pro
12
12
New contributor
New contributor
2
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40
add a comment |
2
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40
2
2
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
If you just want to generate an M3U8 file from an existing segment:
ffmpeg -i input.ts
-map 0 -c copy
-f segment -segment_list out.m3u8
-segment_time 60
out%03d.ts
Here, it's important that you specify a -segment_time
equal to or larger than the actual input duration, as otherwise, ffmpeg will split the input file again.
The output M3U8 will contain a reference to the newly output TS file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:61
#EXTINF:60.033333,
out000.ts
#EXT-X-ENDLIST
You may use that, or delete the out000.ts
file (since it's essentially the same as the input file), and change the file name in the M3U8 file, as the content of the media file will be the same.
You can do such a replacement e.g. using perl
:
perl -pi -e 's/out000.ts/input.ts'
I should add that for the simple case of one segment file of which you know the duration, you can easily generate the M3U8 file manually. You then have to specify the EXT-X-TARGETDURATION
and EXTINF:
duration values manually as well.
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the fileout000.ts
, but you have to manually change it toinput.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.
– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
If you just want to generate an M3U8 file from an existing segment:
ffmpeg -i input.ts
-map 0 -c copy
-f segment -segment_list out.m3u8
-segment_time 60
out%03d.ts
Here, it's important that you specify a -segment_time
equal to or larger than the actual input duration, as otherwise, ffmpeg will split the input file again.
The output M3U8 will contain a reference to the newly output TS file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:61
#EXTINF:60.033333,
out000.ts
#EXT-X-ENDLIST
You may use that, or delete the out000.ts
file (since it's essentially the same as the input file), and change the file name in the M3U8 file, as the content of the media file will be the same.
You can do such a replacement e.g. using perl
:
perl -pi -e 's/out000.ts/input.ts'
I should add that for the simple case of one segment file of which you know the duration, you can easily generate the M3U8 file manually. You then have to specify the EXT-X-TARGETDURATION
and EXTINF:
duration values manually as well.
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the fileout000.ts
, but you have to manually change it toinput.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.
– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
|
show 4 more comments
up vote
1
down vote
If you just want to generate an M3U8 file from an existing segment:
ffmpeg -i input.ts
-map 0 -c copy
-f segment -segment_list out.m3u8
-segment_time 60
out%03d.ts
Here, it's important that you specify a -segment_time
equal to or larger than the actual input duration, as otherwise, ffmpeg will split the input file again.
The output M3U8 will contain a reference to the newly output TS file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:61
#EXTINF:60.033333,
out000.ts
#EXT-X-ENDLIST
You may use that, or delete the out000.ts
file (since it's essentially the same as the input file), and change the file name in the M3U8 file, as the content of the media file will be the same.
You can do such a replacement e.g. using perl
:
perl -pi -e 's/out000.ts/input.ts'
I should add that for the simple case of one segment file of which you know the duration, you can easily generate the M3U8 file manually. You then have to specify the EXT-X-TARGETDURATION
and EXTINF:
duration values manually as well.
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the fileout000.ts
, but you have to manually change it toinput.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.
– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
|
show 4 more comments
up vote
1
down vote
up vote
1
down vote
If you just want to generate an M3U8 file from an existing segment:
ffmpeg -i input.ts
-map 0 -c copy
-f segment -segment_list out.m3u8
-segment_time 60
out%03d.ts
Here, it's important that you specify a -segment_time
equal to or larger than the actual input duration, as otherwise, ffmpeg will split the input file again.
The output M3U8 will contain a reference to the newly output TS file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:61
#EXTINF:60.033333,
out000.ts
#EXT-X-ENDLIST
You may use that, or delete the out000.ts
file (since it's essentially the same as the input file), and change the file name in the M3U8 file, as the content of the media file will be the same.
You can do such a replacement e.g. using perl
:
perl -pi -e 's/out000.ts/input.ts'
I should add that for the simple case of one segment file of which you know the duration, you can easily generate the M3U8 file manually. You then have to specify the EXT-X-TARGETDURATION
and EXTINF:
duration values manually as well.
If you just want to generate an M3U8 file from an existing segment:
ffmpeg -i input.ts
-map 0 -c copy
-f segment -segment_list out.m3u8
-segment_time 60
out%03d.ts
Here, it's important that you specify a -segment_time
equal to or larger than the actual input duration, as otherwise, ffmpeg will split the input file again.
The output M3U8 will contain a reference to the newly output TS file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:61
#EXTINF:60.033333,
out000.ts
#EXT-X-ENDLIST
You may use that, or delete the out000.ts
file (since it's essentially the same as the input file), and change the file name in the M3U8 file, as the content of the media file will be the same.
You can do such a replacement e.g. using perl
:
perl -pi -e 's/out000.ts/input.ts'
I should add that for the simple case of one segment file of which you know the duration, you can easily generate the M3U8 file manually. You then have to specify the EXT-X-TARGETDURATION
and EXTINF:
duration values manually as well.
edited Nov 15 at 10:33
answered Nov 13 at 12:20
slhck
157k46434461
157k46434461
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the fileout000.ts
, but you have to manually change it toinput.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.
– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
|
show 4 more comments
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the fileout000.ts
, but you have to manually change it toinput.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.
– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
I played the m3u8 file created by the command you mentioned, it played well. But when I delete the ts files(created by the command), the m3u8 file is not at all playing. Is there any reason for that?
– emb-pro
Nov 13 at 14:05
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the file
out000.ts
, but you have to manually change it to input.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.– slhck
Nov 13 at 14:14
Of course it won't work then. As I said, you can “delete it and change the file name in the M3U8 file”. The generated M3U8 will reference the file
out000.ts
, but you have to manually change it to input.ts
. Otherwise the player will look for the deleted file. If you open up the M3U8 file with a text editor you'll notice that there isn't much going on here—it's easy to just create it yourself.– slhck
Nov 13 at 14:14
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
I understood, could you please make it for me.
– emb-pro
Nov 13 at 14:43
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
How do you mean, make it for you? ffmpeg already created the M3U8 file for you. I'm just saying that in case you don't want to use ffmpeg, you could write a small script or use a text editor to type the M3U8 file similar to the one that ffmpeg automatically generates. You will only have to replace the duration values and file name.
– slhck
Nov 13 at 14:52
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
Hi, I created an m3u8 file as per you answer, but navigating through the video file(m3u8) is taking more time(almost 10 sec to play). This is very unusual. is there any alternative for this?
– emb-pro
Nov 14 at 12:05
|
show 4 more comments
emb-pro is a new contributor. Be nice, and check out our Code of Conduct.
emb-pro is a new contributor. Be nice, and check out our Code of Conduct.
emb-pro is a new contributor. Be nice, and check out our Code of Conduct.
emb-pro is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1374995%2fhow-can-i-convert-a-ts-file-to-a-single-m3u8-file-using-ffmpeg%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
2
What do you mean by "you don't have the source file". The .ts file is a video file, no? Please explain what you are trying to do.
– slhck
Nov 13 at 10:55
Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
Nov 13 at 11:09
I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
Nov 13 at 11:40