Je lis un flux vidéo mpeg4 en utilisant ffmpeg. J'utilise certaines de ses propriétés et fais certains processus en utilisant ces propriétés. Ce que je veux, c'est jouer la vidéo ouverte en utilisant un joueur comme vlc. Et puis, par conséquent, j'ai besoin de lire la vidéo de sortie après le traitement afin de vérifier s'il y a une latence. Est-il possible de donner la vidéo à un port. Alors que je peux obtenir la vidéo comme une entrée pour le lecteur vlc du port spécifique.comment générer un flux multimédia en utilisant ffmpeg?
Ceci est mon code jusqu'à maintenant. J'utilise la méthode MV_generation pour en extraire des entités et en faire une comparaison.
static int MV_generation(const AVPacket *pkt)
{
std::vector<unsigned long long> vl = File_read();
std::hash<string> hash1;
std::ios_base::app);
double x_src_val = 0;
double y_src_val = 0;
double x_dst_val = 0;
double y_dst_val = 0;
int ret = avcodec_send_packet(video_dec_ctx, pkt);
if (ret < 0) {
//fprintf(stderr, "Error while sending a packet to the decoder: %s\n", av_err2str(ret));
return ret;
}
video_frame_count++;
while (ret >= 0){
ret = avcodec_receive_frame(video_dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
break;
}
else if (ret < 0) {
return ret;
}
if (ret >= 0) {
AVFrameSideData *sd;
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
if (sd) {
const AVMotionVector *mvs = (const AVMotionVector *)sd->data;
int size_sd = sd->size;
//outData << size_sd << endl;
string str = "", str1, str2, str3, str4;
for (int i = 0; i < size_sd/sizeof(*mvs); i++) {
const AVMotionVector *mv = &mvs[i];
int x_src = mv->src_x;
int y_src = mv->src_y;
int x_dst = mv->dst_x;
int y_dst = mv->dst_y;
if (x_src != x_dst || y_src != y_dst || x_src > 100 || y_src > 100 || x_dst > 100 || y_dst > 100){
str1 = to_string(x_src);
str2 = to_string(y_src);
str3 = to_string(x_dst);
str4 = to_string(y_dst);
str = str.append(str1).append(str2).append(str3).append(str4);
}
}
for (unsigned long long y : vl)
{
// Check if any of the numbers are equal to x
if (hash1(str) == y)
{
cout << "matched frame_no : " << video_frame_count << endl;
}
}
}
av_frame_unref(frame);
}
}
outData.close();
return 0;
}