英文:
MIME type for transcoded stream
问题
我希望确定管道内容的MIME类型。该管道输出一个转码的视频流,因此没有相应的文件扩展名。
在这种情况下,我可以使用ffprobe -i pipe:0
或类似的方法确定MIME类型吗?是否有一种将编解码器或容器格式映射到MIME类型的规范方法?
英文:
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
得分: 0
我的建议是:
1)在发送数据之前,通过管道传输MIME类型。
或者
2)查看流的前几个字节(头部),通常视频和音频文件在前2到3个字节中标识其格式。
或者
3)阅读您所期望的不同格式的格式规范,并尝试根据常见模式(例如可用的同步点)来确定格式。
英文:
My suggestion would be to either:
- Transfer the MIME type over the pipe before sending the data.
or
- 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
- 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).
答案2
得分: 0
您可以使用DetectContentType根据魔术数字猜测内容类型:
http://golang.org/pkg/net/http/#DetectContentType
英文:
You can use DetectContentType to guess the content type based on the magic numbers:
http://golang.org/pkg/net/http/#DetectContentType
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论