FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 };
const char * s
Definition: avisynth_c.h:631
static int write_header(AVFormatContext *s)
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
void avpriv_set_pts_info(AVStream *s, 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:4427
static AVPacket pkt
Format I/O context.
Definition: avformat.h:1325
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1393
static const uint8_t header[24]
Definition: sdr2.c:67
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:204
#define av_log(a,...)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
const char * name
Definition: avformat.h:522
AVOutputFormat ff_mkvtimestamp_v2_muxer
AVIOContext * pb
I/O context.
Definition: avformat.h:1367
void * buf
Definition: avisynth_c.h:553
#define snprintf
Definition: snprintf.h:34
Main libavformat public API header.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1579
static int write_packet(AVFormatContext *s, AVPacket *pkt)
int stream_index
Definition: avcodec.h:1582
This structure stores compressed data.
Definition: avcodec.h:1557