第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在指定視頻中的每個(gè)時(shí)間點(diǎn)截圖?

如何在指定視頻中的每個(gè)時(shí)間點(diǎn)截圖?

皈依舞 2022-07-01 07:07:03
1,如何使用ffmpeg獲得視頻文件中有多少條音頻管道?2,如何使用ffmpeg獲取視頻文件中的某條管道的音頻文件?3,如何在指定視頻中的每個(gè)時(shí)間點(diǎn)截圖?
查看完整描述

1 回答

?
冉冉說(shuō)

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

// 初始化libavcodec, and register all codecs and formats
av_register_all();

// 打開(kāi)媒體文件
input_format_context = 0;
ret = av_open_input_file(
&input_format_context,
open_file_name.data(),
0,
0,
0);
if(0 != ret || !input_format_context)
{
LOG( "FFMPEG Load File " << open_file_name << " Failed ." << ret);
return ret;
}
else
{
LOG( "FFMPEG Load File " << open_file_name << " Success .");
}

// 取出流信息
ret = av_find_stream_info(input_format_context);
if(0 != ret)
{
LOG( "FFMPEG Can Not Find Stream Info .");
return ret;
}

// 尋找第一個(gè)視頻流
for(unsigned int i = 0; i < input_format_context->nb_streams; i++)
{
if(input_format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
{
video_stream_index = i;
}
else if(input_format_context->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO)
{
audio_stream_index = i;
}
}

if(video_stream_index == -1 && audio_stream_index == -1)
{
// 既沒(méi)有音頻也沒(méi)有視頻,直接退出
LOG("Do not have video stream and audio stream");
return -1;
}

// 得到視頻流編碼上下文的指針
if(video_stream_index != -1)
{
video_decode_context = input_format_context->streams[video_stream_index]->codec;
// 尋找視頻流的解碼器
video_decode = avcodec_find_decoder(video_decode_context->codec_id);
if(!video_decode)
{
LOG( "FFMPEG Can Not Decoder For " << (int)video_decode_context->codec_id);
}
// 打開(kāi)解碼器
ret = avcodec_open(video_decode_context,video_decode);
if(0 != ret)
{
LOG( "FFMPEG Can Not Open Video Decoder .");
}

LOG("Image Size " << video_decode_context->width << "*" << video_decode_context->height);
LOG("Frame Rate " << (float)video_decode_context->time_base.den / (float)video_decode_context->time_base.num);
}

// 得到音頻流編碼上下文的指針
if(audio_stream_index != -1)
{
audio_decode_context = input_format_context->streams[audio_stream_index]->codec;
audio_decode = avcodec_find_decoder(audio_decode_context->codec_id);
if(!audio_decode)
{
LOG( "FFMPEG Can Not Decoder For " << (int)audio_decode_context->codec_id);
}
ret = avcodec_open(audio_decode_context,audio_decode);
if(0 != ret)
{
LOG( "FFMPEG Can Not Open Audio Decoder .");
}
}

讀圖像或者音頻數(shù)據(jù)

// 從流中讀取數(shù)據(jù)
int frameFinished = 0;
AVPacket packet;
AVFrame* frame = 0;
while(av_read_frame(input_format_context, &packet) >= 0)
{
if(packet.stream_index == video_stream_index)
{
if(frame == 0)
frame = avcodec_alloc_frame();

// 視頻
avcodec_decode_video(video_decode_context, frame, &frameFinished,packet.data,packet.size);

第三個(gè) 問(wèn)題 也很簡(jiǎn)單 會(huì)了前2個(gè)。搜索ffmpeg 播放位置


查看完整回答
反對(duì) 回復(fù) 2022-07-05
  • 1 回答
  • 0 關(guān)注
  • 195 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)