Digital Video Forums  

Go Back   Digital Video Forums > Video File Formats > MP4, MKV, MPEG-4 AVC (H.264)

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 17 Feb 2013, 11:17 PM   #1
Junior Member
Junior Member
 
Join Date: Feb 2013
Posts: 1
Default the relationship between rtp packet and frame

The sequence is IPPP... I only want to lose the second frame, so I revise the rtp_loss.c in JM 18.4 as follows. I only read the second packet to the buffer, but not write it to the output file.

The problem is that I do not know the relationship between packet and frame. I can make the second packet lost, but not the second frame.



Code:
// rtp_loss.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#ifdef WIN32
#include <Winsock2.h>
#else
#include <netinet/in.h>
#endif

void print_usage(char *argv [])
{
  printf ("Usage: %s input_file output_file loss_percent <keep_leading_packets>\n", argv[0]);
  exit (-1);
}


int main(int argc, char* argv[])
{
  unsigned int bufsize, pacno=0;
  unsigned char buf[65000];
  int i, intime;
  FILE *fr;                                // file for reading
  FILE *fw;                                // file for writing

  
  if ((argc != 4) && (argc != 5))
  {
    print_usage (argv);
  }

  if (NULL == (fr = fopen (argv[1], "rb")))
  {
    printf ("%s: cannot open H.264 packet file %s for reading\n", argv[0], argv[1]);
    return -2;
  }

  if (NULL == (fw = fopen (argv[2], "wb")))
  {
    printf ("%s: cannot open H.264 packet file %s for reading\n", argv[0], argv[1]);
    fclose (fr);
    return -2;
  }


  if (argc==5)
  {
    for (i=0; i< atoi (argv[4]); i++)
    {
      if (4 != fread (&bufsize, 1, 4, fr))
        return 0;
      if (4 != fread (&intime, 1, 4, fr))
      {
        printf ("Panic, cannot read timestamp, old software version file?\n");
        return -1;
      }
      if (bufsize != fread (buf, 1, bufsize, fr))
      {
        printf ("Problems while reading buffer, exit\n");
        return -3;
      }

      if (4 != fwrite (&bufsize, 1, 4, fw))
      {
        printf ("Problems while writing buffer size, exit\n");
        return -1;
      }
      if (4 != fwrite (&intime, 1, 4, fw))
      {
        printf ("Problems while writing timestamp, exit\n");
        return -1;
      }
      if (bufsize != fwrite (buf, 1, bufsize, fw))
      {
        printf ("Problems while writing buffer, exit\n");
        return -3;
      }
      pacno++;
    }
  }
   
      if (4 != fread (&bufsize, 1, 4, fr))
        return 0;
      if (4 != fread (&intime, 1, 4, fr))
      {
        printf ("Panic, cannot read timestamp, old software version file?\n");
        return -1;
      }
      if (bufsize != fread (buf, 1, bufsize, fr))
      {
        printf ("Problems while reading buffer, exit\n");
        return -3;
      }
  printf ("lost packet #%d\n", pacno);
  pacno++;

	for (i=2; ; i++)
    {
      if (4 != fread (&bufsize, 1, 4, fr))
        return 0;
      if (4 != fread (&intime, 1, 4, fr))
      {
        printf ("Panic, cannot read timestamp, old software version file?\n");
        return -1;
      }
      if (bufsize != fread (buf, 1, bufsize, fr))
      {
        printf ("Problems while reading buffer, exit\n");
        return -3;
      }

      if (4 != fwrite (&bufsize, 1, 4, fw))
      {
        printf ("Problems while writing buffer size, exit\n");
        return -1;
      }
      if (4 != fwrite (&intime, 1, 4, fw))
      {
        printf ("Problems while writing timestamp, exit\n");
        return -1;
      }
      if (bufsize != fwrite (buf, 1, bufsize, fw))
      {
        printf ("Problems while writing buffer, exit\n");
        return -3;
      }
      pacno++;
    }
 }
cherishren is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relationship Card ™ ® © sonnyboo Off Topic 5 26 May 2009 03:29 PM
Relationship of H.264 to MPEG-4 HDTiVo General Discussions 2 6 Oct 2005 08:08 AM
MPEG Packet Structure BigJohn_GF_ND General Discussions 2 19 May 2003 10:45 PM
SVCD bad packet... HELP!! Sephiroth Authoring 6 7 Feb 2003 04:58 AM



All times are GMT +10. The time now is 05:19 PM.

Kirsch designed by Andrew & Austin


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 1999 - 2018 Digital Digest

Visit DivXLand   Visit dvdloc8.com