2

24/06/2024: [Presentation of the problem]

I had dowloaded some videos from the Internet, few years ago.

I obtained many files:

  • a series of files in .ts
  • a single file playlist.m3u8

In my example: A series of 318 files named from segment1_1_av.ts to segment318_1_av.ts

I try to merge the series of .ts files, with this command-line of Powershell:

ffmpeg -i playlist.m3u8 -c copy out.ts

It seems to fail due to what is written in playlist.m3u8

Copie écran message d'erreur

When I edit (with Notepad) playlist.m3u8, I obtain :

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-ALLOW-CACHE:YES
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment1_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment2_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment3_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment4_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment5_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment6_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment7_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment8_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment9_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment10_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment11_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment12_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment13_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment14_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment15_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment16_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment17_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment18_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment19_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment20_1_av.ts
#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment21_1_av.ts
    
[…]

#EXTINF:10.000,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment317_1_av.ts
#EXTINF:6.520,
http://arteptweb-vh.akamaihd.net/i/am/ptweb/069000/069800/069809-001-A_0_VOF_AMM-PTWEB_XQ.seC11KAAU2.smil/segment318_1_av.ts
#EXT-X-ENDLIST

I don't know what to modify in playlist.m3u8. Could you tell me what a correct playlist.m3u8 should contain, or should look like? So I will be able to manually correct the playlist.m3u8 that I have.

NB: The .ts files are all on my hard drive (they are not on http://arteptweb-vh.akamaihd.net, Internet adress which is obsolete today).

PS: I use Win 10.

26/06/2024:

I have followed the advices of JayCravens (to begin with his second method, because it is less abstract for me…):

  1. I renamed my playlist.m3u8 file to playlist.m3u
  2. I modified the content of playlist.m3u:

#EXTM3U #EXT-X-PLAYLIST-TYPE:EVENT #EXT-X-VERSION:4 #EXT-X-MEDIA-SEQUENCE:1 #EXTINF:10.00, segment1_1_av.ts

// List of files 2 and 317 go here.

#EXTINF:6.520, segment318_1_av.ts #EXT-X-ENDLIST

NB : I only have let (I don't know if I have been wright?):

#EXTINF:6.520, segment318_1_av.ts #EXT-X-ENDLIST

in stade of #EXTINF:10, segment318_1_av.ts

  1. To finish : ffmpeg -i playlist.m3u -codec copy output.mkv

→ The result: I obtain an output.mkv file. When I play (with VLC) this output.mkv file : I have fastly review it, and it seems to me perfect…

However, I noted two things written in red, with Powershell:

[NULL @ 000002c0bd2bad40] non-existing SPS 0 referenced in buffering period

[h264 @ 000002c0bd29c0c0] non-existing SPS 0 referenced in buffering period

enter image description here

enter image description here

Source : From m3u8/ts files to mp4

4
  • 1
    Just curious... Did it require you to change the TS on the last segment #EXTINF:6.520, segment318_1_av.ts for it to work?
    – JayCravens
    Commented yesterday
  • @JayCravens — I wrote #EXTINF:6.520, for the last segment, uniquely because in the original playlist.m3u8, it was written #EXTINF:6.520 ! I didn't know if #EXTINF:10.000 was an error or not... Today I have tried with #EXTINF:10.000, segment318_1_av.ts, and it works perfectly to! — On the other hand, the final term #EXT-X-ENDLIST seems to be obligatory: I tried without it and the process failed... — JayCravens, I am grateful for the help you gave me. Thank you so much. Now I am able to merge videos stocked on my PC since more eight years. 😃
    – dg lr
    Commented 19 hours ago
  • 1
    @Destroy666: You're perfectly right, sorry. So I have edited my post and included a screen shot. ;-)
    – dg lr
    Commented 19 hours ago
  • No problem. :-) I was pretty certain the #EXTINF: value can be > or = to. I updated the answer to include #EXT-X-ENDLIST. Good stuff!
    – JayCravens
    Commented 15 hours ago

1 Answer 1

1

You might be able to get away with:

ffmpeg -f mpegts -i segment%03d_1_av.ts -codec copy -map 0:0 -map 0:1 output.mkv

Otherwise...

playlist.m3u

#EXTM3U
#EXT-X-PLAYLIST-TYPE:EVENT
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXTINF:10.00,
segment1_1_av.ts

// List of files 2 through 317 go here.

#EXTINF:10.0,
segment318_1_av.ts
#EXT-X-ENDLIST 
ffmpeg -i playlist.m3u -codec copy output.mkv

The SPS 0 means the original source was a UDP stream, possibly from a DVB satellite receiver. If you didn't have the files, looks like it would have failed.

5
  • JayCravens, Thank you very much for your helpful answer. I had few more questions about it: I have conserved the final lines: #EXTINF:6.520, segment318_1_av.ts #EXT-X-ENDLIST (as the original .m3U8 file…), in stade of #EXTINF:10, segment318_1_av.ts Was it a good idea?
    – dg lr
    Commented 2 days ago
  • You have chosen to create an output file in mkv: Is there a specific reason, or can we create without problem an ouput file in .ts? with ffmpeg -i playlist.m3u -codec copy output.ts?
    – dg lr
    Commented 2 days ago
  • Are the two things written in red, with Powershell a source of problem for playing final output file obtained? [NULL @ 000002c0bd2bad40] non-existing SPS 0 referenced in buffering period [h264 @ 000002c0bd29c0c0] non-existing SPS 0 referenced in buffering period
    – dg lr
    Commented 2 days ago
  • I don't understand EXTINF (= EXTernal INFormation): EXTINF specifies the duration of a Media Segment, but when I look at the file properties, it is written (in the details tab): 9 seconds. So why in my .m3u8 file is it written #EXTINF:10.0, and not #EXTINF:9.0???
    – dg lr
    Commented 2 days ago
  • 1
    @dglr #EXTINF: will be valid as long as its the same time or longer. It's a slight overlap to help avoid issues. The red messages shouldn't cause an issue.
    – JayCravens
    Commented 2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .