Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any easy way to extract h.264 raw stream in annexb format?

When I extract video stream with ffmpeg using command-line:

ffmpeg -i {some file} -vcodec copy -an -f {rawvideo|h264|whatever} out.h264

with some media files produced by Adobe Media Encoder, only .m4v (encoded as h.264 blu-ray) files can produce some usable results.

Some other format(like .f4v) can produce h.264 stream, but without PPS/SPS, and each slice starts with size instead of 00 00 00 01 sequence.

I wish I can extract annexb format raw streams from as many as possible files that contains valid h.264 stream. I know I can add PPS/SPS and change size into 00 00 00 01 myself. But is there any existing software can do this?


Or can it be guaranteed that ffmpeg can always extract streams in annexb format from .m4v file, no matter with what software the file is encoded?

like image 609
BlueWanderer Avatar asked Apr 30 '12 07:04

BlueWanderer


1 Answers

What you are probably looking for is the h264_mp4toannexb bitstream filter, invoked with the -bsf command line option:

ffmpeg -i {some file} -vcodec copy -bsf h264_mp4toannexb -an -f {rawvideo|h264|whatever} out.h264

Be advised that if your version of FFmpeg is a bit old, you may need to use -vbsf instead of -bsf (the option was renamed recently).

like image 187
Multimedia Mike Avatar answered Jan 03 '23 06:01

Multimedia Mike