我已使用此命令行转换.MOV视频:
ffmpeg -re -i 123.mov -vcodec copy -map 0 -f segment -segment_list 123.m3u8 \-segment_list_flags +live -segment_time 3 123%03d.ts
输出:
ffmpeg version N-81872-gbe1d324 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --prefix=/usr/local --enable-gpl --enable-nonfree
libavutil 55. 32.100 / 55. 32.100
libavcodec 57. 60.101 / 57. 60.101
libavformat 57. 51.102 / 57. 51.102
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 63.100 / 6. 63.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '123.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2016-09-26T19:34:01.000000Z
Duration: 00:00:20.00, start: 0.000000, bitrate: 1210 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1088 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 114 kb/s (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
Output #0, segment, to '123%03d.ts':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf57.51.102
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, q=2-31, 1088 kb/s, 30 fps, 30 tbr, 90k tbn, 600 tbc (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:1(und): Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
encoder : Lavc57.60.101 mp2
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
Press [q] to stop, [?] for help
frame= 1 fps=1.0 q=-1.0 size=N/A time=00:00:01.00 bitrate=N/A speed=0.996x
frame= 32 fps= 16 q=-1.0 size=N/A time=00:00:02.00 bitrate=N/A speed=0.987x
frame= 47 fps= 19 q=-1.0 size=N/A time=00:00:02.52 bitrate=N/A speed=0.996x
frame= 63 fps= 21 q=-1.0 size=N/A time=00:00:03.01 bitrate=N/A speed=0.993x
frame= 77 fps= 22 q=-1.0 size=N/A time=00:00:03.54 bitrate=N/A speed=0.998x
frame= 93 fps= 23 q=-1.0 size=N/A time=00:00:04.03 bitrate=N/A speed=0.995x
frame= 108 fps= 24 q=-1.0 size=N/A time=00:00:04.56 bitrate=N/A speed=0.999x
frame= 123 fps= 24 q=-1.0 size=N/A time=00:00:05.05 bitrate=N/A speed=0.997x
frame= 139 fps= 25 q=-1.0 size=N/A time=00:00:05.55 bitrate=N/A speed=0.996x
frame= 154 fps= 25 q=-1.0 size=N/A time=00:00:06.04 bitrate=N/A speed=0.994x
frame= 169 fps= 26 q=-1.0 size=N/A time=00:00:06.57 bitrate=N/A speed=0.997x
frame= 184 fps= 26 q=-1.0 size=N/A time=00:00:07.09 bitrate=N/A speed=0.999x
frame= 199 fps= 26 q=-1.0 size=N/A time=00:00:07.59 bitrate=N/A speed=0.998x
frame= 230 fps= 27 q=-1.0 size=N/A time=00:00:08.58 bitrate=N/A speed=0.995x
frame= 261 fps= 27 q=-1.0 size=N/A time=00:00:09.60 bitrate=N/A speed=0.996x
frame= 275 fps= 27 q=-1.0 size=N/A time=00:00:10.12 bitrate=N/A speed=0.998x
frame= 306 fps= 27 q=-1.0 size=N/A time=00:00:11.14 bitrate=N/A speed=0.999x
frame= 337 fps= 28 q=-1.0 size=N/A time=00:00:12.13 bitrate=N/A speed=0.997x
frame= 352 fps= 28 q=-1.0 size=N/A time=00:00:12.65 bitrate=N/A speed=0.998x
frame= 367 fps= 28 q=-1.0 size=N/A time=00:00:13.15 bitrate=N/A speed=0.997x
frame= 382 fps= 28 q=-1.0 size=N/A time=00:00:13.67 bitrate=N/A speed=0.999x
frame= 412 fps= 28 q=-1.0 size=N/A time=00:00:14.69 bitrate=N/A speed=0.999x
frame= 428 fps= 28 q=-1.0 size=N/A time=00:00:15.19 bitrate=N/A speed=0.998x
frame= 443 fps= 28 q=-1.0 size=N/A time=00:00:15.68 bitrate=N/A speed=0.998x
frame= 473 fps= 28 q=-1.0 size=N/A time=00:00:16.70 bitrate=N/A speed=0.998x
frame= 488 fps= 28 q=-1.0 size=N/A time=00:00:17.22 bitrate=N/A speed=0.999x
frame= 519 fps= 28 q=-1.0 size=N/A time=00:00:18.24 bitrate=N/A speed=0.999x
frame= 550 fps= 29 q=-1.0 size=N/A time=00:00:19.24 bitrate=N/A speed=0.998x
frame= 565 fps= 29 q=-1.0 size=N/A time=00:00:19.76 bitrate=N/A speed=0.999x
frame= 601 fps= 30 q=-1.0 Lsize=N/A time=00:00:20.02 bitrate=N/A speed= 1x
video:2663kB audio:939kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
最终视频可用here,我可以在Mac OS上的Safari中读取它,但它在使用AVPlayer或Safari的iOS上无效。
我也尝试使用this sample code provided by Apple播放它,但是我收到以下错误: “无法找到此媒体所需的解码器”
感谢任何帮助
编辑1
我编辑了命令行,现在我可以使用AVPlayer播放视频了,但是没有声音......
ffmpeg -i 123.mov -c:a libfdk_aac -profile:a aac_he -b:a 64k -c:v h264 -preset slow -map 0 -an -flags -global_header -f hls -hls_time 2 123%03d.ts
输出:
ffmpeg version N-81883-gbeb877b Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --enable-gpl --enable-nonfree --enable-shared --enable-libfdk-aac --enable-libx264 --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib
libavutil 55. 32.100 / 55. 32.100
libavcodec 57. 60.101 / 57. 60.101
libavformat 57. 51.102 / 57. 51.102
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 63.100 / 6. 63.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '123.mov':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2016-09-26T19:34:01.000000Z
Duration: 00:00:20.00, start: 0.000000, bitrate: 1210 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 540x960, 1088 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 114 kb/s (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (123%03d.ts) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Codec AVOption profile () specified for output file #0 (123%03d.ts) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
[libx264 @ 0x14ca8a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x14ca8a0] profile High, level 3.1
Output #0, hls, to '123%03d.ts':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
encoder : Lavf57.51.102
Stream #0:0(und): Video: h264 (libx264), yuv420p, 540x960, q=-1--1, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
creation_time : 2016-09-26T19:34:01.000000Z
handler_name : Core Media Data Handler
encoder : Lavc57.60.101 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 600 fps= 79 q=-1.0 Lsize=N/A time=00:00:19.90 bitrate=N/A dup=1 drop=0 speed=2.63x
video:3542kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x14ca8a0] frame I:18 Avg QP:21.70 size: 13958
[libx264 @ 0x14ca8a0] frame P:326 Avg QP:23.78 size: 7702
[libx264 @ 0x14ca8a0] frame B:256 Avg QP:24.83 size: 3380
[libx264 @ 0x14ca8a0] consecutive B-frames: 26.8% 46.0% 8.5% 18.7%
[libx264 @ 0x14ca8a0] mb I I16..4: 21.5% 71.7% 6.9%
[libx264 @ 0x14ca8a0] mb P I16..4: 14.9% 29.6% 1.5% P16..4: 32.2% 5.4% 2.2% 0.0% 0.0% skip:14.1%
[libx264 @ 0x14ca8a0] mb B I16..4: 3.0% 4.4% 0.3% B16..8: 37.9% 4.5% 0.4% direct: 5.0% skip:44.6% L0:50.0% L1:47.1% BI: 2.9%
[libx264 @ 0x14ca8a0] 8x8 transform intra:64.3% inter:82.5%
[libx264 @ 0x14ca8a0] direct mvs spatial:97.7% temporal:2.3%
[libx264 @ 0x14ca8a0] coded y,uvDC,uvAC intra: 30.0% 44.4% 4.9% inter: 10.1% 20.7% 0.4%
[libx264 @ 0x14ca8a0] i16 v,h,dc,p: 29% 33% 13% 26%
[libx264 @ 0x14ca8a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 24% 18% 4% 5% 6% 8% 5% 6%
[libx264 @ 0x14ca8a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 35% 11% 4% 6% 5% 9% 4% 6%
[libx264 @ 0x14ca8a0] i8c dc,h,v,p: 36% 29% 23% 12%
[libx264 @ 0x14ca8a0] Weighted P-Frames: Y:0.9% UV:0.3%
[libx264 @ 0x14ca8a0] ref P L0: 80.5% 9.7% 6.1% 2.0% 1.3% 0.2%
[libx264 @ 0x14ca8a0] ref B L0: 92.2% 5.5% 2.0% 0.3%
[libx264 @ 0x14ca8a0] ref B L1: 99.0% 1.0%
[libx264 @ 0x14ca8a0] kb/s:1450.98