H264 ByteStream to Image Files

怎甘沉沦 提交于 2021-01-05 07:46:24

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/60139561/h264-bytestream-to-image-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!