ffmpeg - Convert .png segment of HLS to mp3 - Stack Overflow

admin2025-05-02  1

I have url of HLS:

/m3u8/tp1-rdv1/1080/642bce856edd7cab511931a2/647af249adaf446b461a374e/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/2a2415eaeec82cbf16cebbf974a372e0

It contains links to segments:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007927d1e7a824e88d90e17fc925d914a006873ed08c7ecb7107e7a72b810e66a2cf/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c37bc9a36794c836b2cc1c80b4c82aff3e/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/96902c1c0db5b15f08a07d5264361f76
#EXTINF:6,
/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007927d1e7a824e88d90e17fc925d914a0066544f42d5295cd71e2423a54702ca79a/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3fa2a9b2a1346c4d1e2dc5c86583c6eca67d125b9be8ecfee724eea988e5948be/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/8e029c34700e193599b52db66deeb735
...
#EXTINF:6,
/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007923834b9bbcad67c4f65be31cff40707486e081644f595435073518177e606a22/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3ddcf230599d82c80aa1c0d846a87eccbd425fffb2434464a4aea5eecb13bf477/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/63ae374ce1012f9b702a082f691edfd8
#EXTINF:2.24,
/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007923834b9bbcad67c4f65be31cff407074bce293bef2086d37ff74c808d35023d5/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3514fc67bd369ecc7b2b8d0fa501094d2da0625e9796bde32b6f9a9cb5d278ec3/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/ae04e0aa6d021a973852ee444489eec0
#EXT-X-ENDLIST

I can download any segment and play it using ExoPlayer in Android, but I can't convert it to mp3 or mp4 using ffmpeg.

For example this command:

ffmpeg -i /Users/user1/Downloads/response0.png /Users/user1/Downloads/response0.mp3

returns this:

  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
