FFmpeg
mkvtimestamp_v2.c
Go to the documentation of this file.
1 /*
2  * extract pts as timecode v2, as defined by mkvtoolnix
3  * Copyright (c) 2009 David Conrad
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "avformat.h"
23 #include "internal.h"
24 
26 {
27  static const char *header = "# timecode format v2\n";
28  avio_write(s->pb, header, strlen(header));
29  avpriv_set_pts_info(s->streams[0], 64, 1, 1000);
30  return 0;
31 }
32 
34 {
35  char buf[256];
36  if (pkt->stream_index)
37  av_log(s, AV_LOG_WARNING, "More than one stream unsupported\n");
38  snprintf(buf, sizeof(buf), "%" PRId64 "\n", pkt->dts);
39  avio_write(s->pb, buf, strlen(buf));
40  return 0;
41 }
42 
44  .name = "mkvtimestamp_v2",
45  .long_name = NULL_IF_CONFIG_SMALL("extract pts as timecode v2 format, as defined by mkvtoolnix"),
46  .audio_codec = AV_CODEC_ID_NONE,
47  .video_codec = AV_CODEC_ID_RAWVIDEO,
48  .write_header = write_header,
49  .write_packet = write_packet,
50 };
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVOutputFormat::name
const char * name
Definition: avformat.h:504
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:63
write_packet
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mkvtimestamp_v2.c:33
pkt
AVPacket * pkt
Definition: movenc.c:59
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVFormatContext
Format I/O context.
Definition: avformat.h:1200
internal.h
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
header
static const uint8_t header[24]
Definition: sdr2.c:67
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:232
ff_mkvtimestamp_v2_muxer
const AVOutputFormat ff_mkvtimestamp_v2_muxer
Definition: mkvtimestamp_v2.c:43
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
AVOutputFormat
Definition: avformat.h:503
avformat.h
write_header
static int write_header(AVFormatContext *s)
Definition: mkvtimestamp_v2.c:25
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:1196
AVPacket::stream_index
int stream_index
Definition: packet.h:375
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
snprintf
#define snprintf
Definition: snprintf.h:34