Closed toomyzoom closed 8 months ago
This is not related to #5856, because #5856 is about something completely different.
Both video and audio streams get muxed and written to the output perfectly fine. This also works using --player-external-http
.
streamlink \
--stdout \
--loglevel none \
--http-no-ssl-verify \
--http-cookie "domand_bid=128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b" \
"https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134" \
best \
2>/dev/null \
| ffprobe -v error -of json -show_streams - \
| jq
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_tag_string": "[27][0][0][0]",
"codec_tag": "0x001b",
"width": 1920,
"height": 1080,
"coded_width": 1920,
"coded_height": 1080,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 2,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuv420p",
"level": 42,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"field_order": "progressive",
"refs": 1,
"is_avc": "false",
"nal_length_size": "0",
"ts_packetsize": "188",
"id": "0x100",
"r_frame_rate": "60/1",
"avg_frame_rate": "60/1",
"time_base": "1/90000",
"start_pts": 129840,
"start_time": "1.442667",
"bits_per_raw_sample": "8",
"extradata_size": 43,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_tag_string": "[15][0][0][0]",
"codec_tag": "0x000f",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"ts_packetsize": "188",
"id": "0x101",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 126000,
"start_time": "1.400000",
"bit_rate": "147462",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
},
"tags": {
"language": "und"
}
}
]
}
This is not related to #5856, because #5856 is about something completely different.
Both video and audio streams get muxed and written to the output perfectly fine. This also works using
--player-external-http
.streamlink \ --stdout \ --loglevel none \ --http-no-ssl-verify \ --http-cookie "domand_bid=128755907:33da7e6476356e50114d25c768f04098e83219f506bf88c58a2693a07df9872b" \ "https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=1b4bc251ff32937e7f1b5603688092ef0ea125d10b6c24e30000000065e62a7ef25d514e44dec1b7&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk1ODI5NzR9fX1dfQ__&Signature=rz1uOhlJb92xUEcfueNIYMnI5DVfLJQmW4SUu4Tcla-B0oMsg1tjSPnv6QfNGHClWdTN3Xq7A6XEM9QxXlIQp2TR0-IWacTa1iqECoo~lO2ogvA2QdTwJqSJZljoG4ivwGOJrQY7if5xI-mDQqxPKe4LFLoJZc2BAdL1rI5agkT1~V6EEAC82dBULI9wJzU1179M~5ine7ibe4Y28LsGVpqrWsDYxqYDnRObYRvUxMu8gtxM5PaXO~wCJiUeG~2CxT52xVLGyXmaGW5ht3DTp5R4iDkdPusFjqr9tDBzbH3MsIgZQ3L58tkNxepbrERD5hn1B8wkvKtYMXMRXKDvxA__&Key-Pair-Id=K11RB80NFXU134" \ best \ 2>/dev/null \ | ffprobe -v error -of json -show_streams - \ | jq
{ "streams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "[27][0][0][0]", "codec_tag": "0x001b", "width": 1920, "height": 1080, "coded_width": 1920, "coded_height": 1080, "closed_captions": 0, "film_grain": 0, "has_b_frames": 2, "sample_aspect_ratio": "1:1", "display_aspect_ratio": "16:9", "pix_fmt": "yuv420p", "level": 42, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "false", "nal_length_size": "0", "ts_packetsize": "188", "id": "0x100", "r_frame_rate": "60/1", "avg_frame_rate": "60/1", "time_base": "1/90000", "start_pts": 129840, "start_time": "1.442667", "bits_per_raw_sample": "8", "extradata_size": 43, "disposition": { "default": 0, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "non_diegetic": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 } }, { "index": 1, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_tag_string": "[15][0][0][0]", "codec_tag": "0x000f", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 2, "channel_layout": "stereo", "bits_per_sample": 0, "initial_padding": 0, "ts_packetsize": "188", "id": "0x101", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/90000", "start_pts": 126000, "start_time": "1.400000", "bit_rate": "147462", "disposition": { "default": 0, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "non_diegetic": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und" } } ] }
May I ask what ffmpeg version you're using? I run the same command you used but getting error on ffmpeg.
[h264 @ 0x5c00fc123e00] non-existing PPS 0 referenced
[h264 @ 0x5c00fc123e00] A non-intra slice in an IDR NAL unit.
[h264 @ 0x5c00fc123e00] decode_slice_header error
[h264 @ 0x5c00fc123e00] no frame!
[h264 @ 0x5c00fc123e00] non-existing PPS 4 referenced
[h264 @ 0x5c00fc123e00] no frame!
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"codec_type": "video",
"codec_tag_string": "[27][0][0][0]",
"codec_tag": "0x001b",
"width": 0,
"height": 0,
"coded_width": 0,
"coded_height": 0,
"closed_captions": 0,
"film_grain": 0,
"has_b_frames": 1,
"level": -99,
"refs": 1,
"is_avc": "false",
"nal_length_size": "0",
"ts_id": "1",
"ts_packetsize": "188",
"id": "0x100",
"r_frame_rate": "90000/1",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 129840,
"start_time": "1.442667",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_tag_string": "[15][0][0][0]",
"codec_tag": "0x000f",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"initial_padding": 0,
"ts_id": "1",
"ts_packetsize": "188",
"id": "0x101",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 126000,
"start_time": "1.400000",
"bit_rate": "162649",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"non_diegetic": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
},
"tags": {
"language": "und"
}
}
]
}
https://archlinux.org/packages/extra/x86_64/ffmpeg/
$ ffmpeg
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13.2.1 (GCC) 20230801
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
https://archlinux.org/packages/extra/x86_64/ffmpeg/
$ ffmpeg ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.1 (GCC) 20230801 configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100
Thanks. Seem like ffmpeg was broken somewhere after Jan 31st this year. I was able to to narrow down using snapshots between these 2 commits:
-> There was about 5 out of 8 commits between these 2 related to mpegts and mpegtsenc refactor and update.
Your ffmpeg output and version gave me the hint. I looked like an old version from last year.
If there's an unresolved issue in FFmpeg's MPEG-TS muxer on their master branch, then please report the issue upstream, so it can get fixed in their next release. Thanks!
If there's an unresolved issue in FFmpeg's MPEG-TS muxer on their master branch, then please report the issue upstream, so it can get fixed in their next release. Thanks!
I found the commit (8559cce3c37b08e37fd208b8895a87adb8832e77) causing problem and created a patch that can fix it for ffmpeg but I'm not sure how to report it. The hls master stream has unencrypted substreams in it which ffmpeg by itself was able to pick it up without issue. Correct me if I'm wrong here but seem like streamlink feed ffmpeg the master stream as mpegts and it assumes the stream was encrypted which call the buggy function mpegts_check_bitstream() in mpegtsenc.c. I'm not sure how can I generate the same stream for ffmpeg bug report without using streamlink and the expiring link.
Decryption happens on the HLS protocol level and has nothing to do with the resulting bitstream (MPEG-TS or fragmented MPEG-4).
If you want to download (--output=...
) the individual video and audio streams separately, then use their respective media playlist URLs as inputs instead of the multivatiant playlist URL. You can list them using the --loglevel=all
CLI argument when parsing the multivariant playlist without having selected a particular stream. There's currently no better solution until the planned re-implementation of Streamlink's stream selection has landed.
All that Streamlink does when muxing the HLS substreams is this:
ffmpeg \
-nostats \
-y \
-i namedpipe-of-stream-a \
-i namedpipe-of-stream-b \
-c:v copy \
-c:a copy \
-map '0:v?' \
-map '0:a?' \
-map '1:a' \
-f mpegts \
pipe:1
I would be very surprised though if this fundamental stuff broke on FFmpeg's master branch. I haven't built it myself from master yet, but I can have a look when I get the time. I won't be able to access your stream though because it's expired. If it's indeed broken, then this should be applicable to other streams as well and not just your stream example.
I can't see any issues with FFmpeg built from its master branch.
I've tested 97beb63a66
(current HEAD) built from the ffmpeg-git
AUR PKGBUILD on Arch and 49707b0590
(HEAD from yesterday) from BtbN/FFmpeg-Builds
.
Both muxed HLS and DASH streams worked fine (MPEG-4 video+audio streams remuxed to MPEG-TS).
I can't see any issues with FFmpeg built from its master branch.
I've tested
97beb63a66
(current HEAD) built from theffmpeg-git
AUR PKGBUILD on Arch and49707b0590
(HEAD from yesterday) fromBtbN/FFmpeg-Builds
.Both muxed HLS and DASH streams worked fine (MPEG-4 video+audio streams remuxed to MPEG-TS).
I'm not sure what in the stream from nicovideo that triggers this function when passed through streamlink to ffmpeg.
This is the current patch I have:
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
(AV_RB24(pkt->data) != 0x000001 ||
(st->codecpar->extradata_size > 0 &&
- (st->codecpar->extradata[0] & e->mask == e->value))))
+ ((st->codecpar->extradata[0] & e->mask) == e->value))))
return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
}
return 1;
From 8559cce3, it was the change in this line:
- st->codecpar->extradata[0] == 1)))
+ (st->codecpar->extradata[0] & e->mask == e->value))))
The commit overlooked the precedence between ==
and &
. It was supposed to be &
first before ==
but without parenthesis, the order evaluated was the other way around. It never looks up the correct entry in the codec id table in that same function which what causes the issue of not return video stream info.
I generated a new link. You can use the command you gave me with the same cookie to test it. I get no video info (width/height=0, etc without this patch)
https://delivery.domand.nicovideo.jp/hlsbid/65bb415e1a6e6c306f97ef37/playlists/variants/0ea125d10b6c24e3.m3u8?session=bee8811336df5b891a6030459316aef60ea125d10b6c24e30000000065ebe379d54a8e49ad54585a&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9kZWxpdmVyeS5kb21hbmQubmljb3ZpZGVvLmpwL2hsc2JpZC82NWJiNDE1ZTFhNmU2YzMwNmY5N2VmMzcvcGxheWxpc3RzL3ZhcmlhbnRzLzBlYTEyNWQxMGI2YzI0ZTMubTN1OFxcPyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE3MDk5NTgwMDl9fX1dfQ__&Signature=cKBnb5Cra4vRXKZSnD7pqfjuHsI0P6YnsLICXg3Kg~FK6eSNfb6SuFDR1U0vYCeOr0tuCCcT4zijzGcnPSrGG1UzeXEXKkmAfDIL~0WOLKRT8O-etPHeAFvNrGIKK68urQjL0X-ThC8nLeSu6Pnc0BIko2tK6ThHjFPw8rowtYQpPs~K4JSEN2BHqJI7pQobi2pGtYPXQTpaaf3TUgu2pOz7CQU-R2m3wwx6IodIKNtYpxRRHBPbPeYXPzbO52NKMtWqBsbwH1pUWNO7eLEcav9l7dfCWPwetmhLxdID3DAeNGmSkyDp75lRbeyuiejdXC7VmFFX5KxIPg-tvsixLg__&Key-Pair-Id=K11RB80NFXU134
Here are the separate video and audio streams (limited to --hls-duration=5
)
5876.zip
$ ffprobe -v error -of json -show_format 5876-v.mp4 | jq
{
"format": {
"filename": "5876-v.mp4",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.033333",
"duration": "6.000000",
"size": "3675840",
"bit_rate": "4901120",
"probe_score": 100,
"tags": {
"major_brand": "iso6",
"minor_version": "512",
"compatible_brands": "iso6cmfcmp41",
"encoder": "Lavf58.76.100"
}
}
}
$ ffprobe -v error -of json -show_format 5876-a.mp4 | jq
{
"format": {
"filename": "5876-a.mp4",
"nb_streams": 1,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "6.016000",
"size": "116752",
"bit_rate": "155255",
"probe_score": 100,
"tags": {
"major_brand": "iso5",
"minor_version": "512",
"compatible_brands": "iso5cmfciso6mp41",
"encoder": "Lavf58.76.100"
}
}
}
Muxing to MPEG-TS fails using FFmpeg built from master (49707b0590
)
$ ./ffmpeg-master-latest-linux64-gpl/bin/ffmpeg \
-i 5876-v.mp4 \
-i 5876-a.mp4 \
-c copy \
-f mpegts \
-y \
5876-muxed-master.ts
...
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 100902 data 00018A22
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 539 data 00000217
[mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 165 data 000000A1
...
Muxing to MPEG-4 works fine.
That is all I can do to help. It's an FFmpeg issue and not a Streamlink issue, even if it affects Streamlink.
Streamlink's muxed output format can be set using --ffmpeg-fout
, which defaults to mpegts
.
Decided to quickly check your patch and I can confirm that it fixes the issue. You should send it to their mailing list
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 06e88e9879..b8efc535a7 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -2319,7 +2319,7 @@ static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st,
pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
(AV_RB24(pkt->data) != 0x000001 ||
(st->codecpar->extradata_size > 0 &&
- (st->codecpar->extradata[0] & e->mask == e->value))))
+ ((st->codecpar->extradata[0] & e->mask) == e->value))))
return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL);
}
return 1;
No idea how such mistakes like using the wrong operator precedence can make it onto their master branch...
Here are the separate video and audio streams (limited to
--hls-duration=5
) 5876.zip$ ffprobe -v error -of json -show_format 5876-v.mp4 | jq { "format": { "filename": "5876-v.mp4", "nb_streams": 1, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.033333", "duration": "6.000000", "size": "3675840", "bit_rate": "4901120", "probe_score": 100, "tags": { "major_brand": "iso6", "minor_version": "512", "compatible_brands": "iso6cmfcmp41", "encoder": "Lavf58.76.100" } } } $ ffprobe -v error -of json -show_format 5876-a.mp4 | jq { "format": { "filename": "5876-a.mp4", "nb_streams": 1, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.000000", "duration": "6.016000", "size": "116752", "bit_rate": "155255", "probe_score": 100, "tags": { "major_brand": "iso5", "minor_version": "512", "compatible_brands": "iso5cmfciso6mp41", "encoder": "Lavf58.76.100" } } }
Muxing to MPEG-TS fails using FFmpeg built from master (
49707b0590
)$ ./ffmpeg-master-latest-linux64-gpl/bin/ffmpeg \ -i 5876-v.mp4 \ -i 5876-a.mp4 \ -c copy \ -f mpegts \ -y \ 5876-muxed-master.ts ... [mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 100902 data 00018A22 [mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 539 data 00000217 [mpegts @ 0x6392afb61240] h264 bitstream error, startcode missing, size 165 data 000000A1 ...
Muxing to MPEG-4 works fine.
That is all I can do to help. It's an FFmpeg issue and not a Streamlink issue, even if it affects Streamlink.
Streamlink's muxed output format can be set using
--ffmpeg-fout
, which defaults tompegts
.
Your help is more than what can be asked for. I appreciated it. Thanks for your patience of working with me through this.
I will try to submit the patch to ffmpeg.
I will try to submit the patch to ffmpeg.
@toomyzoom, did you submit it? I can't see anything on their devel mailing list or commit history
Pointing out the bug on their mailing list could also be enough
I've opened a bug report on their tracker: https://trac.ffmpeg.org/ticket/10908
I've opened a bug report on their tracker: https://trac.ffmpeg.org/ticket/10908
I was busy this week so didn't check the email. I was going to submit the patch but seem like someone already did that.
Thanks for opening the bug report.
Checklist
Streamlink version
6.6.2+12.g0a63b33c
Description
This is related to #5856
The fix included in that pull request only partially fixes the problem. On some video, streamlink was only able to get the audio stream but not video
This is the mpv debug when opening that stream from streamlink http server:
Debug log