| 860 | } |
| 861 | |
| 862 | static void dump_attachment(AVStream *st, const char *filename) |
| 863 | { |
| 864 | int ret; |
| 865 | AVIOContext *out = NULL; |
| 866 | AVDictionaryEntry *e; |
| 867 | |
| 868 | if (!st->codecpar->extradata_size) { |
| 869 | av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n", |
| 870 | nb_input_files - 1, st->index); |
| 871 | return; |
| 872 | } |
| 873 | if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) |
| 874 | filename = e->value; |
| 875 | if (!*filename) { |
| 876 | av_log(NULL, AV_LOG_FATAL, "No filename specified and no 'filename' tag" |
| 877 | "in stream #%d:%d.\n", nb_input_files - 1, st->index); |
| 878 | exit_program(1); |
| 879 | } |
| 880 | |
| 881 | assert_file_overwrite(filename); |
| 882 | |
| 883 | if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { |
| 884 | av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n", |
| 885 | filename); |
| 886 | exit_program(1); |
| 887 | } |
| 888 | |
| 889 | avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size); |
| 890 | avio_flush(out); |
| 891 | avio_close(out); |
| 892 | } |
| 893 | |
| 894 | static int open_input_file(OptionsContext *o, const char *filename) |
| 895 | { |
no test coverage detected