MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / new_audio_stream

Function new_audio_stream

ffmpeg-single-cmd/src/main/cpp/ffmpeg_opt.c:1711–1782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1709}
1710
1711static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
1712{
1713 int n;
1714 AVStream *st;
1715 OutputStream *ost;
1716 AVCodecContext *audio_enc;
1717
1718 ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
1719 st = ost->st;
1720
1721 audio_enc = ost->enc_ctx;
1722 audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
1723
1724 MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
1725 MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
1726
1727 if (!ost->stream_copy) {
1728 char *sample_fmt = NULL;
1729
1730 MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st);
1731
1732 MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st);
1733 if (sample_fmt &&
1734 (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) == AV_SAMPLE_FMT_NONE) {
1735 av_log(NULL, AV_LOG_FATAL, "Invalid sample format '%s'\n", sample_fmt);
1736 exit_program(1);
1737 }
1738
1739 MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st);
1740
1741 MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st);
1742 ost->apad = av_strdup(ost->apad);
1743
1744 ost->avfilter = get_ost_filters(o, oc, ost);
1745 if (!ost->avfilter)
1746 exit_program(1);
1747
1748 /* check for channel mapping for this audio stream */
1749 for (n = 0; n < o->nb_audio_channel_maps; n++) {
1750 AudioChannelMap *map = &o->audio_channel_maps[n];
1751 if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&
1752 (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {
1753 InputStream *ist;
1754
1755 if (map->channel_idx == -1) {
1756 ist = NULL;
1757 } else if (ost->source_index < 0) {
1758 av_log(NULL, AV_LOG_FATAL, "Cannot determine input stream for channel mapping %d.%d\n",
1759 ost->file_index, ost->st->index);
1760 continue;
1761 } else {
1762 ist = input_streams[ost->source_index];
1763 }
1764
1765 if (!ist || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) {
1766 if (av_reallocp_array(&ost->audio_channels_map,
1767 ost->audio_channels_mapped + 1,
1768 sizeof(*ost->audio_channels_map)

Callers 2

init_output_filterFunction · 0.85
open_output_fileFunction · 0.85

Calls 4

new_output_streamFunction · 0.85
exit_programFunction · 0.85
get_ost_filtersFunction · 0.85
check_streamcopy_filtersFunction · 0.85

Tested by

no test coverage detected