Go to the documentation of this file.
33 #include "libavutil/ffversion.h"
62 "File Format=MacCaption_MCC V1.0\n"
64 "///////////////////////////////////////////////////////////////////////////////////\n"
65 "// Computer Prompting and Captioning Company\n"
66 "// Ancillary Data Packet Transfer File\n"
68 "// Permission to generate this format is granted provided that\n"
69 "// 1. This ANC Transfer file format is used on an as-is basis and no warranty is given, and\n"
70 "// 2. This entire descriptive information text is included in a generated .mcc file.\n"
72 "// General file format:\n"
73 "// HH:MM:SS:FF(tab)[Hexadecimal ANC data in groups of 2 characters]\n"
74 "// Hexadecimal data starts with the Ancillary Data Packet DID (Data ID defined in S291M)\n"
75 "// and concludes with the Check Sum following the User Data Words.\n"
76 "// Each time code line must contain at most one complete ancillary data packet.\n"
77 "// To transfer additional ANC Data successive lines may contain identical time code.\n"
78 "// Time Code Rate=[24, 25, 30, 30DF, 50, 60]\n"
80 "// ANC data bytes may be represented by one ASCII character according to the following schema:\n"
82 "// H 2 x (FAh 00h 00h)\n"
83 "// I 3 x (FAh 00h 00h)\n"
84 "// J 4 x (FAh 00h 00h)\n"
85 "// K 5 x (FAh 00h 00h)\n"
86 "// L 6 x (FAh 00h 00h)\n"
87 "// M 7 x (FAh 00h 00h)\n"
88 "// N 8 x (FAh 00h 00h)\n"
89 "// O 9 x (FAh 00h 00h)\n"
95 "// U E1h 00h 00h 00h\n"
98 "///////////////////////////////////////////////////////////////////////////////////\n";
101 "File Format=MacCaption_MCC V2.0\n"
103 "///////////////////////////////////////////////////////////////////////////////////\n"
104 "// Computer Prompting and Captioning Company\n"
105 "// Ancillary Data Packet Transfer File\n"
107 "// Permission to generate this format is granted provided that\n"
108 "// 1. This ANC Transfer file format is used on an as-is basis and no warranty is given, and\n"
109 "// 2. This entire descriptive information text is included in a generated .mcc file.\n"
111 "// General file format:\n"
112 "// HH:MM:SS:FF(tab)[Hexadecimal ANC data in groups of 2 characters]\n"
113 "// Hexadecimal data starts with the Ancillary Data Packet DID (Data ID defined in S291M)\n"
114 "// and concludes with the Check Sum following the User Data Words.\n"
115 "// Each time code line must contain at most one complete ancillary data packet.\n"
116 "// To transfer additional ANC Data successive lines may contain identical time code.\n"
117 "// Time Code Rate=[24, 25, 30, 30DF, 50, 60, 60DF]\n"
119 "// ANC data bytes may be represented by one ASCII character according to the following schema:\n"
121 "// H 2 x (FAh 00h 00h)\n"
122 "// I 3 x (FAh 00h 00h)\n"
123 "// J 4 x (FAh 00h 00h)\n"
124 "// K 5 x (FAh 00h 00h)\n"
125 "// L 6 x (FAh 00h 00h)\n"
126 "// M 7 x (FAh 00h 00h)\n"
127 "// N 8 x (FAh 00h 00h)\n"
128 "// O 9 x (FAh 00h 00h)\n"
134 "// U E1h 00h 00h 00h\n"
137 "///////////////////////////////////////////////////////////////////////////////////\n";
149 { .
num = 24, .den = 1 },
150 { .num = 25, .den = 1 },
151 { .num = 30000, .den = 1001 },
152 { .num = 30, .den = 1 },
153 { .num = 50, .den = 1 },
154 { .num = 60000, .den = 1001 },
155 { .num = 60, .den = 1 },
170 av_log(avf,
AV_LOG_FATAL,
"MCC Version 1.0 doesn't support 60DF (59.94 fps drop-frame)");
179 if (!creation_program) {
181 creation_program =
"FFmpeg";
183 creation_program =
"FFmpeg version " FFMPEG_VERSION;
184 }
else if (strchr(creation_program,
'\n')) {
185 av_log(avf,
AV_LOG_FATAL,
"creation_program must not contain multiple lines of text");
197 if (!
localtime_r((time_t[1]){ timeval / 1000000 }, &tm))
200 static const char *
const months[12] = {
216 const char *month =
months[tm.tm_mon];
218 static const char *
const weekdays[7] = {
219 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
223 const char *weekday = weekdays[tm.tm_wday];
228 "Creation Program=%s\n"
229 "Creation Date=%s, %s %d, %d\n"
230 "Creation Time=%02d:%02d:%02d\n"
231 "Time Code Rate=%u%s\n\n",
249 static void mcc_bytes_to_hex(
char *dest,
const uint8_t *bytes,
size_t bytes_size,
int use_u_alias)
251 while (bytes_size != 0) {
255 for (
unsigned char code =
'G';
code <= (
unsigned char)
'O';
code++) {
258 if (bytes[0] != 0xFA || bytes[1] != 0 || bytes[2] != 0)
272 if (bytes_size >= 3 && bytes[1] == 0x80 && bytes[2] == 0x80) {
273 *dest++ = bytes[0] - 0xFB +
'P';
280 if (bytes_size >= 2 && bytes[1] == 0x69) {
288 if (bytes_size >= 2 && bytes[1] == 0x01) {
296 if (use_u_alias && bytes_size >= 4 && bytes[1] == 0 && bytes[2] == 0 && bytes[3] == 0) {
313 int v = (bytes[0] >>
shift) & 0xF;
317 *dest++ = v - 0xA +
'A';
341 for (
char *p = timecode_str; *p; p++) {
360 size_t mcc_anc_len = 0;
362 mcc_anc[mcc_anc_len++] = anc.
did;
367 mcc_anc[mcc_anc_len++] = anc.
checksum;
369 unsigned field_number;
382 "Unsupported SMPTE 436M ANC Wrapping Type %#x -- discarding ANC packet",
387 char field_and_line[32] =
"";
389 snprintf(field_and_line,
sizeof(field_and_line),
".%u,%u", field_number, (
unsigned)coded_anc.
line_number);
390 }
else if (field_number != 0) {
391 snprintf(field_and_line,
sizeof(field_and_line),
".%u", field_number);
396 if (field_and_line[0] !=
'\0') {
399 "MCC Version 1.0 doesn't support ANC packets where the field number (got %u) isn't 0 and "
400 "line number (got %u) isn't 9: discarding ANC packet",
411 char hex[1 + 2 *
sizeof(mcc_anc)];
413 avio_printf(avf->
pb,
"%s%s\t%s\n", timecode_str, field_and_line, hex);
432 int timecode_flags = 0;
449 av_log(avf,
AV_LOG_FATAL,
"time code rate not set, you need to use -override_time_code_rate to set it\n");
453 "time code rate not supported by mcc: %d/%d\n",
462 if (time_code_rate.
den == 1001 && time_code_rate.
num % 30000 == 0) {
479 snprintf(args,
sizeof(args),
"cdp_frame_rate=%d/%d", time_code_rate.
num, time_code_rate.
den);
486 "mcc muxer supports only codec %s or codec %s\n",
497 (void)std_compliance;
503 #define OFFSET(x) offsetof(MCCContext, x)
504 #define ENC AV_OPT_FLAG_ENCODING_PARAM
507 {
"override_time_code_rate",
"override the `Time Code Rate` value in the output",
OFFSET(override_time_code_rate),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, INT_MAX,
ENC },
508 {
"use_u_alias",
"use the U alias for E1h 00h 00h 00h, disabled by default because some .mcc files disagree on whether it has 2 or 3 zero bytes",
OFFSET(use_u_alias),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
ENC },
526 .p.extensions =
"mcc",
const FFOutputFormat ff_mcc_muxer
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_TIMECODE_STR_SIZE
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME
#define AVERROR_EOF
End of file.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
AVStream ** streams
A list of all streams in the file.
AVRational avg_frame_rate
Average framerate.
uint32_t flags
flags such as drop frame, +24 hours support, ...
uint16_t payload_sample_count
int av_smpte_436m_anc_iter_next(AVSmpte436mAncIterator *iter, AVSmpte436mCodedAnc *anc)
Get the next ANC packet from the iterator, advancing the iterator.
static const AVClass mcc_muxer_class
AVSmpte436mWrappingType wrapping_type
static void mcc_bytes_to_hex(char *dest, const uint8_t *bytes, size_t bytes_size, int use_u_alias)
convert the input bytes to hexadecimal with mcc's aliases
static const char mcc_header_v1[]
static const AVOption options[]
static const char mcc_header_v2[]
int start
timecode frame start (first base frame number)
static int query_codec(enum AVCodecID id, int std_compliance)
uint8_t payload[AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
int av_smpte_291m_anc_8bit_decode(AVSmpte291mAnc8bit *out, AVSmpte436mPayloadSampleCoding sample_coding, uint16_t sample_count, const uint8_t *payload, void *log_ctx)
Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit.
int flags
Flags modifying the (de)muxer behaviour.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int av_smpte_436m_anc_iter_init(AVSmpte436mAncIterator *iter, const uint8_t *buf, int buf_size)
Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
AVIOContext * pb
I/O context.
unsigned fps
frame per second; must be consistent with the rate field
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
AVRational rate
frame rate in rational form
AVCodecID
Identify the syntax and semantics of the bitstream.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
Init a timecode struct from the passed timecode components.
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2
static int shift(int a, int b)
static const char months[12][4]
static AVRational valid_time_code_rates[]
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int mcc_init(AVFormatContext *avf)
An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
An ANC packet with an 8-bit payload.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
static int mcc_write_header(AVFormatContext *avf)
static const char mcc_ffmpeg_uuid[]
generated with the bash command:
char * override_time_code_rate
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int mcc_write_packet(AVFormatContext *avf, AVPacket *pkt)
@ AV_CODEC_ID_SMPTE_436M_ANC
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
uint8_t payload[AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY]
the payload, has size payload_array_length.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
Writes a formatted string to the context.
Iterator over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data.
#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY
the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added)
@ AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME
static int mcc_query_codec(enum AVCodecID codec_id, int std_compliance)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
AVSmpte436mPayloadSampleCoding payload_sample_coding
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static void write_header(FFV1Context *f)
void * priv_data
Format private data.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg)
Load timecode string in buf.