转码流的MIME类型

huangapple go评论86阅读模式
英文:

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:

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

or

  1. 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

  1. 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

huangapple
  • 本文由 发表于 2012年6月12日 02:58:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/10985953.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定