Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <libavformat/avformat.h>
- AVOutputFormat *get_yuv4mpeg_format() {
- AVOutputFormat *format = NULL;
- while((format = av_oformat_next(format))) {
- if(strcmp(format->name, "yuv4mpegpipe") == 0) {
- return format;
- }
- }
- return NULL;
- }
- int main(int argc, char *argv[]) {
- av_register_all();
- char *filename = "test.y4m";
- AVFormatContext *fc = avformat_alloc_context();
- fc->oformat = get_yuv4mpeg_format();
- if(!fc->oformat) {
- fprintf(stderr, "Could not find yuv4mpeg\n");
- exit(1);
- }
- snprintf(fc->filename, sizeof(fc->filename), "%s", filename);
- AVCodecContext *c;
- AVStream *st;
- if (fc->oformat->video_codec != CODEC_ID_NONE) {
- st = avformat_new_stream(fc, 0);
- c = st->codec;
- c->codec_id = fc->oformat->video_codec;
- c->codec_type = AVMEDIA_TYPE_VIDEO;
- c->pix_fmt = PIX_FMT_YUV420P;
- c->width = 352;
- c->height = 288;
- }
- if (!(fc->oformat->flags & AVFMT_NOFILE)) {
- if (avio_open(&fc->pb, filename, URL_WRONLY) < 0) {
- fprintf(stderr, "Could not open '%s'\n", filename);
- exit(1);
- }
- }
- fc->oformat->write_header(fc);
- return 0;
- }
- #if 0
- Backtrace:
- #0 0x00007ffff7b9c185 in ?? () from /usr/lib/x86_64-linux-gnu/libavformat.so.53
- #1 0x0000000000400ac6 in main (argc=1, argv=0x7fffffffe0e8) at test.c:48
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement