部分视频因错误 MEDIA_UNKNOWN 无法进行 chromecast

Some videos fail to chromecast with error MEDIA_UNKNOWN

使用 mkchromecast 投射本地 mp4 文件,有些视频有效,有些无效(如:屏幕挂在蓝色 chromecast 徽标上,表明初始连接有效)。我可以准确重现描述的问题 here.

所以我决定降低一级,用pychromecast,看看当它挂在蓝色标志上时到底发生了什么。我将两个视频转换为 HLS 格式,并通过 http 服务器公开它们。适用于 mkchromecast 的视频也适用于我的设置,但失败的视频,好吧......两者都失败了。使用 pychromecast,我得到的信息不多于:

ERROR, code 100: MEDIA_UNKNOWN.

来自Cast documentation,这个错误的意思是:

The media element encountered an unknown error fired from platform. The media element encountered an error that did not indicate it's one of MediaError.MEDIA_ERR_*. This should be rare.

不过,这对我来说并不罕见。我认为可能失败的视频格式不受支持,如 in the documentation 所述。所以我尝试使用以下命令比较这两个视频:

ffprobe -v quiet -print_format json -show_streams <video.mp4>

有效的视频:

{
    "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_time_base": "1001/48000",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1088,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "16:9",
            "pix_fmt": "yuv420p",
            "level": 50,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "24000/1001",
            "avg_frame_rate": "24000/1001",
            "time_base": "1/24000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 47127080,
            "duration": "1963.628333",
            "bit_rate": "5527977",
            "bits_per_raw_sample": "8",
            "nb_frames": "47080",
            "disposition": {
                "default": 1,
                "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
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/48000",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 94254528,
            "duration": "1963.636000",
            "bit_rate": "125776",
            "max_bit_rate": "125776",
            "nb_frames": "92048",
            "disposition": {
                "default": 1,
                "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
            },
            "tags": {
                "language": "und",
                "handler_name": "SoundHandler"
            }
        }
    ]
}

无法播放的视频:

{                                               
    "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_time_base": "125/5994",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1920,
            "height": 1040,
            "coded_width": 1920,
            "coded_height": 1040,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "24:13",
            "pix_fmt": "yuv420p",
            "level": 41,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "2997/125",
            "avg_frame_rate": "2997/125",
            "time_base": "1/11988",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 97032000,
            "duration": "8094.094094",
            "bit_rate": "2499644",
            "bits_per_raw_sample": "8",
            "nb_frames": "194064",
            "disposition": {
                "default": 1,
                "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
            },
            "tags": {
                "creation_time": "2020-03-27T09:56:39.000000Z",
                "language": "und",
                "handler_name": "L-SMASH Video Media Handler"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_time_base": "1/48000",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 6,
            "channel_layout": "5.1",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 388516320,
            "duration": "8094.090000",
            "bit_rate": "224000",
            "max_bit_rate": "224000",
            "nb_frames": "379413",
            "disposition": {
                "default": 1,
                "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
            },
            "tags": {
                "creation_time": "2020-03-27T09:56:39.000000Z",
                "language": "eng",
                "handler_name": "SoundHandler"
            }
        }
    ]
}

据我所知,编解码器是相同的,我唯一能做的就是宽高比不同。

chromecast 端出现此 "MEDIA_UNKNOWN" 错误的原因可能是什么?这两个视频之间还有什么我可以比较的吗?会不会是因为宽高比导致chromecast失败?

不喜欢5.1声道布局。尝试将其缩混为立体声:

ffmpeg -i not_working.mp4 -c copy -c:a aac -ac 2 -movflags +faststart fixed.mp4