NVIDIA / VideoProcessingFramework

Set of Python bindings to C++ libraries which provides full HW acceleration for video decoding, encoding and GPU-accelerated color space and pixel format conversions
Apache License 2.0
1.31k stars 233 forks source link

Getting usable mp4 container with HEVC #407

Open Yozer opened 1 year ago

Yozer commented 1 year ago

Describe the bug I successfully encoded a video using hevc encoder and got raw annex b stream. Then I tried to mux it to mp4 container using the following command: ffmpeg -r 60 -f hevc -i encoded.mp4 -vcodec copy output.mp4. It created something but with two warnings:

[hevc @ 00000118e6e32380] Stream #0: not enough frames to estimate rate; consider increasing probesize
[mp4 @ 00000118e88bbf00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

The problem I have with the output.mp4 is that I can't find a player capable of playing it. If you open a video using, for example, MPC and let it play then it works just fine but as soon as you try to seek it freezes. The only solution I found so far was to reencode it using ffmpeg and their "hevc_nvenc" so it looks like annex b is fine but it's missing something to be playable.

Expected behavior Ability to seek the encoded video.

Desktop (please complete the following information):

Additional context My current encoder settings:

{
  'preset': 'P5', 
  'codec': 'hevc', 
  'bitrate': '40M', 
  'maxrate': '60M', 
  'tune': 'hq', 
  'tier': 'high', 
  'fps': '30',
  's': '1920x1080',
  'cq': '21', 
  'rc': 'vbr'
}
Renzzauw commented 1 year ago

Hi @Yozer, are you sure your FFmpeg command is correct? I think you need to place encoded.mp4 right after the -i.

Hope this helps!

Yozer commented 1 year ago

Updated, sorry! I was playing with this command a bit and posted the wrong version. Could it be because annex b stream doesn't have any iframes (except the first frame of course)?