| 755 | } |
| 756 | |
| 757 | int of_write_trailer(OutputFile *of) |
| 758 | { |
| 759 | Muxer *mux = mux_from_of(of); |
| 760 | AVFormatContext *fc = mux->fc; |
| 761 | int ret, mux_result = 0; |
| 762 | |
| 763 | if (!mux->header_written) { |
| 764 | av_log(mux, AV_LOG_ERROR, |
| 765 | "Nothing was written into output file, because " |
| 766 | "at least one of its streams received no packets.\n"); |
| 767 | return AVERROR(EINVAL); |
| 768 | } |
| 769 | |
| 770 | ret = av_write_trailer(fc); |
| 771 | if (ret < 0) { |
| 772 | av_log(mux, AV_LOG_ERROR, "Error writing trailer: %s\n", av_err2str(ret)); |
| 773 | mux_result = err_merge(mux_result, ret); |
| 774 | } |
| 775 | |
| 776 | mux->last_filesize = filesize(fc->pb); |
| 777 | |
| 778 | if (!(fc->oformat->flags & AVFMT_NOFILE)) { |
| 779 | ret = avio_closep(&fc->pb); |
| 780 | if (ret < 0) { |
| 781 | av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", av_err2str(ret)); |
| 782 | mux_result = err_merge(mux_result, ret); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | mux_final_stats(mux); |
| 787 | |
| 788 | // check whether anything was actually written |
| 789 | ret = check_written(of); |
| 790 | mux_result = err_merge(mux_result, ret); |
| 791 | |
| 792 | return mux_result; |
| 793 | } |
| 794 | |
| 795 | static void enc_stats_uninit(EncStats *es) |
| 796 | { |
no test coverage detected