Re: [FFmpeg-user] Problem with ffmpeg-3.2.4

2017-04-13 Thread Pierre Delmas
Thank you I didn't see the last line in documentation


Promise next time I will publish on the right list.


Thank you very much,

Best regards,

DELMAS P


Le 13/04/2017 à 12:23, Cley Faye a écrit :
> 2017-04-13 11:18 GMT+02:00 Pierre Delmas <
> pierre.del...@centrale-marseille.fr>:
>
>> How to replace avcodec_decode_video2 in the version ffmpeg-3.2.4 ?
>
> ​Two things.
>
> First, this is not the right list for this kind of questions;
> https://lists.ffmpeg.org/mailman/listinfo/libav-user/ is probably a better
> starting point.
>
> Second, it might be a shot in the dark, but since the documentation (
> https://www.ffmpeg.org/doxygen/3.2/group__lavc__decoding.html#ga3ac51525b7ad8bca4ced9f3446e96532)
> is telling you to use avcodec_send_packet() and avcodec_receive_frame(),
> maybe you could use avcodec_send_packet() and avcodec_receive_frame()? :)
> ___
> ffmpeg-user mailing list
> ffmpeg-user@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".




signature.asc
Description: OpenPGP digital signature
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Problem with ffmpeg-3.2.4

2017-04-13 Thread Cley Faye
2017-04-13 11:18 GMT+02:00 Pierre Delmas <
pierre.del...@centrale-marseille.fr>:

>
> How to replace avcodec_decode_video2 in the version ffmpeg-3.2.4 ?


​Two things.

First, this is not the right list for this kind of questions;
https://lists.ffmpeg.org/mailman/listinfo/libav-user/ is probably a better
starting point.

Second, it might be a shot in the dark, but since the documentation (
https://www.ffmpeg.org/doxygen/3.2/group__lavc__decoding.html#ga3ac51525b7ad8bca4ced9f3446e96532)
is telling you to use avcodec_send_packet() and avcodec_receive_frame(),
maybe you could use avcodec_send_packet() and avcodec_receive_frame()? :)
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Problem with ffmpeg-3.2.4

2017-04-13 Thread Pierre Delmas
Hello,

I need a little help.

Currently I'm doing a research project in which I use ffmpeg.

For that project I need to extract motion vectors so I looked on the web
for solution and found the use of AVMotionVector (like in file
frame.cpp) but with that method I get a segfault so I looked for the
reason and found that avcodec_decode_video2 is deprecated. I looked for
a replacement solution but I didn't find any, so here is my question :

How to replace avcodec_decode_video2 in the version ffmpeg-3.2.4 ?

Best regards,
DELMAS P.

P.S : You can find attached two c++ class which are one for frame and
another one for video


#include "alloc/lib_alloc.h"
#include "computing/lib_convert.h"
#include "frame.hpp"

Frame::Frame(AVFrame ,AVCodecContext )
{
context = 
frame = 

motion = new vector;
}

AVCodecContext *Frame::getContext() const
{
return context;
}

void Frame::setContext(AVCodecContext *value)
{
context = value;
}

AVFrame *Frame::getFrame() const
{
return frame;
}

void Frame::setFrame(AVFrame *value)
{
frame = value;
}

vector *Frame::getMotion() const
{
return motion;
}

void Frame::setMotion(vector *value)
{
motion = value;
}

int Frame::extract()
{
AVFrameSideData *sd = av_frame_get_side_data(frame,AV_FRAME_DATA_MOTION_VECTORS);

if (sd)
{
const AVMotionVector *mvs = (const AVMotionVector*)sd->data;
for (unsigned int i = 0; i < sd->size / sizeof(*mvs); i++)
{
const AVMotionVector *mv = [i];
const int direction = mv->source > 0;
motion->push_back(*mv);
}
}

return 0;
}

/*int Frame::modifyOne(int motionVectorValue,int valueSup)
{
//int* working = convertIntToBinary(motionVectorValue,8);

return -1;
}*/






#ifndef FRAME_HPP
#define FRAME_HPP

#include 
#include 

#ifdef __cplusplus
extern "C"
{
#endif

#include 
#include 
#include 


#ifdef __cplusplus
}
#endif

using namespace std;

class Frame
{
public:
Frame(AVFrame , AVCodecContext );

AVCodecContext *getContext() const;
void setContext(AVCodecContext *value);
AVFrame *getFrame() const;
void setFrame(AVFrame *value);
vector *getMotion() const;
void setMotion(vector *value);

int extract();
//int modifyOne(int motionVectorValue, int valueSup);

private:
AVFrame* frame;
AVCodecContext* context;
vector *motion;
};

#endif // FRAME_HPP
#include 
#include "framesVector.hpp"
#include "video.hpp"


#define FF_I_TYPE AV_PICTURE_TYPE_I ///< Intra

Video::Video(string n)
{
formatContext = NULL;
codec = NULL;
error=0;

av_register_all();
name = n;
contextTest = gettingContext();
mvInfoTest = gettingInfo();

if(contextTest!=0||mvInfoTest!=0)
{
error = 1;
}
}

string Video::getName() const
{
return name;
}

void Video::setName(const string )
{
name = value;
}

int Video::getNbi() const
{
return nbi;
}

int Video::getNbj() const
{
return nbj;
}

int Video::getGOP() const
{
return gop;
}

int Video::getNb() const
{
return nb;
}

int Video::getMvInfoTest() const
{
return mvInfoTest;
}

int Video::getContextTest() const
{
return contextTest;
}


AVCodecContext *Video::getContext() const
{
return context;
}

int Video::gettingContext()
{
int ret = -1;

if(avformat_open_input(, name.c_str(), NULL, NULL)==0)
{
if (avformat_find_stream_info(formatContext, NULL)>=0)
{
for(unsigned int i=0; inb_streams; i++)
{
if(formatContext->streams[i]->codecpar->codec_type==AVMEDIA_TYPE_VIDEO)
{
videoStream = i;
}
}
if(videoStream!=-1)
{
context = formatContext->streams[videoStream]->codec;
ret = 0;
}
}
}

return ret;
}

int Video::gettingInfo()
{
int ret=-1;

int NB=0;
int NBI=0;
int NBJ=0;

if(contextTest==0)
{
NBI = (int) (context->height)/16;
NBJ = (int) (context->width)/16;

bool test1 = (16*((int) (context->height)/16)!=(context->height));
bool test2 = (16*((int) (context->width)/16)!=(context->width));

if(test1==false&==false)
{
int N = context->gop_size;
int M = context->max_b_frames;

codec = avcodec_find_decoder(context->codec_id);

if(codec!=NULL)
{
if(avcodec_open2(context, codec, NULL)>=0)
{
nbi = NBI;
nbj = NBJ;
gop = N + N*M/(M+1) - 1;
nb = NB;

ret = 0;
}
}
}
}

return ret;
}

vector Video::readAllFrames()
{
vector *all = new vector;
AVPacket packet;

int i = 0;
int f=1;
int frameFinished=0;
int NB=0;

//AVFrame* frame;