Encoding H.264 CBR videos with FFmpeg

后端 未结 4 1133
长发绾君心
长发绾君心 2021-02-04 09:25

I\'m trying to encode a video with ffmpeg into H.264 (via the libx264 library) with a constant bit rate. I know, I know, VBR is often preferred, but for this specific job I\'m

相关标签:
4条回答
  • 2021-02-04 09:55

    This may be a clue (assuming you have a bitrate set) "CBR is when maxrate == bitrate and bufsize is set" http://ffmpeg-users.933282.n4.nabble.com/Does-constant-bitrate-exist-in-libx264-td2255554.html

    bufsize is supposed to be the "receiving client's" max buffer size.

    0 讨论(0)
  • 2021-02-04 10:00

    I too have been working on trying to get CBR out of x264. I found this blog post by Dark Shakari quite interesting.

    Here is what I have for low-latency CBR video to an MPEG tranport stream:

    ffmpeg -i sintel_trailer-720p.mp4 -an -tune zerolatency \
           -x264opts bitrate=4000:vbv-maxrate=4000:vbv-bufsize=166 \
           -vcodec libx264 -f mpegts -muxrate 4000K -y trailer.ts
    

    According the x264 developer's blog you set:

    • vbv-maxrate = bitrate = B = target bitrate
    • vbv-bufsize = B / fps (in this video's case that's 24 fps)

    Finally, set the ffmpeg switch for x264 of -tune zerolatency.

    Hope that's helpful. And, if anyone has improvements to this please do let me know!

    0 讨论(0)
  • 2021-02-04 10:10

    Specify -nal-hrd cbr after -bufsize 400000.

    0 讨论(0)
  • 2021-02-04 10:11

    Ok, so I think I may have found part of the problem. Making -bufsize greater than the data rate seems to have solved the problem. Of course, I don't know if it's encoding real CBR, but the data rate that Quick Time Inspector reads looks right now.

    0 讨论(0)
提交回复
热议问题