MIME type for transcoded stream

北战南征 提交于 2019-12-11 11:41:11

问题


I wish to determine the MIME type of the contents of a pipe. The pipe is outputting a transcoded video stream, so there is no corresponding file extension.

Can I determine the MIME type in these circumstances using say ffprobe -i pipe:0 or some equivalent? Is there a canonical mapping of codecs or container formats to MIME type?


回答1:


You can use DetectContentType to guess the content type based on the magic numbers: http://golang.org/pkg/net/http/#DetectContentType




回答2:


My suggestion would be to either:

1) Transfer the MIME type over the pipe before sending the data.

or

2) Look at the first couple of bytes (header) of the stream, normally video and audio files identify their format in the first 2 to 3 bytes.

or

3) Read the format specifications of the different formats you are expecting and try to figure out the the format based on common patterns (sync points where available, for instance).



来源:https://stackoverflow.com/questions/10985953/mime-type-for-transcoded-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!