Commit ef44a607 authored by Anton Khirnov's avatar Anton Khirnov

avconv: rescue poor abused recording_time global.

Keep a per-OutputFile instance of it, thus making -t work with multiple
output files.
parent 2886aee7
......@@ -272,6 +272,7 @@ typedef struct OutputStream {
int sws_flags;
AVDictionary *opts;
int is_past_recording_time;
} OutputStream;
typedef struct InputStream {
......@@ -289,7 +290,6 @@ typedef struct InputStream {
double ts_scale;
int is_start; /* is 1 at the start and after a discontinuity */
int showed_multi_packet_warning;
int is_past_recording_time;
AVDictionary *opts;
} InputStream;
......@@ -305,6 +305,7 @@ typedef struct OutputFile {
AVFormatContext *ctx;
AVDictionary *opts;
int ost_index; /* index of the first stream in output_streams */
int64_t recording_time; /* desired length of the resulting file in microseconds */
} OutputFile;
static InputStream *input_streams = NULL;
......@@ -1577,12 +1578,20 @@ static int output_packet(InputStream *ist, int ist_index,
encode packets and output them */
if (start_time == 0 || ist->pts >= start_time)
for(i=0;i<nb_ostreams;i++) {
OutputFile *of = &output_files[ost_table[i].file_index];
int frame_size;
ost = &ost_table[i];
if (ost->source_index != ist_index)
continue;
if (of->recording_time != INT64_MAX &&
av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + start_time,
(AVRational){1, 1000000}) >= 0) {
ost->is_past_recording_time = 1;
continue;
}
#if CONFIG_AVFILTER
if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
ost->input_video_filter) {
......@@ -2235,7 +2244,7 @@ static int transcode(OutputFile *output_files,
ost = &output_streams[i];
os = output_files[ost->file_index].ctx;
ist = &input_streams[ost->source_index];
if(ist->is_past_recording_time || no_packet[ist->file_index])
if(ost->is_past_recording_time || no_packet[ist->file_index])
continue;
opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = ist->pts;
......@@ -2329,13 +2338,6 @@ static int transcode(OutputFile *output_files,
}
}
/* finish if recording time exhausted */
if (recording_time != INT64_MAX &&
av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
ist->is_past_recording_time = 1;
goto discard_packet;
}
//fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->st->index, pkt.size);
if (output_packet(ist, ist_index, output_streams, nb_output_streams, &pkt) < 0) {
......@@ -3559,6 +3561,7 @@ static void opt_output_file(const char *filename)
output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1);
output_files[nb_output_files - 1].ctx = oc;
output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams;
output_files[nb_output_files - 1].recording_time = recording_time;
av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0);
/* check filename in case of an image number is expected */
......@@ -3684,6 +3687,7 @@ static void opt_output_file(const char *filename)
audio_channels = 0;
audio_sample_fmt = AV_SAMPLE_FMT_NONE;
chapters_input_file = INT_MAX;
recording_time = INT64_MAX;
av_freep(&meta_data_maps);
nb_meta_data_maps = 0;
......
......@@ -62,4 +62,3 @@
0, 171000, 921600, 0x5639e670
1, 171429, 1000, 0xa491f3ef
1, 175510, 1000, 0x2c036e18
1, 179592, 1000, 0x52d65e2a
......@@ -213,335 +213,3 @@
1, 265680, 768, 0xfd6c7597
0, 267267, 1327, 0x7d15307c
1, 267840, 768, 0x8d766d40
0, 270270, 1225, 0x1b5d0f5f
0, 273273, 1173, 0x840efed5
0, 276276, 1215, 0xa8e0035e
0, 279279, 1295, 0x142918ca
0, 282282, 1144, 0xf50cef50
0, 285285, 1527, 0x7d13bd9d
0, 288288, 5609, 0x1ae1921d
0, 291291, 1303, 0xabdc264f
0, 294294, 1419, 0x878169bf
0, 297297, 972, 0x00c4a257
0, 300300, 1277, 0x87d520cf
0, 303303, 1014, 0x5946b4ee
0, 306306, 1177, 0x124e0e23
0, 309309, 1402, 0x8e6363cc
0, 312312, 1171, 0x9bdaeda2
0, 315315, 1389, 0x2db53b22
0, 318318, 1056, 0xd1c3de3e
0, 321321, 1320, 0x1ea142c7
0, 324324, 1250, 0x33612229
0, 327327, 1477, 0xb9648b48
0, 330330, 1522, 0x5352c318
0, 333333, 1391, 0x5e9157e0
0, 336336, 5545, 0x569e64c1
0, 339339, 1354, 0xdb39469e
0, 342342, 1302, 0x79912b5d
0, 345345, 1065, 0x4befcdd2
0, 348348, 1408, 0x7d2f65a2
0, 351351, 1727, 0x9cac0398
0, 354354, 1590, 0xa321b563
0, 357357, 1039, 0xfa35cabf
0, 360360, 1184, 0xb332fde7
0, 363363, 669, 0xb10e3783
0, 366366, 784, 0x57275e09
0, 369369, 1051, 0xe072cd33
0, 372372, 1119, 0x635ee9ee
0, 375375, 1147, 0x3916f981
0, 378378, 1086, 0x306ef895
0, 381381, 827, 0x213f7aef
0, 384384, 5525, 0x19157827
0, 387387, 1044, 0xb661abc5
0, 390390, 1143, 0x032e1109
0, 393393, 1460, 0x5a2f9503
0, 396396, 1178, 0xd038141f
0, 399399, 1004, 0x410ec3b2
0, 402402, 1089, 0xc89af8c9
0, 405405, 1367, 0x52085e0a
0, 408408, 1115, 0x8bb2ee7f
0, 411411, 1325, 0xc2e05647
0, 414414, 1295, 0x213951c9
0, 417417, 1054, 0xbb8bdaae
0, 420420, 1210, 0x431122bd
0, 423423, 1400, 0x47526fcc
0, 426426, 1188, 0x19770b07
0, 429429, 1301, 0x437161c8
0, 432432, 5281, 0xc0c92b55
0, 435435, 840, 0x67da7b2f
0, 438438, 1094, 0x3fd6d944
0, 441441, 832, 0x0eda74bc
0, 444444, 1096, 0x3300da7b
0, 447447, 1018, 0xa208c971
0, 450450, 1389, 0x1167724c
0, 453453, 1411, 0xe3be666b
0, 456456, 1294, 0xa8f35cc6
0, 459459, 1232, 0xfd0d20fd
0, 462462, 1252, 0xadd83a26
0, 465465, 844, 0xcbaf6a55
0, 468468, 979, 0x78d9b241
0, 471471, 1057, 0x6743e16c
0, 474474, 776, 0xfedd6615
0, 477477, 1158, 0xa39fee34
0, 480480, 5288, 0x5f26ee02
0, 483483, 1029, 0xa681bee8
0, 486486, 1106, 0xa68dea33
0, 489489, 844, 0x42fd83ec
0, 492492, 779, 0xb5006759
0, 495495, 951, 0xec13af4f
0, 498498, 1011, 0x90e5c86e
0, 501501, 892, 0x4db48ca4
0, 504504, 804, 0x59bf73a7
0, 507507, 1001, 0x10c2b3ff
0, 510510, 879, 0x65c57eaf
0, 513513, 1320, 0x80815836
0, 516516, 1448, 0xaf457b3b
0, 519519, 1168, 0x65b9f96a
0, 522522, 1002, 0x053fafb9
0, 525525, 1101, 0x2d30c3d5
0, 528528, 5314, 0x87cee383
0, 531531, 1305, 0xb19035db
0, 534534, 1240, 0xdc6a0a65
0, 537537, 1067, 0x9c88ba67
0, 540540, 823, 0x2f736a43
0, 543543, 1183, 0x2ef9f3c9
0, 546546, 899, 0x3fcc8d11
0, 549549, 886, 0xccec8d49
0, 552552, 1190, 0x2d020fa1
0, 555555, 1017, 0x0776b627
0, 558558, 1202, 0xbdd808d5
0, 561561, 998, 0x64c7c246
0, 564564, 1200, 0x9d6e2289
0, 567567, 895, 0xa8a68d80
0, 570570, 748, 0xe61a49fb
0, 573573, 929, 0x30168b50
0, 576576, 5276, 0xceb2edf2
0, 579579, 1127, 0xab43ddc3
0, 582582, 1028, 0xaacfbff5
0, 585585, 914, 0xb63c8fb0
0, 588588, 1067, 0xbdacd1ed
0, 591591, 1109, 0x6792ddec
0, 594594, 1310, 0x71bc4da2
0, 597597, 1098, 0xc464de9b
0, 600600, 1018, 0x6833b875
0, 603603, 1210, 0x44faf34b
0, 606606, 1200, 0x9ee816f6
0, 609609, 1461, 0xc76b7d2b
0, 612612, 829, 0x006677e6
0, 615615, 1145, 0xc769fb13
0, 618618, 1292, 0xb63225f5
0, 621621, 1252, 0x0e2a2626
0, 624624, 5257, 0x3877eca1
0, 627627, 952, 0x7f708d25
0, 630630, 1125, 0x140cd81b
0, 633633, 1095, 0x3025dade
0, 636636, 1388, 0xd7494d4e
0, 639639, 1124, 0x0c48ee92
0, 642642, 1556, 0xa0749ee2
0, 645645, 1461, 0xe5fd7d7f
0, 648648, 903, 0x07a58303
0, 651651, 1049, 0x4b6cd03b
0, 654654, 1044, 0x5f47cb48
0, 657657, 1253, 0xba281c6a
0, 660660, 1618, 0xed7cd040
0, 663663, 981, 0x2926b6f4
0, 666666, 1560, 0xa0e1ab73
0, 669669, 1479, 0x41a77e88
0, 672672, 5222, 0xc2dbd182
0, 675675, 925, 0x967580dd
0, 678678, 1284, 0x5b7822e0
0, 681681, 1512, 0xe84da1e0
0, 684684, 1514, 0xc38bb09e
0, 687687, 1224, 0x8752228e
0, 690690, 1296, 0xcf053c03
0, 693693, 1117, 0x9a81e659
0, 696696, 1090, 0x003ed687
0, 699699, 1196, 0x3a510937
0, 702702, 1075, 0x05eec8d4
0, 705705, 1048, 0x3b19cb96
0, 708708, 944, 0xaad89770
0, 711711, 960, 0x94649e4c
0, 714714, 1079, 0x530ddaba
0, 717717, 1150, 0x0339e696
0, 720720, 5189, 0xb8dac0bf
0, 723723, 1129, 0x3b2cd64d
0, 726726, 962, 0xe9df9a07
0, 729729, 1113, 0xc6ccddb2
0, 732732, 1069, 0xf589d4a4
0, 735735, 889, 0x5f7b8762
0, 738738, 863, 0xe9c36be4
0, 741741, 1021, 0xcfb5a737
0, 744744, 1048, 0x203ac9ff
0, 747747, 1223, 0x3e30fe35
0, 750750, 814, 0x59c076fc
0, 753753, 1157, 0x0dcf0bd0
0, 756756, 1691, 0xdd030547
0, 759759, 1700, 0x7641fb7e
0, 762762, 1791, 0x57ac147b
0, 765765, 2008, 0x3d4483ca
0, 768768, 4579, 0x874aa75b
0, 771771, 1647, 0xeddef621
0, 774774, 1999, 0x61d4a23a
0, 777777, 1572, 0x1c3ae6e1
0, 780780, 1803, 0xb31c3a11
0, 783783, 1919, 0xccbf64e3
0, 786786, 1720, 0xa4d010e5
0, 789789, 1721, 0x87ee0c7b
0, 792792, 1626, 0x8211f3d0
0, 795795, 1675, 0xef8a0b3d
0, 798798, 1609, 0x8731ce06
0, 801801, 1691, 0xcf24038b
0, 804804, 1637, 0x21d8e1b2
0, 807807, 1546, 0xc597a700
0, 810810, 1518, 0xb944bc11
0, 813813, 1403, 0x999e59a8
0, 816816, 2467, 0xe69f2507
0, 819819, 531, 0x3c7cea7e
0, 822822, 555, 0xdf20fb22
0, 825825, 500, 0xebeee00d
0, 828828, 446, 0x664cc711
0, 831831, 521, 0xf223df4b
0, 834834, 559, 0x4dc60028
0, 837837, 593, 0xec440ba9
0, 840840, 557, 0xef0100b1
0, 843843, 602, 0x7b1cfd88
0, 846846, 566, 0x77700a1d
0, 849849, 523, 0x3df7eb64
0, 852852, 482, 0x5da1dba9
0, 855855, 541, 0x9c8ff3d7
0, 858858, 572, 0x3e1204b2
0, 861861, 549, 0x0921fe3d
0, 864864, 2429, 0xba4fe5a8
0, 867867, 495, 0xc35ade54
0, 870870, 453, 0xcc66c9dc
0, 873873, 421, 0x3aa7ce8f
0, 876876, 448, 0x56c6d3d7
0, 879879, 478, 0x4131d467
0, 882882, 497, 0xac3ce3ca
0, 885885, 470, 0x41b9d9d3
0, 888888, 454, 0x44c2d956
0, 891891, 460, 0x6629db01
0, 894894, 488, 0x6be2dd68
0, 897897, 512, 0xda4cf116
0, 900900, 550, 0x6e990da9
0, 903903, 561, 0x81180e5e
0, 906906, 689, 0xe58a5a9a
0, 909909, 548, 0xfa1417a9
0, 912912, 2832, 0x942495a5
0, 915915, 610, 0x6b201ab9
0, 918918, 1015, 0x5f36b3f9
0, 921921, 870, 0x14e48f0c
0, 924924, 716, 0xf4034b52
0, 927927, 763, 0xcbf4694e
0, 930930, 778, 0xb9396764
0, 933933, 831, 0x31999005
0, 936936, 877, 0xc95e977f
0, 939939, 836, 0xb56c7d61
0, 942942, 853, 0x2d5980cf
0, 945945, 861, 0x25629295
0, 948948, 897, 0x0ff78a5f
0, 951951, 1016, 0x4dd8cdfd
0, 954954, 1117, 0x763f06c4
0, 957957, 984, 0xcf7bc906
0, 960960, 2750, 0xd428962d
0, 963963, 995, 0x5cbdd6a4
0, 966966, 894, 0xc42b9e25
0, 969969, 1028, 0xdf8ad906
0, 972972, 1059, 0x4c49f0cc
0, 975975, 1122, 0x8880eed8
0, 978978, 1007, 0xa9b4c243
0, 981981, 1055, 0x6051dcd6
0, 984984, 1293, 0xc3b32fa5
0, 987987, 1101, 0xf986f9af
0, 990990, 1272, 0x13883127
0, 993993, 1037, 0xb97cebff
0, 996996, 980, 0x0931d807
0, 999999, 928, 0xbc3eb30b
0, 1003002, 1068, 0x62d9e8de
0, 1006005, 852, 0x9278a49a
0, 1009008, 2841, 0x3091d12d
0, 1012011, 931, 0x60f6c26e
0, 1015014, 949, 0x31b9c856
0, 1018017, 835, 0xfe018775
0, 1021020, 779, 0x85356cd7
0, 1024023, 748, 0x862756bf
0, 1027026, 768, 0x0b7d645c
0, 1030029, 786, 0x7c196f5b
0, 1033032, 716, 0x4e8252cc
0, 1036035, 671, 0x0b2d3023
0, 1039038, 708, 0x3b2b4f25
0, 1042041, 786, 0x523d670e
0, 1045044, 680, 0x329142ec
0, 1048047, 703, 0x841b456c
0, 1051050, 660, 0x5cf332f1
0, 1054053, 681, 0xcd7b3915
0, 1057056, 2445, 0x27660ecb
0, 1060059, 667, 0xf3d53d2a
0, 1063062, 652, 0xe2b037b0
0, 1066065, 695, 0x200248fc
0, 1069068, 659, 0x7f6434c5
0, 1072071, 682, 0x8d243afb
0, 1075074, 701, 0x16e6476f
0, 1078077, 636, 0x319a3236
0, 1081080, 679, 0x81fa41f9
0, 1084083, 740, 0xb32850af
0, 1087086, 694, 0xe3f832c2
0, 1090089, 681, 0x8174353f
0, 1093092, 757, 0xebbe5a1f
0, 1096095, 683, 0x9b46383c
0, 1099098, 816, 0xd41e6bdf
0, 1102101, 1058, 0x6170d2e6
0, 1105104, 2489, 0x58fb28e1
0, 1108107, 804, 0xb3037da8
0, 1111110, 1053, 0x81ffc0a8
0, 1114113, 868, 0xf73583cb
0, 1117116, 875, 0xfa5d85bd
0, 1120119, 723, 0x0714418d
0, 1123122, 670, 0xd04333a1
0, 1126125, 854, 0x370e730d
0, 1129128, 794, 0x3d8a5e3c
0, 1132131, 836, 0xebe26aa7
0, 1135134, 871, 0x1da58c5e
0, 1138137, 827, 0xda1e6ccb
0, 1141140, 805, 0x10ad6a44
0, 1144143, 831, 0x826f6fc9
0, 1147146, 832, 0xb2517364
0, 1150149, 887, 0x11bf8a3f
0, 1153152, 2718, 0x26a8a174
0, 1156155, 805, 0x4d0179f9
0, 1159158, 699, 0x176c4f45
0, 1162161, 758, 0xc1fc5b16
0, 1165164, 707, 0x161b4891
0, 1168167, 733, 0x99b554c0
0, 1171170, 671, 0xccee2f89
0, 1174173, 762, 0xd6416c9d
0, 1177176, 721, 0x2ad94f0c
0, 1180179, 727, 0x6280572e
0, 1183182, 856, 0x0a7b797e
0, 1186185, 843, 0xc64288aa
0, 1189188, 877, 0x6d1c945d
0, 1192191, 780, 0x4ba464e8
0, 1195194, 808, 0xb3087cca
0, 1198197, 870, 0x75809930
0, 1201200, 2919, 0x5a80f685
0, 1204203, 1027, 0xc98add3d
0, 1207206, 1003, 0x0d88bd54
0, 1210209, 1189, 0xb2f91ec7
0, 1213212, 1320, 0x5acc4db3
0, 1216215, 1381, 0xbd585feb
0, 1219218, 1378, 0xe1a656f0
0, 1222221, 1398, 0x88b57a5e
0, 1225224, 1449, 0x1c737698
0, 1228227, 1420, 0x6f0f80cd
0, 1231230, 1032, 0x2d16d643
0, 1234233, 1275, 0x38844729
0, 1237236, 1112, 0x300207ea
0, 1240239, 1105, 0xa2b700be
0, 1243242, 1283, 0x08d04bef
0, 1246245, 1056, 0xf795d994
0, 1249248, 3202, 0xebf07050
0, 1252251, 1034, 0x1099dbe5
0, 1255254, 922, 0x88be9edc
0, 1258257, 1050, 0xd3d7eb96
0, 1261260, 979, 0x8de6b302
0, 1264263, 1053, 0x5de2eca8
......@@ -235,3 +235,6 @@
0, 878377, 276480, 0x1700efbb
0, 882131, 276480, 0x9ebe6ba2
0, 885884, 276480, 0x8f316c66
0, 889638, 276480, 0x6348ecf5
0, 893392, 276480, 0x34b5b78a
0, 897146, 276480, 0xcbf66922
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment