Concat两个不同的视频

时间:2017-10-18 15:39:12

标签: ffmpeg

我想连续2个视频: 第一个title.avi是用图像制作的

  

ffmpeg -loop 1 -framerate 10 -i title.jpg -t 5 -pix_fmt yuv420p   title.avi

第二个video.avi来自相机

title.avi的信息

 ffmpeg -i title.avi

    ffmpeg version 2.1.5 Copyright (c) 2000-2014 the FFmpeg developers
      built on Jun 30 2014 00:37:24 with gcc 4.8.2 (GCC)
      configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-shared --disable-static --disable-debug --enable-pthreads --enable-x11grab --disable-libfaac --enable-libcaca --enable-librtmp --enable-libmp3lame --enable-libmodplug --enable-libspeex --enable-libwavpack --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libx264 --enable-libschroedinger --enable-libass --enable-libxvid --enable-gpl --enable-postproc --enable-libopus --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libcdio --enable-openal --enable-avresample --enable-version3 --disable-ssse3 --arch=i486 --cpu=i686
      libavutil      52. 48.101 / 52. 48.101
      libavcodec     55. 39.101 / 55. 39.101
      libavformat    55. 19.104 / 55. 19.104
      libavdevice    55.  5.100 / 55.  5.100
      libavfilter     3. 90.100 /  3. 90.100
      libavresample   1.  1.  0 /  1.  1.  0
      libswscale      2.  5.101 /  2.  5.101
      libswresample   0. 17.104 /  0. 17.104
      libpostproc    52.  3.100 / 52.  3.100
    Input #0, avi, from 'essai.avi':
      Metadata:
        encoder         : Lavf55.19.104
      Duration: 00:00:02.00, start: 0.000000, bitrate: 233 kb/s
        Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 59.94 tbn, 119.88 tbc
    At least one output file must be specified

video.avi的信息

ffmpeg -i video.avi
ffmpeg version 2.1.5 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun 30 2014 00:37:24 with gcc 4.8.2 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-shared --disable-static --disable-debug --enable-pthreads --enable-x11grab --disable-libfaac --enable-libcaca --enable-librtmp --enable-libmp3lame --enable-libmodplug --enable-libspeex --enable-libwavpack --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libx264 --enable-libschroedinger --enable-libass --enable-libxvid --enable-gpl --enable-postproc --enable-libopus --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libcdio --enable-openal --enable-avresample --enable-version3 --disable-ssse3 --arch=i486 --cpu=i686
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Guessed Channel Layout for  Input Stream #0.1 : stereo
Input #0, avi, from 'partA.avi':
  Metadata:
    encoder         : Lavf55.19.104
  Duration: 00:00:25.00, start: 0.000000, bitrate: 16089 kb/s
    Stream #0:0: Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1280x720 [SAR 1:1 DAR 16:9], 15038 kb/s, 119.88 fps, 59.94 tbr, 119.88 tbn, 119.88 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 32000 Hz, stereo, s16, 1024 kb/s
At least one output file must be specified

我想要连在一起,但这不起作用。 Mplayer在第一个视频结束时停止阅读。

命令的结果

>ffmpeg -f concat -i assemble -c copy out.avi
ffmpeg version 2.1.5 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun 30 2014 00:37:24 with gcc 4.8.2 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/man --enable-shared --disable-static --disable-debug --enable-pthreads --enable-x11grab --disable-libfaac --enable-libcaca --enable-librtmp --enable-libmp3lame --enable-libmodplug --enable-libspeex --enable-libwavpack --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libx264 --enable-libschroedinger --enable-libass --enable-libxvid --enable-gpl --enable-postproc --enable-libopus --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx --enable-libcdio --enable-openal --enable-avresample --enable-version3 --disable-ssse3 --arch=i486 --cpu=i686
  libavutil      52. 48.101 / 52. 48.101
  libavcodec     55. 39.101 / 55. 39.101
  libavformat    55. 19.104 / 55. 19.104
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 90.100 /  3. 90.100
  libavresample   1.  1.  0 /  1.  1.  0
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, concat, from 'assemble':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 59.94 tbn, 119.88 tbc
Output #0, avi, to 'anni2.avi':
  Metadata:
    ISFT            : Lavf55.19.104
    Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 59.94 tbn, 59.94 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[concat @ 0x8cfd250] Invalid stream index 1
    Last message repeated 319 times
[concat @ 0x8cfd250] Invalid stream index 1time=00:00:24.04 bitrate=6321.2kbits/s    
    Last message repeated 478 times
frame= 1619 fps=0.0 q=-1.0 Lsize=   46007kB time=00:00:54.00 bitrate=6979.0kbits/s    
video:45926kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.177626%

您可能必须使视频相同,但是什么?怎么样?

提前致谢。

2 个答案:

答案 0 :(得分:0)

尝试

ffmpeg -loop 1 -framerate 120 -i title.jpg -f lavfi -i anullsrc
    -c:v libx264 -profile:v baseline -pix_fmt yuv420p -x264opts stitchable
    -c:a pcm_s16le -ar 32000 -ac 2 -sample_fmt s16 -t 5 title.avi

生成第一个视频。

答案 1 :(得分:0)

我们可以通过编写像这样的2个视频来实现它

ffmpeg -i title.avi -c:v libx264 -preset slow -crf 15 -c:a copy title_coded.avi
ffmpeg -i video.avi -c:v libx264 -preset slow -crf 15 -c:a copy video_coded.avi

但我宁愿没有reencoder video.avi也不会失去质量, 通过仅重新编码title.avi来获得与video.avi相同的功能