11

I would like to extract the raw .265 bitstream from HEVC mkv file. I use this:

ffmpeg.exe -i hevc.mkv -an -vcodec copy -f hevc bitstream.265

I got this error:

Requested output format 'hevc' is not a suitable output format

However, HEVC demuxer is already implemented and I can extract it to uncompressed raw YUV. ffmpeg -formats:

 File formats:
 D. = Demuxing supported
 .E = Muxing supported
D  hevc            raw HEVC video

What is wrong here?

slhck
  • 223,558
  • 70
  • 607
  • 592
Mark
  • 425
  • 2
  • 4
  • 9
  • 1
    I think you just need a `-f rawvideo`. Since the codec is copied, that should do it. – slhck Nov 21 '13 at 21:44
  • Well it does something, but the result is improper stream, i.e. can't be decoded with HM decoder 12.0 (TappDecoder.exe) – Mark Nov 24 '13 at 15:29

5 Answers5

14

The raw bitstream of H.264/H.265 is typically called the Annex B format. You can create those files with the following FFmpeg commands:

H.265 to Annex B

ffmpeg -i in.mkv -c:v copy -bsf hevc_mp4toannexb out.h265

does the trick with ffmpeg and H.265/HEVC.

H.264 to Annex B

For H.264 it's slightly different:

ffmpeg -i in.mkv -c:v copy -bsf h264_mp4toannexb out.h264
slhck
  • 223,558
  • 70
  • 607
  • 592
3

I tried the ffmpeg solution from Sebastian, but it didn't work for me. Here is what I did to get just the H.265 bitstream. I did see that some people suggested setting the output file extension to .bin, but I like h264/h265 as it makes it more clear what kind of bitstream the file contains.

H.265 to Annex B

ffmpeg -i test.mkv -c:v copy -bsf hevc_mp4toannexb -f hevc test.h265

H.264 to Annex B

ffmpeg -i test.mkv -c:v copy -bsf h264_mp4toannexb -f h264 test.h264

NOTE: This also works for .mov files and probably for other formats as well.

arndtc
  • 31
  • 1
  • 1
    So, you answer is identical to [Sebastian Annies’s answer](https://superuser.com/q/678897/150988#1251326) except you added back in the ``-h`` option that was in the question already (even though [dstob](https://superuser.com/q/678897/150988#770509) recommended leaving it out)?  If you’re going to compare your answer to somebody else’s answer, *compare your answer to the other answer* (i.e., describe how it’s different, and why). – Scott - Слава Україні Feb 28 '19 at 21:33
  • Thanks for the feedback, but I did try without the -h, but ffmpeg kept giving an error. I found that frustrating so I posted the solution that worked for me. – arndtc Mar 06 '19 at 22:56
1

So far, the best solution is to use MKVToolNix.

mkvextract.exe tracks hevc.mkv -f 0:bitstream.265
slhck
  • 223,558
  • 70
  • 607
  • 592
Mark
  • 425
  • 2
  • 4
  • 9
0

I would recommend using a file extension of .bin for your output. This is a raw bitstream file so that should be good enough.

You are doing a video copy so I would recommend leaving out the -f hevc and letting ffmpeg handle the format selection. If HEVC has been implemented in your version then it should work.

Also consider going with -c:v copy over -vcodec copy as the latter is deprecated.

I have a lot of experience with the h265 test model encoder and with using ffmpeg but not with the HEVC muxer in ffmpeg so my information may be inaccurate.

dstob
  • 303
  • 1
  • 5
-3

You might want check if you have a recent version of ffmpeg. If you want a video file without audio, try this:

ffmpeg -y -i hevc.mkv -codec:v copy videostream.mkv

or:

ffmpeg -y -i hevc.mkv -codec:v copy videostream.mp4
slhck
  • 223,558
  • 70
  • 607
  • 592