[FFmpeg-user] how can I set limit_filesize or recording_time for the specific output dynamically?
刘 岐
lingjiujianke at gmail.com
Wed Oct 16 01:31:24 CEST 2013
在 2013-10-16,上午12:14,Huang Soho <soho123.2012 at gmail.com> 写道:
>> ffmpeg version 1.2
>>
>> Please test current git head.
>>
>
>
> I have tested head version.
> I got the same result.
> "-segment_time 3" still does not function.
Hey,
Please try it , it can work when i used my camera
[root at CM ~]# ffmpeg -f video4linux2 -s 1280x720 -i /dev/video0 -preset ultrafast -force_key_frames 3,6,9,12,15,18,21,24 -vcodec libx264 -vprofile baseline -vlevel 1.0 -s 640x480 -b:v 800k -r 15 -pix_fmt yuv420p -map 0:0 -f segment -segment_format mpegts -segment_time 3 -segment_list a.m3u8 -segment_list_flags live -map 0 -flags -global_header video-%d.ts
ffmpeg version N-54918-g11cb697 Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 19 2013 08:54:07 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-3)
configuration: --disable-yasm --enable-libx264 --enable-gpl
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.102 / 3. 81.102
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 404985.663701, bitrate: 147456 kb/s
Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 1280x720, 147456 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc
[libx264 @ 0x289c4a0] frame MB size (40x30) > level limit (99)
[libx264 @ 0x289c4a0] DPB size (1 frames, 1200 mbs) > level limit (0 frames, 396 mbs)
[libx264 @ 0x289c4a0] MB rate (18000) > level limit (1485)
[libx264 @ 0x289c4a0] using cpu capabilities: none!
[libx264 @ 0x289c4a0] profile Constrained Baseline, level 1.0
[libx264 @ 0x289d160] frame MB size (40x30) > level limit (99)
[libx264 @ 0x289d160] DPB size (1 frames, 1200 mbs) > level limit (0 frames, 396 mbs)
[libx264 @ 0x289d160] MB rate (18000) > level limit (1485)
[libx264 @ 0x289d160] using cpu capabilities: none!
[libx264 @ 0x289d160] profile Constrained Baseline, level 1.0
[segment @ 0x289ba00] Codec for stream 0 does not use global headers but container format requires global headers
[segment @ 0x289ba00] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, segment, to 'video-%d.ts':
Metadata:
encoder : Lavf55.12.102
Stream #0:0: Video: h264 (libx264), yuv420p, 640x480, q=-1--1, 800 kb/s, 90k tbn, 15 tbc
Stream #0:1: Video: h264 (libx264), yuv420p, 640x480, q=-1--1, 800 kb/s, 90k tbn, 15 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo -> libx264)
Stream #0:0 -> #0:1 (rawvideo -> libx264)
Press [q] to stop, [?] for help
frame= 472 fps= 15 q=-1.0 Lq=-1.0 size=N/A time=00:00:31.46 bitrate=N/A dup=346 drop=0
video:6195kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000347%
[libx264 @ 0x289c4a0] frame I:9 Avg QP:24.56 size: 33423
[libx264 @ 0x289c4a0] frame P:463 Avg QP:27.58 size: 6201
[libx264 @ 0x289c4a0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x289c4a0] mb P I16..4: 12.1% 0.0% 0.0% P16..4: 62.3% 0.0% 0.0% 0.0% 0.0% skip:25.6%
[libx264 @ 0x289c4a0] final ratefactor: 27.96
[libx264 @ 0x289c4a0] coded y,uvDC,uvAC intra: 66.3% 68.2% 40.5% inter: 31.0% 29.2% 3.2%
[libx264 @ 0x289c4a0] i16 v,h,dc,p: 18% 21% 44% 17%
[libx264 @ 0x289c4a0] i8c dc,h,v,p: 61% 19% 15% 4%
[libx264 @ 0x289c4a0] kb/s:806.38
[libx264 @ 0x289d160] frame I:9 Avg QP:24.56 size: 33423
[libx264 @ 0x289d160] frame P:463 Avg QP:27.58 size: 6201
[libx264 @ 0x289d160] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x289d160] mb P I16..4: 12.1% 0.0% 0.0% P16..4: 62.3% 0.0% 0.0% 0.0% 0.0% skip:25.6%
[libx264 @ 0x289d160] final ratefactor: 27.96
[libx264 @ 0x289d160] coded y,uvDC,uvAC intra: 66.3% 68.2% 40.5% inter: 31.0% 29.2% 3.2%
[libx264 @ 0x289d160] i16 v,h,dc,p: 18% 21% 44% 17%
[libx264 @ 0x289d160] i8c dc,h,v,p: 61% 19% 15% 4%
[libx264 @ 0x289d160] kb/s:806.38
[root at CM ~]#
[root at CM ~]# ffmpeg -i video-0.ts -i video-1.ts -i video-2.ts -i video-3.ts -i video-4.ts -i video-5.ts
ffmpeg version N-54918-g11cb697 Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 19 2013 08:54:07 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-3)
configuration: --disable-yasm --enable-libx264 --enable-gpl
libavutil 52. 40.100 / 52. 40.100
libavcodec 55. 19.100 / 55. 19.100
libavformat 55. 12.102 / 55. 12.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 81.102 / 3. 81.102
libswscale 2. 4.100 / 2. 4.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Input #0, mpegts, from 'video-0.ts':
Duration: 00:00:02.93, start: 0.000000, bitrate: 2077 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #0:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Input #1, mpegts, from 'video-1.ts':
Duration: 00:00:02.93, start: 3.000000, bitrate: 1665 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #1:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #1:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Input #2, mpegts, from 'video-2.ts':
Duration: 00:00:02.93, start: 6.000000, bitrate: 1665 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #2:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #2:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Input #3, mpegts, from 'video-3.ts':
Duration: 00:00:02.93, start: 9.000000, bitrate: 1810 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #3:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #3:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Input #4, mpegts, from 'video-4.ts':
Duration: 00:00:02.93, start: 12.000000, bitrate: 1787 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #4:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #4:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Input #5, mpegts, from 'video-5.ts':
Duration: 00:00:02.93, start: 15.000000, bitrate: 1839 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #5:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
Stream #5:1[0x101]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480, 15 fps, 15 tbr, 90k tbn, 30 tbc
At least one output file must be specified
you can write a bash or other scripts, to compute the keyframe point from 0 ~ unlimited, and set the key frame at every 3s
for example:
I want to cat 24hours:
compute :
#define LIMIT 20 * 60 * 60;
int split_point = 0;
char buffer[8];
char keyframe_point_set[n];
for (split_point = 0; split_point < LIMIT; split_point += 3) {
memset(buffer, 0, strlen(buffer))
snprintf(buffer, sizeof(buffer), ",%s", split_point);
strncat(keyframe_point_set, buffer, strlen(buffer));
}
if you don't want do like this, perhaps you can set the *gopsize* as 1
:)
Carl,
Is there have some args can set the gop=1?
Thanks,
More information about the ffmpeg-user
mailing list