Input #0, png_pipe, from '/Users/user1/Downloads/response0.png':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: png, ya8(pc, gbr/unknown/unknown), 1x1, 25 fps, 25 tbr, 25 tbn
Output #0, mp3, to '/Users/user1/Downloads/response0.mp3':
[out#0/mp3 @ 0x7fe879206b00] Output file does not contain any stream
Error opening output file /Users/user1/Downloads/response0.mp3.
Error opening output files: Invalid argument

(response0.png is the first downloaded segment from hls)

I think that "Stream #0:0: Video: png ..." means that this file is in png format, and it does not have audio track. But it has audio track, because I can play it.

Probably segments are in some non-standard format, but how to find out what format is it?

PS1

Link to response0.png:

.png

or

PS2

This command:

file /Users/user1/Downloads/response0.png

returns this:

/Users/user1/Downloads/response0.png: PNG image data, 1 x 1, 8-bit gray+alpha, non-interlaced

PS3:

This command:

xxd /Users/user1/Downloads/response0.png | head -4

returns this:

/Users/user1/Downloads/response0.png: PNG image data, 1 x 1, 8-bit gray+alpha, non-interlaced
user1@MBP-Maxim-2 temp % xxd /Users/user1/Downloads/response0.png | head -4
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
00000010: 0000 0001 0000 0001 0804 0000 00b5 1c0c  ................
00000020: 0200 0000 0b49 4441 5478 da63 64f8 0f00  .....IDATx.cd...
00000030: 0105 0101 2718 e366 0000 0000 4945 4e44  ....'..f....IEND

PS4:

web-page with video:

/watch/tci7-pulp-fiction-1994-movie-online-free-123movies.html

I have url of HLS:

https://9str-m3u8-play-021024.playm4u.xyz/m3u8/tp1-rdv1/1080/642bce856edd7cab511931a2/647af249adaf446b461a374e/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/2a2415eaeec82cbf16cebbf974a372e0

It contains links to segments:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:6,
https://9str-rd.playm4u.xyz/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007927d1e7a824e88d90e17fc925d914a006873ed08c7ecb7107e7a72b810e66a2cf/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c37bc9a36794c836b2cc1c80b4c82aff3e/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/96902c1c0db5b15f08a07d5264361f76
#EXTINF:6,
https://9str-rd.playm4u.xyz/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007927d1e7a824e88d90e17fc925d914a0066544f42d5295cd71e2423a54702ca79a/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3fa2a9b2a1346c4d1e2dc5c86583c6eca67d125b9be8ecfee724eea988e5948be/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/8e029c34700e193599b52db66deeb735
...
#EXTINF:6,
https://9str-rd.playm4u.xyz/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007923834b9bbcad67c4f65be31cff40707486e081644f595435073518177e606a22/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3ddcf230599d82c80aa1c0d846a87eccbd425fffb2434464a4aea5eecb13bf477/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/63ae374ce1012f9b702a082f691edfd8
#EXTINF:2.24,
https://9str-rd.playm4u.xyz/9str-rd-tp1v1/1080/642bce856edd7cab511931a2/cdebe91fd08cdb6d79827cca6c41007923834b9bbcad67c4f65be31cff407074bce293bef2086d37ff74c808d35023d5/0292b734e3b0d7dacb586869beac1f91281543d90d0496d24f01bbaf70c971c3514fc67bd369ecc7b2b8d0fa501094d2da0625e9796bde32b6f9a9cb5d278ec3/53616c7465645f5f3ec139a78aff102a8e3a3c62ae8f3826f32bf6f19ea4b1fb/1735825697/ae04e0aa6d021a973852ee444489eec0
#EXT-X-ENDLIST

I can download any segment and play it using ExoPlayer in Android, but I can't convert it to mp3 or mp4 using ffmpeg.

For example this command:

ffmpeg -i /Users/user1/Downloads/response0.png /Users/user1/Downloads/response0.mp3

returns this:

  libavutil      59. 39.100 / 59. 39.100
  libavcodec     61. 19.100 / 61. 19.100
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100
Input #0, png_pipe, from '/Users/user1/Downloads/response0.png':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: png, ya8(pc, gbr/unknown/unknown), 1x1, 25 fps, 25 tbr, 25 tbn
Output #0, mp3, to '/Users/user1/Downloads/response0.mp3':
[out#0/mp3 @ 0x7fe879206b00] Output file does not contain any stream
Error opening output file /Users/user1/Downloads/response0.mp3.
Error opening output files: Invalid argument

(response0.png is the first downloaded segment from hls)

I think that "Stream #0:0: Video: png ..." means that this file is in png format, and it does not have audio track. But it has audio track, because I can play it.

Probably segments are in some non-standard format, but how to find out what format is it?

PS1

Link to response0.png:

https://i.sstatic.net/pajvO7fg.png

or

https://drive.google.com/file/d/1i-LERY8kEYVZgS8mX9mCoMWd3To4Fk2T/view?usp=sharing

PS2

This command:

file /Users/user1/Downloads/response0.png

returns this:

/Users/user1/Downloads/response0.png: PNG image data, 1 x 1, 8-bit gray+alpha, non-interlaced

PS3:

This command:

xxd /Users/user1/Downloads/response0.png | head -4

returns this:

/Users/user1/Downloads/response0.png: PNG image data, 1 x 1, 8-bit gray+alpha, non-interlaced
user1@MBP-Maxim-2 temp % xxd /Users/user1/Downloads/response0.png | head -4
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR
00000010: 0000 0001 0000 0001 0804 0000 00b5 1c0c  ................
00000020: 0200 0000 0b49 4441 5478 da63 64f8 0f00  .....IDATx.cd...
00000030: 0105 0101 2718 e366 0000 0000 4945 4e44  ....'..f....IEND

PS4:

web-page with video:

https://ww2.movie123.club/watch/tci7-pulp-fiction-1994-movie-online-free-123movies.html

Share Improve this question edited Apr 25 at 20:20 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Jan 2 at 11:43 MaximMaxim 4861 gold badge8 silver badges13 bronze badges 7
  • Where's response0.png? – Mark Setchell Commented Jan 2 at 11:52
  • @MarkSetchell response0.png is in Downloads directory. Сorrected the code. – Maxim Commented Jan 2 at 11:56
  • 1 How can a PNG file contain audio? Try running file response0.png to see what type it is. Or xxd response0.png | head -4 – Mark Setchell Commented Jan 2 at 11:56
  • 1 Mmmm.... a single pixel PNG. What is the length of the file, use ls -l response0.png – Mark Setchell Commented Jan 2 at 13:36
  • 1 The PNG data in the file is exactly 64 bytes long. So it must be longer than that if it contains audio data - so how long is response0.png ? – Mark Setchell Commented Jan 2 at 13:58
 |  Show 2 more comments

1 Answer 1

Reset to default 0

The reason was that segments of hls are not png files, but they have headers (first 8 bytes) like png files. I just removed first 8 bytes, and it works. Source: https://github.com/xbmc/inputstream.ffmpegdirect/issues/100?ysclid=m5feoz1irw450917629#issuecomment-828988158

The only questions are:

  1. Why does the streaming server mask video segments? Perhaps for security reasons?
  2. What other formats do streaming servers use to hide video files?
转载请注明原文地址:http://www.anycun.com/QandA/1746122622a91986.html