I have a project, that i need to received data from a rtsp link, decode,resize video, encode it and save to .mp4 file.
this is my code:
AVPacket destPacket;
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
while(av_read_frame(i_format_context, &packet)>=0) {
if(packet.stream_index==video_stream_index) {
int rest = avcodec_decode_video2(copyInputCodec, pFrame, &frameFinished, &packet);
if(frameFinished) {
av_init_packet(&destPacket);
destPacket.data = NULL;
destPacket.size = 0;
av_free_packet(&destPacket);
//deocde here
int ret_scale = sws_scale(sws_ctx,pFrame->data,pFrame->linesize,0,copyInputCodec->height,encodeFrame->data,encodeFrame->linesize);
encodeFrame->pts=i;
int ret_enc = avcodec_encode_video2(copyOutputCodec,&destPacket,encodeFrame,&encodeFinishsed);//<--- Problem here.
getchar();
}
}
}
And this is output error
[swscaler @ 00607880] Warning: data is not aligned! This can lead to a speedlo ss Assertion avctx->codec->encode2 failed at /home/kyle/software/ffmpeg/source/ffmp eg-git/libavcodec/utils.c:2134
I try to run many sample code to encode video, the result is same.
Thanks for help.
PS: sorry about my English skill.
There are actually two issues here:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.