Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编码再解码后帧顺序与原始输入视频不匹配 #5

Open
yaowangvrviu opened this issue Sep 25, 2018 · 0 comments
Open

编码再解码后帧顺序与原始输入视频不匹配 #5

yaowangvrviu opened this issue Sep 25, 2018 · 0 comments

Comments

@yaowangvrviu
Copy link

yaowangvrviu commented Sep 25, 2018

使用如下的ffmpeg命令生成一个特殊的视频序列,每帧都是黑屏,只是显示一个帧号(从0开始)
ffmpeg -i in_5s.mp4 -vf scale=176:144,drawbox=0:0:176:144:black:fill,drawtext=text=%{n}:x=(176-tw)/2:y=(144-th)/2:fontcolor=white:fontsize=30 -f rawvideo -pix_fmt yuv420p -y test_176x144.yuv
在我的in_5s.mp4码流有129帧。

使用这个视频测试AVS2

  1. 先编码
    ffmpeg -r 25 -s 176x144 -i test_176x144.yuv -vcodec libxavs2 -b:v 1M test.avs2
    此处显示的编码log看起来也是正常的:
    Stream mapping:
    Stream #0:0 -> #0:0 (rawvideo (native) -> avs2 (libxavs2))
    Press [q] to stop, [?] for help
    Output #0, avs2, to 'F:\testcase\test_sample\test.avs2':
    Metadata:
    encoder : Lavf58.12.100
    Stream #0:0: Video: avs2 (libxavs2), yuv420p, 176x144, q=2-31, 1000 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
    encoder : Lavc58.18.100 libxavs2
    frame= 129 fps=0.0 q=-0.0 Lsize= 75kB time=00:00:05.04 bitrate= 122.4kbits/s speed= 46x
    video:75kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

因为没有什么第三方的软件能够直接解码显示avs2的码流,所以只能把它解码成yuv看编码结果。

  1. 再解码
    ffmpeg -i test.avs2 -f rawvideo -pix_fmt yuv420p test_avs2_out.yuv
    此处显示的解码log,看起来就有些不对:
    Stream mapping:
    Stream #0:0 -> #0:0 (avs2 (libdavs2) -> rawvideo (native))
    Press [q] to stop, [?] for help
    Output #0, rawvideo, to 'F:\testcase\test_sample\test_avs2_out.yuv':
    Metadata:
    encoder : Lavf58.12.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, q=2-31, 7603 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
    encoder : Lavc58.18.100 rawvideo
    frame= 133 fps=0.0 q=-0.0 Lsize= 4938kB time=00:00:05.40 bitrate=7490.6kbits/s dup=12 drop=0 speed= 103x
    video:4938kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

帧数为133帧比输入的129帧要大。
逐帧比较test_176x144.yuv 和 test_avs2_out.yuv 发现
In frm index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ..., 41, 42, 43, 44, ... 91, 92, 93, 94, ... 128
Out frm index: 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8,..., 33, 33, 34, 34, ... 81, 81, 82, 82, ... 116
输出与输入之间存在较大的帧差,某些帧(1,2,33,81)被重复,某些帧(117-128)被丢弃。
如果参数中增加 -xavs2-params bframes=0 结果也是有较大的差别。

如果使用x264编码,逐帧比较test_176x144.yuv 和 test_x264_out.yuv 每帧都是一样的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant