Tzah Mazuz
Tzah Mazuz

Reputation: 59

H264 ByteStream to Image Files

first time here so be gentle.

I've been working for a few weeks on a given H.264 byte stream:

General notes:

  1. The Byte Stream is not from a file, it is being fed live to me from an external source.
  2. The Byte Stream is encoded with Android's Media Codec.
  3. When writing the stream into a file with a .H264 extension, VLC is able to play it properly.

What I'm trying to achieve? One of the following:

  1. Converting the frames of the H264 stream to a saveable picture file (png/jpeg etc')

  2. Converting the H264 raw bytes into a MP4 stream that can be played as source by a browser.

I tried already using JavaCV (FFmpegFrameGrabber) without any success, my main problem is that i have no idea how to parse the byte stream or what each "packet" means

So, I've attached a text file with some of the packets I'm getting from the stream H264 Packets

Upvotes: 2

Views: 6690

Answers (1)

llogan
llogan

Reputation: 133923

Converting the frames of the H264 stream to a saveable picture file (png/jpeg etc')

Assuming you are using the ffmpeg cli tool.

Single image:

ffmpeg -framerate 25 -i input.h264 -frames:v 1 output.png

Single image at 01:23:45 timestamp:

ffmpeg -framerate 24 -i input.h264 -ss 01:23:45 -frames:v 1 output.png

All images. Will be named output_0001.png, output_0002.png, output_0003.png, etc. No need to set -framerate or -frames:v in this case.

ffmpeg -i input.h264 output_%04d.png

See FFmpeg image muxer for more info.

Converting the H264 raw bytes into a MP4 stream that can be played as source by a browser.

ffmpeg -framerate 24000/1001 -i input.h264 -c copy -movflags +faststart output.mp4

Upvotes: 1

Related Questions