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.










share|improve this question









New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    2 days ago










  • I don't have the original MP4 file as I told you earlier. @slhck
    – emb-pro
    2 days ago















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.










share|improve this question









New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    2 days ago










  • I don't have the original MP4 file as I told you earlier. @slhck
    – emb-pro
    2 days ago













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.










share|improve this question









New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago





















New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 13 at 10:43









emb-pro

12




12




New contributor




emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






emb-pro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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
    2 days ago










  • I don't have the original MP4 file as I told you earlier. @slhck
    – emb-pro
    2 days ago














  • 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
    2 days ago










  • I don't have the original MP4 file as I told you earlier. @slhck
    – emb-pro
    2 days ago








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
2 days ago




Actually the .ts file is created by mp4 file. That's why I said like that.
– emb-pro
2 days ago












I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
2 days ago




I don't have the original MP4 file as I told you earlier. @slhck
– emb-pro
2 days ago










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.






share|improve this answer























  • 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
    2 days ago












  • 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
    2 days ago












  • I understood, could you please make it for me.
    – emb-pro
    2 days ago










  • 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
    2 days ago










  • 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
    yesterday













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






emb-pro is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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

























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.






share|improve this answer























  • 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
    2 days ago












  • 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
    2 days ago












  • I understood, could you please make it for me.
    – emb-pro
    2 days ago










  • 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
    2 days ago










  • 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
    yesterday

















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.






share|improve this answer























  • 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
    2 days ago












  • 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
    2 days ago












  • I understood, could you please make it for me.
    – emb-pro
    2 days ago










  • 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
    2 days ago










  • 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
    yesterday















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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered 2 days ago









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
    2 days ago












  • 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
    2 days ago












  • I understood, could you please make it for me.
    – emb-pro
    2 days ago










  • 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
    2 days ago










  • 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
    yesterday




















  • 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
    2 days ago












  • 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
    2 days ago












  • I understood, could you please make it for me.
    – emb-pro
    2 days ago










  • 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
    2 days ago










  • 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
    yesterday


















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
2 days ago






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
2 days ago














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
2 days ago






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
2 days ago














I understood, could you please make it for me.
– emb-pro
2 days ago




I understood, could you please make it for me.
– emb-pro
2 days ago












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
2 days ago




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
2 days ago












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
yesterday






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
yesterday












emb-pro is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Index of /

Tribalistas

Listed building