问题
first time here so be gentle.
I've been working for a few weeks on a given H.264 byte stream:
General notes:
- The Byte Stream is not from a file, it is being fed live to me from an external source.
- The Byte Stream is encoded with Android's Media Codec.
- 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:
Converting the frames of the H264 stream to a saveable picture file (png/jpeg etc')
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