| 1032 | } |
| 1033 | |
| 1034 | static int ffmpeg_put_frame(struct ffmpeg *ffmpeg, const struct timeval *tv1) |
| 1035 | { |
| 1036 | int retcd; |
| 1037 | |
| 1038 | ffmpeg->pkt = my_packet_alloc(ffmpeg->pkt); |
| 1039 | |
| 1040 | retcd = ffmpeg_set_pts(ffmpeg, tv1); |
| 1041 | if (retcd < 0) { |
| 1042 | //If there is an error, it has already been reported. |
| 1043 | ffmpeg_free_pkt(ffmpeg); |
| 1044 | return 0; |
| 1045 | } |
| 1046 | |
| 1047 | retcd = ffmpeg_encode_video(ffmpeg); |
| 1048 | if (retcd != 0) { |
| 1049 | if (retcd != -2) { |
| 1050 | MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Error while encoding picture")); |
| 1051 | } |
| 1052 | ffmpeg_free_pkt(ffmpeg); |
| 1053 | return retcd; |
| 1054 | } |
| 1055 | |
| 1056 | if (ffmpeg->tlapse == TIMELAPSE_APPEND) { |
| 1057 | retcd = ffmpeg_timelapse_append(ffmpeg, ffmpeg->pkt); |
| 1058 | } else { |
| 1059 | retcd = av_write_frame(ffmpeg->oc, ffmpeg->pkt); |
| 1060 | } |
| 1061 | ffmpeg_free_pkt(ffmpeg); |
| 1062 | |
| 1063 | if (retcd < 0) { |
| 1064 | MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Error while writing video frame")); |
| 1065 | return -1; |
| 1066 | } |
| 1067 | return retcd; |
| 1068 | |
| 1069 | } |
| 1070 | |
| 1071 | static void ffmpeg_passthru_reset(struct ffmpeg *ffmpeg) |
| 1072 | { |
no test coverage detected