ffmpeg mp4 视频无法在 iPhone 上运行

ffmpeg mp4 视频无法在 iPhone 上运行

我的网站上有 ffmpeg,可以让用户创建各种 mp4,除了我的一个转换函数不允许视频在我的 iphone 上播放外,它们在所有设备上都可以正常工作。同样的视频在我的笔记本电脑上的 chrome 中可以正常播放。

这是我使用的代码——

// first we merge the audio file with the concat file for images
ffmpeg -i '.$thepath .'/audio.mp3 \
-safe 0 -f concat -i '.$thepath .'/paths.txt \
-af "volume=-1dB" -c:v libx264 -vprofile baseline \
-vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" -t 180 -pix_fmt yuv420p -movflags +faststart -y '.$output.' 2>&1

// now add background music
ffmpeg \
-i '.$output.' -i '.$musicpath .'/'.$music.'.mp3 \
-filter_complex "[1:a]volume=-25dB,apad[A];[0:a][A]amerge[out]" \
-c:v copy -map 0:v -map [out] -vprofile baseline -level 3.0 \
-pix_fmt yuv420p -movflags +faststart -shortest \
-y '.$thepath.'/output-'.$v_Id.'.mp4 2>&1

由于这是在 iPhone 上发生的,而我没有 Mac,所以我看不到输出。不过,在我的笔记本电脑上运行相同的代码,我得到了这个输出 ---

ffmpeg version N-90767-g768c077-syslint Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
  libavutil      56. 15.100 / 56. 15.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 18.100 /  7. 18.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[mp3 @ 0x12c1900] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/path/to/audio.mp3':
  Metadata:
    encoder         : Lavf57.71.100
  Duration: 00:00:18.00, start: 0.000000, bitrate: 48 kb/s
    Stream #0:0: Audio: mp3, 22050 Hz, mono, fltp, 48 kb/s
Input #1, concat, from '/path/to/paths.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #1:0: Video: png, rgb24(pc), 754x424, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #1:0 -> #0:0 (png (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x12eb740] using cpu capabilities: none!
[libx264 @ 0x12eb740] profile Constrained Baseline, level 3.1
[libx264 @ 0x12eb740] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=22 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/path/to/output-4672-first.mp4':
  Metadata:
    encoder         : Lavf58.13.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.19.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc58.19.100 aac
[swscaler @ 0x13ddb00] Warning: data is not aligned! This can lead to a speed loss
frame=  151 fps= 47 q=28.0 size=       0kB time=00:00:03.48 bitrate=   0.1kbits/s dup=149 drop=0 speed=1.08x    
frame=  301 fps= 50 q=28.0 size=       0kB time=00:00:09.48 bitrate=   0.0kbits/s dup=298 drop=0 speed=1.58x    
frame=  451 fps= 54 q=28.0 size=     256kB time=00:00:15.48 bitrate= 135.5kbits/s dup=447 drop=0 speed=1.87x    
frame=  599 fps= 58 q=28.0 size=     512kB time=00:00:21.40 bitrate= 196.0kbits/s dup=595 drop=0 speed=2.06x    
[mp4 @ 0x12ea0c0] Starting second pass: moving the moov atom to the beginning of the file
frame=  599 fps= 54 q=-1.0 Lsize=     619kB time=00:00:23.92 bitrate= 212.0kbits/s dup=743 drop=0 speed=2.16x    
video:434kB audio:175kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.592660%
[libx264 @ 0x12eb740] frame I:4     Avg QP:13.86  size: 99376
[libx264 @ 0x12eb740] frame P:595   Avg QP:14.17  size:    78
[libx264 @ 0x12eb740] mb I  I16..4: 43.0%  0.0% 57.0%
[libx264 @ 0x12eb740] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.5%  0.1%  0.0%  0.0%  0.0%    skip:99.5%
[libx264 @ 0x12eb740] coded y,uvDC,uvAC intra: 57.5% 55.0% 48.9% inter: 0.0% 0.4% 0.0%
[libx264 @ 0x12eb740] i16 v,h,dc,p: 74% 11%  4% 11%
[libx264 @ 0x12eb740] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 30% 12%  4%  5%  4%  7%  4%  7%
[libx264 @ 0x12eb740] i8c dc,h,v,p: 56% 21% 17%  5%
[libx264 @ 0x12eb740] ref P L0: 95.5%  2.6%  1.9%
[libx264 @ 0x12eb740] kb/s:148.30
[aac @ 0x12ecac0] Qavg: 9185.104

ffmpeg version N-90767-g768c077-syslint Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
  libavutil      56. 15.100 / 56. 15.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.100 / 58. 13.100
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 18.100 /  7. 18.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/path/to/output-4672-first.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.13.100
  Duration: 00:00:23.96, start: 0.000000, bitrate: 211 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 148 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 79 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mp3, from '/path/to/creative_minds.mp3':
  Duration: 00:02:27.23, start: 0.025057, bitrate: 160 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 160 kb/s
    Metadata:
      encoder         : LAME3.97 
    Side data:
      replaygain: track gain - -8.100000, track peak - unknown, album gain - unknown, album peak - unknown, 
Stream mapping:
  Stream #0:1 (aac) -> amerge:in0
  Stream #1:0 (mp3float) -> volume
  Stream #0:0 -> #0:0 (copy)
  amerge -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[Parsed_amerge_2 @ 0x95f580] No channel layout for input 1
Output #0, mp4, to '/path/to/output-4672.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.13.100
    Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, q=2-31, 148 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, 3.0, fltp, 197 kb/s (default)
    Metadata:
      encoder         : Lavc58.19.100 aac
frame=  439 fps=0.0 q=-1.0 size=     768kB time=00:00:17.52 bitrate= 359.1kbits/s speed=  35x    
[mp4 @ 0x78dc80] Starting second pass: moving the moov atom to the beginning of the file
frame=  599 fps=0.0 q=-1.0 Lsize=     889kB time=00:00:23.92 bitrate= 304.6kbits/s speed=46.5x    
video:434kB audio:445kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.096470%

相关内容