Darwin Streaming Server中mp4文件点播失败,通过抓包发现服务器返回”415 Unsupported Media Type“错误,如下:
RTSP/1.0 415 Unsupported Media Type Server: DSS/6.0.3 (Build/526.3; Platform/Linux; Release/Darwin Streaming Server; State/Development; ) Cseq: 3 Connection: Close
解决方案如下:
用mp4box来hint文件
yingc@yingc:~/media/video$ MP4Box h.mp4 -info * Movie Info * Timescale 90000 - Duration 00:23:35.062 Fragmented File no - 2 track(s) File Brand mp42 - version 0 Created: GMT Sun Jul 28 04:40:51 2013 File has root IOD (9 bytes) Scene PL 0xff - Graphics PL 0xff - OD PL 0xff Visual PL: ISO Reserved Profile (0x7f) Audio PL: High Quality Audio Profile @ Level 2 (0x0f) No streams included in root OD iTunes Info: Encoder Software: tv.sohu.com v3.3.0 20130315 Track # 1 Info - TrackID 1 - TimeScale 90000 - Duration 00:23:34.920 Media Info: Language "Undetermined" - Type "vide:avc1" - 35373 samples Visual Track layout: x=0 y=0 width=640 height=368 MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21 AVC/H264 Video - Visual Size 640 x 368 AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3 NAL Unit length bits: 32 yingc@yingc:~/media/video$ MP4Box h.mp4 -hint Hinting file with Path-MTU 1450 Bytes Hinting track ID 1 - Type "avc1:avc1" (H264) - BW 449 kbps Hinting track ID 2 - Type "mp4a:mp4a" (mpeg4-generic) - BW 32 kbps Saving h.mp4: 0.500 secs Interleaving yingc@yingc:~/media/video$ ffprobe h.mp4 ffprobe version 2.2.4 Copyright (c) 2007-2014 the FFmpeg developers built on Apr 13 2016 08:42:24 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/ --bindir=/home/yingc/git/thirdparty/av/ffmpeg/output/bin --extra-cflags=' -I/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/include' --extra-ldflags=-L/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/lib --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --disable-stripping --enable-extra-warnings --disable-optimizations --enable-openssl --enable-static --enable-debug=3 libavutil 52. 66.100 / 52. 66.100 libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'h.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42isomavc1 creation_time : 2013-07-28 04:40:51 encoder : tv.sohu.com v3.3.0 20130315 Duration: 00:23:35.16, start: 0.000000, bitrate: 512 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x368, 448 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default) Metadata: creation_time : 2013-07-28 04:40:51 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 32 kb/s (default) Metadata: creation_time : 2013-07-28 04:40:51 Stream #0:2(und): Data: none (rtp / 0x20707472), 23 kb/s (default) Metadata: creation_time : 2018-08-08 02:11:44 handler_name : GPAC ISO Hint Handler Stream #0:3(und): Data: none (rtp / 0x20707472), 3 kb/s (default) Metadata: creation_time : 2018-08-08 02:11:52 handler_name : GPAC ISO Hint Handler Unsupported codec with id 0 for input stream 2 Unsupported codec with id 0 for input stream 3
unhint文件:
yingc@yingc:~/media/video$ MP4Box h.mp4 -unhint Removing hint track ID 65536 Removing hint track ID 65537 Saving h.mp4: 0.500 secs Interleaving yingc@yingc:~/media/video$ ffprobe h.mp4 ffprobe version 2.2.4 Copyright (c) 2007-2014 the FFmpeg developers built on Apr 13 2016 08:42:24 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/ --bindir=/home/yingc/git/thirdparty/av/ffmpeg/output/bin --extra-cflags=' -I/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/include' --extra-ldflags=-L/home/yingc/git/thirdparty/av/ffmpeg/output/ffmpeg_build/lib --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --disable-stripping --enable-extra-warnings --disable-optimizations --enable-openssl --enable-static --enable-debug=3 libavutil 52. 66.100 / 52. 66.100 libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100 / 4. 2.100 libswscale 2. 5.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'h.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp42isomavc1 creation_time : 2013-07-28 04:40:51 encoder : tv.sohu.com v3.3.0 20130315 Duration: 00:23:35.02, start: 0.000000, bitrate: 483 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x368, 448 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default) Metadata: creation_time : 2013-07-28 04:40:51 Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 32 kb/s (default) Metadata: creation_time : 2013-07-28 04:40:51
参考: