如何使用 FFMPEG 连接 Android (3GP4) 视频?

如何使用 FFMPEG 连接 Android (3GP4) 视频?

我在 CentoS 6 x64 系统上安装了 FFMPEG:

FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0

我正在尝试连接从手机上传的视频 - 它们可以是 Android 和 iPhone 上传的任意组合。此过程似乎适用于 iPhone 视频,但对于 Android (3GP4) 视频,它会不断复制相同的帧并且进展极其缓慢:

[root@ks383641 html]# ./interleave.sh /mnt/content/09zmWtIt8EvimTIy.mp4 /mnt/content/09zmWtIt8EvimTIy.mp4 out.mp4
MultiMedia Concat Script v1.3 (mmcat) - A script to concatenate multiple multimedia files.
Based on FFmpeg - www.ffmpeg.org
Don't forget to edit this script and change EXTRA_OPTIONS

FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 29 2012 17:52:15 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
  libavutil     50.15. 1 / 50.15. 1
  libavcodec    52.72. 2 / 52.72. 2
  libavformat   52.64. 2 / 52.64. 2
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.19. 0 /  1.19. 0
  libswscale     0.11. 0 /  0.11. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[u16le @ 0xff3690]Estimating duration from bitrate, this may be inaccurate
Input #0, u16le, from '/tmp/mcs_a_all':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
[yuv4mpegpipe @ 0xffce20]Estimating duration from bitrate, this may be inaccurate
Input #1, yuv4mpegpipe, from '/tmp/mcs_v_all':
  Duration: N/A, bitrate: N/A
    Stream #1.0: Video: rawvideo, yuv420p, 1920x1080, 90k tbr, 90k tbn, 90k tbc
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x1007a90]MB rate (734400000) > level limit (983040)
[libx264 @ 0x1007a90]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0x1007a90]profile Constrained Baseline, level 5.1
[libx264 @ 0x1007a90]264 - core 107 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0x1:0 me=dia subme=0 psy=1 psy_rd=0.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=0
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf52.64.2
    Stream #0.0: Video: libx264, yuv420p, 1920x1080, q=10-51, 200 kb/s, 90k tbn, 90k tbc
    Stream #0.1: Audio: libfaac, 44100 Hz, 2 channels, s16, 128 kb/s
Stream mapping:
  Stream #1.0 -> #0.0
  Stream #0.0 -> #0.1
Press [q] to stop encoding
frame= 1662 fps=239 q=-1.0 Lsize=     378kB time=0.02 bitrate=167700.6kbits/s dup=0 drop=17    
video:364kB audio:0kB global headers:0kB muxing overhead 3.895104%
[libx264 @ 0x1007a90]frame I:7     Avg QP:18.29  size: 45202
[libx264 @ 0x1007a90]frame P:1655  Avg QP:21.00  size:    34
[libx264 @ 0x1007a90]mb I  I16..4: 77.0%  0.0% 23.0%
[libx264 @ 0x1007a90]mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:99.9%
[libx264 @ 0x1007a90]coded y,uvDC,uvAC intra: 20.0% 35.7% 8.8% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x1007a90]i16 v,h,dc,p: 72% 17%  6%  5%
[libx264 @ 0x1007a90]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 30% 25%  2%  4%  2%  5%  2%  6%
[libx264 @ 0x1007a90]i8c dc,h,v,p: 56% 22% 16%  6%
[libx264 @ 0x1007a90]kb/s:161117.11
Received signal 2: terminating.
^C

我在用以下脚本。是否有特殊方法可以连接 Android 视频?如果有,我该怎么做?

答案1

您使用的 FFmpeg 版本非常旧,可能无法正确处理该文件格式。请将 FFmpeg 更新到最新版本,您可以在FFmpeg 下载页面

答案2

第一的,获取最新版本的 ffmpeg。然后,不要使用该脚本,而是使用连接解复用器如 ffmpeg wiki 页面所述你链接到;如果不起作用,尝试 concat筛选(来自同一页面)。

Concat 解复用器

首先,创建一个名为的文件inputs.txt,其中包含如下行:

file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

然后像这样使用解复用器:

ffmpeg -f concat -i inputs.txt -c copy output.mp4
## or something like:
ffmpeg -f concat -i inputs.txt -c:v libx264 -preset veryfast -crf 22 -c:a copy output.mp4

相关内容