合并后如何获得高质量的视频

时间:2018-04-03 07:42:43

标签: ffmpeg

我按照Create a mosaic out of several input videos页面合并视频。但是,我的视频质量很差。如何将视频与原始视频相同。

ffmpeg
-i 1.flv-i 2.flv -i 3.flv -i 4.flv
-filter_complex "
    nullsrc=size=640x480 [base];
    [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
    [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
    [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
    [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
    [base][upperleft] overlay=shortest=1 [tmp1];
    [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
    [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
    [tmp3][lowerright] overlay=shortest=1:x=320:y=240
"
-f flv rtmp://10.240.209.94:9999/live2

当我使用rtmp:// **作为视频输入时。 如:

    ffmpeg-i rtmp://10.240.209.94:9999/live1 -i rtmp://10.240.209.94:9999/live1 -i rtmp://10.240.209.94:9999/live1 -i rtmp://10.240.209.94:9999/live1
-filter_complex "
    nullsrc=size=640x480 [base];
    [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
    [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
    [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
    [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
    [base][upperleft] overlay=shortest=1 [tmp1];
    [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
    [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
    [tmp3][lowerright] overlay=shortest=1:x=320:y=240
"
-f flv rtmp://10.240.209.94:9999/live2

它告诉我:

Stream specifier ':v' in filtergraph description  nullsrc=size=640x480 [base];[0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];[1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];[2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];[3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];[base][upperleft] overlay=shortest=1 [tmp1];[tmp1][upperright] overlay=shortest=1:x=320 [tmp2];[tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];[tmp3][lowerright] overlay=shortest=1:x=320:y=240 matches no streams.

这是一个错误吗?但我使用最新的ffmepg。 bug

我只能使用命令:

ffmpeg -i rtmp://10.240.209.94:9999/live10 -vcodec copy -acodec copy -f flv output.flv 

将rtmp转移到flv中,然后阅读flv video ...

1 个答案:

答案 0 :(得分:1)

由于您正在输出FLV并且尚未指定编码器,因此ffm​​peg正在选择flv1。默认情况下,它将使用200 kbps的目标比特率。

因此,您可以设置质量比例目标,例如

... -q:v 5 -f flv rtmp://10.240.209.94:9999/live2

或wsitch到x264,其默认值应该没问题

... -c:v libx264 -f flv rtmp://10.240.209.94:9999/live2