日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

FFMPEG 接口

發布時間:2024/2/28 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 FFMPEG 接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.打開輸入流

avformat_open_input()

int?avformat_open_input(AVFormatContext?**?ps,
const char *?url,
const?AVInputFormat?*?fmt,
AVDictionary?**?options?
)

Open an input stream and read the header.

打開輸入流, 讀取header, 并分配format 上下文 (allocate format context),具體參見AVFormatContext 結構體

The codecs are not opened. The stream must be closed with?avformat_close_input().

Parameters

psPointer to user-supplied?AVFormatContext?(allocated by avformat_alloc_context). May be a pointer to NULL, in which case an?AVFormatContext?is allocated by this function and written into ps. Note that a user-supplied?AVFormatContext?will be freed on failure.
urlURL of the stream to open.
fmtIf non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected.
optionsA dictionary filled with?AVFormatContext?and demuxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.

Returns

0 on success, a negative AVERROR on failure.

Note

If you want to use custom IO, preallocate the format context and set its pb field.

2.? 檢索流信息

avformat_find_stream_info()

int?avformat_find_stream_info(AVFormatContext?*?ic,
AVDictionary?**?options?
)

Read packets of a media file to get stream information.

This is useful for file formats with no headers such as MPEG. This function also computes the real framerate in case of MPEG-2 repeat frame mode. The logical file position is not changed by this function; examined packets may be buffered for later processing.

Parameters

icmedia file handle
optionsIf non-NULL, an ic.nb_streams long array of pointers to dictionaries, where i-th member contains options for codec corresponding to i-th stream. On return each dictionary will be filled with options that were not found.

Returns

>=0 if OK, AVERROR_xxx on error

Note

this function isn't guaranteed to open all the codecs, so options being non-empty at return is a perfectly normal behavior.

Todo:

Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need.

3.?

open_codec_context()

static?int?open_codec_context(int?*?stream_idx,
AVCodecContext?**?dec_ctx,
AVFormatContext?*?fmt_ctx,
enum?AVMediaType?type?

)

4.?創建用于存放解碼視頻幀的image

av_image_alloc()

int?av_image_alloc(uint8_t *?pointers[4],
intlinesizes[4],
intw,
inth,
enum?AVPixelFormat?pix_fmt,
intalign?
)

Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordingly.

The allocated image buffer has to be freed by using?av_freep(&pointers[0]).

Parameters

alignthe value to use for buffer size alignment

Returns

the size in bytes required for the image buffer, a negative error code in case of failure

5.?

av_image_copy av_image_copy()void av_image_copy ( uint8_t * dst_data[4],int dst_linesizes[4],const uint8_t * src_data[4],const int src_linesizes[4],enum AVPixelFormat pix_fmt,int width,int height ) Copy image in src_data to dst_data.Parameters dst_linesizes linesizes for the image in dst_data src_linesizes linesizes for the image in src_data

6.?

av_sample_fmt_is_planar()

int?av_sample_fmt_is_planar(enum?AVSampleFormat?sample_fmt)

Check if the sample format is planar.

Parameters

sample_fmtthe sample format to inspect

Returns

1 if the sample format is planar, 0 if it is interleaved

7.?傳入planar類型的采樣格式,返回其可轉換的packed類型的采樣格式。例如傳入?AV_SAMPLE_FMT_S32P,其返回值為?AV_SAMPLE_FMT_S32。

av_get_packed_sample_fmt()

enum?AVSampleFormat?av_get_packed_sample_fmt(enum?AVSampleFormat?sample_fmt)

Get the packed alternative form of the given sample format.

If the passed sample_fmt is already in packed format, the format returned is the same as the input.

Returns

the packed alternative form of the given sample format or AV_SAMPLE_FMT_NONE on error.

ffmpeg 音頻存儲格式:

packed:多個聲道數據交錯存放,所有聲道的數據交錯排放在frame->data[0](即frame->extended_data[0])地址處,數據長度為linesize[0](單位:字節)

planar:每個聲道數據單獨存放,聲道0的起始地址為 frame->data[0](或frame->extended_data[0]),聲道1的起始地址為 frame->data[1](或frame->extended_data[1]) . . . 每個聲道的數據長度都為linesize[0](單位:字節)

判斷是否是 planar類型:av_sample_fmt_is_planar(sample_fmt)

FFmpeg音頻解碼后的數據是存放在AVFrame結構中的。

1)Packed格式,frame.data[0]或frame.extended_data[0]包含所有的音頻數據中。

2)Planar格式,frame.data[i]或者frame.extended_data[i]表示第i個聲道的數據(假設聲道0是第一個), AVFrame.data數組大小固定為8,如果聲道數超過8,需要從frame.extended_data獲取聲道數據。

參考:FFmpeg: Image related

總結

以上是生活随笔為你收集整理的FFMPEG 接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 成人综合在线观看 | 爱爱视频在线看 | 美女在线一区 | 制服丝袜av在线播放 | 少妇情理伦片丰满午夜在线观看 | 国产精品久久久久久久久久久久久久 | www.国产精品 | 久久精品视频在线播放 | 91在线精品一区二区三区 | 亚洲人 女学生 打屁股 得到 | 日韩av专区片 | 久久久蜜桃一区二区 | 91丨porny丨对白 | 91丨九色丨黑人外教 | 91国产视频在线播放 | 欧美精品乱码久久久久久 | 久久久久久999 | 想要视频在线 | 亚洲欧洲一级 | 得得的爱在线视频 | 伊人天天操 | 你懂的网站在线观看 | 男人插入女人下面视频 | 亚洲熟女乱色一区二区三区久久久 | 999成人网| 伊人色图 | 无码一区二区三区在线观看 | 啪免费视频 | 69色视频| 国产无遮无挡120秒 欧美综合图片 | 国产精品午夜未成人免费观看 | 一区二区三区四区精品视频 | 福利资源在线观看 | 黄a在线| 一区二区精品在线观看 | 夜夜操夜夜干 | 亚洲国产一区在线观看 | 成人短视频在线播放 | 一区二区三区伦理 | 日韩中文视频 | 黄色一级视频网站 | 免费国产一区 | 龚玥菲一级淫片 | 人人超碰97 | 国产情侣91 | 免费在线a | 国产毛片久久久 | 91黄色小视频 | 一级毛片aa | 国产激情综合 | 亚洲综合av一区 | 五月婷婷激情四射 | 黄色网页免费 | 可以免费看污视频的网站 | 国产精品黄色片 | 国产一级片中文字幕 | 国产v亚洲 | 免费麻豆国产一区二区三区四区 | 日本一区欧美 | 波多野吉衣av无码 | 成人性生交大片免费卡看 | 美女裸体网站久久久 | 无码人妻精品中文字幕 | 亚洲精品在线不卡 | 中文字幕 国产精品 | 欧美日韩国产黄色 | 久久久久亚洲AV成人无在 | 欧美生活一级片 | 潘金莲性xxxxhd| 欧美福利视频 | 国产精品jizz在线观看无码 | 亚洲第一网址 | 9cao| 国产成人无码精品久久久电影 | 夜夜综合网 | 少妇不卡视频 | 亚洲成人免费在线视频 | www.com国产 | 香蕉在线看 | 欧美另类videosbestsex| 青青操国产 | 国产xxx69麻豆国语对白 | 中文字幕资源在线 | 日本久色| 性按摩玩人妻hd中文字幕 | 99riav国产精品视频 | 操久久| 一区在线不卡 | 美女被日网站 | 99久久久无码国产 | 午夜少妇久久久久久久久 | 天堂av一区 | av一区二区在线观看 | 天天色天天射综合网 | 天堂中文在线看 | 911香蕉视频| 女人高潮娇喘声mp3 乱色视频 | 亚洲在线精品 | 国产又粗又黄视频 |