0

Im trying to extract each frame from a rtsp mp4 stream, and convert that into a jpeg/gif using ffmpeg. I'm getting the sdp header from 000001b0.....000001b5, and adding that into an byte array then capturing a frame starting from 000001b6 and appending it to the byte array.

When I flush it to a file (.mpg) and use ffmpeg it throws errors and not converting. my header looks like 000001B008000001B58913000001000000012000C488BA98514043C1463F and after this I'm appending a frame (starting from 000001b6).

César
  • 9,939
  • 6
  • 53
  • 74
darleys
  • 412
  • 4
  • 10

2 Answers2

0

Depending on the Codec you may not have to add anything or you may have to add a lot..

This is referred to as de-packetization and MPEG4-ES has no packetization model... H264 has many depending on the profile.

Check out the RFC..

Either 3016 or 3640 should help you.

https://www.rfc-editor.org/rfc/rfc3640

https://www.rfc-editor.org/rfc/rfc3016

Community
  • 1
  • 1
Jay
  • 3,276
  • 1
  • 28
  • 38
0

I did something similar with FFMPEG, and it seems that the frame data you get from FFMPEG already contains the frame header, which is all you need to transcode the data. Please make sure that you decode the mp4 data to a raw format (RGB24 for instance), then encode it to the pixelformat the JPEG/GIF encoder expects (probably a YUV format) using libswscale, before passing the data to the encoder.