ffmpeg -i cctv1.mp4 -codec copy cctv1.ts
$ ffmpeg -i cctv1.mp4 -codec copy cctv1.ts Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Output #0, mpegts, to 'cctv1.ts': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, q=2-31, 2088 kb/s, 25 fps, 25 tbr, 90k tbn, 12800 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy)
ffmpeg -i cctv1.flv -acodec aac cctv1.mp4
$ ffmpeg -i cctv1.flv -acodec aac cctv1.mp4 Input #0, flv, from 'cctv1.flv': Metadata: encoder : Lavf58.20.100 Duration: 00:00:23.69, start: 0.000000, bitrate: 1793 kb/s Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s Stream #0:1: Video: flv1, yuv420p, 1920x1080, 200 kb/s, 25 fps, 25 tbr, 1k tbn Stream mapping: Stream #0:1 -> #0:0 (flv1 (flv) -> h264 (libx264)) Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native)) Output #0, mp4, to 'cctv1.mp4': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc58.54.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), 48000 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.flv -vcodec h264 cctv1.mp4
$ ffmpeg -i cctv1.flv -vcodec h264 cctv1.mp4 Input #0, flv, from 'cctv1.flv': Metadata: encoder : Lavf58.20.100 Duration: 00:00:23.69, start: 0.000000, bitrate: 1793 kb/s Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s Stream #0:1: Video: flv1, yuv420p, 1920x1080, 200 kb/s, 25 fps, 25 tbr, 1k tbn Stream mapping: Stream #0:1 -> #0:0 (flv1 (flv) -> h264 (libx264)) Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native)) Output #0, mp4, to 'cctv1.mp4': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc58.54.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), 48000 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.flv -acodec aac -vcodec h264 cctv1.mp4
$ ffmpeg -i cctv1.flv -acodec aac -vcodec h264 cctv1.mp4 Input #0, flv, from 'cctv1.flv': Metadata: encoder : Lavf58.20.100 Duration: 00:00:23.69, start: 0.000000, bitrate: 1793 kb/s Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s Stream #0:1: Video: flv1, yuv420p, 1920x1080, 200 kb/s, 25 fps, 25 tbr, 1k tbn Stream mapping: Stream #0:1 -> #0:0 (flv1 (flv) -> h264 (libx264)) Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native)) Output #0, mp4, to 'cctv1.mp4': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc58.54.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), 48000 Hz, stereo, fltp, 128 kb/s Metadata: encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.mp4 -r 15 cctv1_15fps.mp4
$ ffmpeg -i cctv1.mp4 -r 15 cctv1_15fps.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Output #0, mp4, to 'cctv1_15fps.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 15 fps, 15360 tbn, 15 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.mp4 -b:v 400k -b:a 100k cctv1_15fps.mp4
$ ffmpeg -i cctv1.mp4 -b:v 400k -b:a 100k cctv1_15fps.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Output #0, mp4, to 'cctv1_15fps.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 400 kb/s, 25 fps, 12800 tbn, 25 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/400000 buffer size: 0 vbv_delay: -1 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 100 kb/s (default) Metadata: handler_name : SoundHandler encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.mp4 -s 1280x720 cctv1_1280x720.mp4
$ ffmpeg -i cctv1.mp4 -s 1280x720 cctv1_1280x720.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Output #0, mp4, to 'cctv1_1280x720.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler encoder : Lavc58.54.100 aac
$ ffmpeg -i cctv1.mp4 -ar 44100 cctv1_44100.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Output #0, mp4, to 'cctv1_44100.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default) Metadata: handler_name : VideoHandler encoder : Lavc58.54.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler encoder : Lavc58.54.100 aac
ffmpeg -i cctv1.mp4 -ss 5 -t 3 -codec copy 1.mp4
$ ffmpeg -i cctv1.mp4 -ss 5 -t 3 -codec copy 1.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cctv1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:23.72, start: 0.000000, bitrate: 2154 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Output #0, mp4, to '1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, q=2-31, 2088 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 78 kb/s (default) Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) frame= 0 fps=0.0 q=-1.0 Lsize= 48kB time=00:00:02.97 bitrate= 132.5kbits/s speed=1.08e+03x
编写concat文件
file '1.mp4' file '2.mp4'
ffmpeg -f concat -i filelist.txt -codec copy output.mp4
$ ffmpeg -f concat -i filelist.txt -codec copy output.mp4 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x559349f6e500] Auto-inserting h264_mp4toannexb bitstream filter Input #0, concat, from 'filelist.txt': Duration: N/A, start: -0.021333, bitrate: 3796 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 3668 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s Metadata: handler_name : SoundHandler Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf58.29.100 Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, q=2-31, 3668 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s Metadata: handler_name : SoundHandler Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) [mov,mp4,m4a,3gp,3g2,mj2 @ 0x559349f7f080] Auto-inserting h264_mp4toannexb bitstream filter frame= 150 fps=0.0 q=-1.0 Lsize= 2646kB time=00:00:06.04 bitrate=3588.7kbits/s speed= 267x video:2548kB audio:93kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.191427% Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:03.02, start: 0.000000, bitrate: 3778 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 3668 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default) Metadata: handler_name : SoundHandler Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:03.00, start: 0.000000, bitrate: 3422 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 3287 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default) Metadata: handler_name : SoundHandler Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.29.100 Duration: 00:00:06.06, start: 0.000000, bitrate: 3575 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 3465 kb/s, 24.91 fps, 50 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s (default) Metadata: handler_name : SoundHandler