【问题标题】:Concat two different videos连接两个不同的视频
【发布时间】:2017-11-23 17:22:48
【问题描述】:

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

ffmpeg -loop 1 -framerate 10 -i title.jpg -t 5 -pix_fmt yuv420p 标题.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%

您可能必须使视频保持相同,但是什么?以及如何?

提前致谢。

【问题讨论】:

  • 我不确定当编解码器不同时是否可以进行连接,您可能需要先重新编码其中一个...

标签: ffmpeg


【解决方案1】:

我们可以通过这样编码 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

但我宁愿不重新编码 video.avi 以免质量下降, 通过仅重新编码 title.avi 使其具有与 video.avi 相同的功能

【讨论】:

    【解决方案2】:

    试试

    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
    

    生成第一个视频。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-28
      • 2019-12-22
      • 2016-05-25
      • 2017-02-11
      • 2019-07-29
      • 1970-01-01
      • 2023-03-24
      相关资源
      最近更新 更多