俩种方法都试了
第一种: ffmpeg -i "concat:1.flv|2.flv|3.flv|4.flv" -c copy all.flv
结果输出的视频里面只包含 1.flv 的内容
第二种: ffmpeg -y -f concat -i mylist.txt -c copy all.flv
直接报“ mylist.txt: Invalid argument ” 错误
cat mylist.txt
file './1.flv'
file './2.flv'
file './3.flv'
file './4.flv'ffmpeg -f concat -i mylist.txt -c:v copy all.flv
ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 7.0.0 (clang-700.0.72)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[flv @ 0x7fd484000600] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'mylist.txt':
Duration: N/A, bitrate: 1564 kb/s
Stream #0:0: Video: h264 (High), yuv420p, 1280x720, 1433 kb/s, 30 fps, 30 tbr, 1k tbn, 2k tbc
Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 131 kb/s
File 'all.flv' already exists. Overwrite ? [y/N] y
[flv @ 0x7fd483821200] Codec for stream 0 does not use global headers but container format requires global headers
Output #0, flv, to 'all.flv':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 1280x720, q=2-31, 1433 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002), 44100 Hz, stereo, fltp
Metadata:
encoder : Lavc56.60.100 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libmp3lame @ 0x7fd483822a00] Queue input is backward in time
[flv @ 0x7fd484000600] Stream discovered after head already parsed
[concat @ 0x7fd482008000] New subtitle stream 0:2 at pos:3248009 and DTS:16.55s
mylist.txt: Invalid argument
frame= 195 fps=0.0 q=-1.0 Lsize= 1401kB time=00:00:16.58 bitrate= 692.5kbits/s
video:1128kB audio:259kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.016911%
1
cnbeining 2015-12-26 09:00:28 +08:00 1
|
3
rungo OP 找到原因了,原来是录制的视频里面有损坏
|
4
rungo OP 结论:
ffmpeg 合并视频有 2 种方式拼接视频: 1 concat protocol 这个方法只适用于那些支持通过直接简单文件拼接就能产生新视频文件的格式,比如(MPEG-1, MPEG-2 PS, DV ) ffmpeg -i concat:"1.mpg|2.mpg" -c copy all.mpg 2 concat demuxer 使用方法没有 1 的使用限制 ffmpeg -f concat -i mylist.txt -c copy all.flv mylist.txt 用于指定视频列表, 的文件格式是这样: file '1.flv' file '2.flv' file '3.flv' file '4.flv' 如果视频录制时有损坏,第二种方法就会出现主贴里面的错误“ invalid argument ”, 解决方法就是,把视频先转换成 mpg 格式,然后用第一种方法拼接,然后再转换回原来格式,稍微麻烦一点。 ffmpeg -i 1.flv -qscale:v 1 1.mpg ffmpeg -i 2.flv -qscale:v 1 2.mpg ffmpeg -i concat:"1.mpg|2.mpg" -c copy all.mpg ffmpeg -i all.mpg -qscale:v 1 all.flv |
5
rungo OP 更新,发现了一个简单方法:
可以指定视频和音频编码,有错误也会自动跳过去 ffmpeg -f concat -i inputs.txt -c:v h264 -c:a mp3 films.flv |