| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Libavformat API example: Output a media file in any supported | 2 * Libavformat API example: Output a media file in any supported |
| 3 * libavformat format. The default codecs are used. | 3 * libavformat format. The default codecs are used. |
| 4 * | 4 * |
| 5 * Copyright (c) 2003 Fabrice Bellard | 5 * Copyright (c) 2003 Fabrice Bellard |
| 6 * | 6 * |
| 7 * Permission is hereby granted, free of charge, to any person obtaining a copy | 7 * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 * of this software and associated documentation files (the "Software"), to deal | 8 * of this software and associated documentation files (the "Software"), to deal |
| 9 * in the Software without restriction, including without limitation the rights | 9 * in the Software without restriction, including without limitation the rights |
| 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (!st) { | 61 if (!st) { |
| 62 fprintf(stderr, "Could not alloc stream\n"); | 62 fprintf(stderr, "Could not alloc stream\n"); |
| 63 exit(1); | 63 exit(1); |
| 64 } | 64 } |
| 65 | 65 |
| 66 c = st->codec; | 66 c = st->codec; |
| 67 c->codec_id = codec_id; | 67 c->codec_id = codec_id; |
| 68 c->codec_type = AVMEDIA_TYPE_AUDIO; | 68 c->codec_type = AVMEDIA_TYPE_AUDIO; |
| 69 | 69 |
| 70 /* put sample parameters */ | 70 /* put sample parameters */ |
| 71 c->sample_fmt = SAMPLE_FMT_S16; |
| 71 c->bit_rate = 64000; | 72 c->bit_rate = 64000; |
| 72 c->sample_rate = 44100; | 73 c->sample_rate = 44100; |
| 73 c->channels = 2; | 74 c->channels = 2; |
| 74 | 75 |
| 75 // some formats want stream headers to be separate | 76 // some formats want stream headers to be separate |
| 76 if(oc->oformat->flags & AVFMT_GLOBALHEADER) | 77 if(oc->oformat->flags & AVFMT_GLOBALHEADER) |
| 77 c->flags |= CODEC_FLAG_GLOBAL_HEADER; | 78 c->flags |= CODEC_FLAG_GLOBAL_HEADER; |
| 78 | 79 |
| 79 return st; | 80 return st; |
| 80 } | 81 } |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 if (!(fmt->flags & AVFMT_NOFILE)) { | 546 if (!(fmt->flags & AVFMT_NOFILE)) { |
| 546 /* close the output file */ | 547 /* close the output file */ |
| 547 url_fclose(oc->pb); | 548 url_fclose(oc->pb); |
| 548 } | 549 } |
| 549 | 550 |
| 550 /* free the stream */ | 551 /* free the stream */ |
| 551 av_free(oc); | 552 av_free(oc); |
| 552 | 553 |
| 553 return 0; | 554 return 0; |
| 554 } | 555 } |
| OLD | NEW |