Skip to content

Commit

Permalink
Fixed broken faststart when postprocessing H.264 recordings to MP4 (f…
Browse files Browse the repository at this point in the history
…ixes #3037)
  • Loading branch information
lminiero committed Aug 30, 2022
1 parent 8f2daf8 commit adea15f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/postprocessing/pp-g722.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "../debug.h"

/* G.722 decoder */
static AVCodec *dec_codec; /* FFmpeg decoding codec */
static const AVCodec *dec_codec; /* FFmpeg decoding codec */
static AVCodecContext *dec_ctx; /* FFmpeg decoding context */

/* WAV header */
Expand Down
4 changes: 3 additions & 1 deletion src/postprocessing/pp-h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int janus_pp_h264_create(char *destination, char *metadata, gboolean faststart,
char filename[1024];
snprintf(filename, sizeof(filename), "%s", destination);
#ifdef USE_CODECPAR
AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
if(!codec) {
/* Error opening video codec */
JANUS_LOG(LOG_ERR, "Encoder not available\n");
Expand Down Expand Up @@ -122,6 +122,7 @@ int janus_pp_h264_create(char *destination, char *metadata, gboolean faststart,
JANUS_LOG(LOG_ERR, "Error opening file for output (%d, %s)\n", res, av_err2str(res));
return -1;
}
fctx->url = g_strdup(filename);
if(avformat_write_header(fctx, &options) < 0) {
JANUS_LOG(LOG_ERR, "Error writing header\n");
return -1;
Expand Down Expand Up @@ -553,6 +554,7 @@ void janus_pp_h264_close(void) {
}
if(fctx != NULL) {
avio_close(fctx->pb);
g_free(fctx->url);
av_free(fctx);
}
}
7 changes: 4 additions & 3 deletions src/postprocessing/pp-h265.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int janus_pp_h265_create(char *destination, char *metadata, gboolean faststart,
char filename[1024];
snprintf(filename, sizeof(filename), "%s", destination);
#ifdef USE_CODECPAR
AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H265);
const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H265);
if(!codec) {
/* Error opening video codec */
JANUS_LOG(LOG_ERR, "Encoder not available\n");
Expand Down Expand Up @@ -110,8 +110,7 @@ int janus_pp_h265_create(char *destination, char *metadata, gboolean faststart,
vStream->codec->width = max_width;
vStream->codec->height = max_height;
vStream->codec->pix_fmt = PIX_FMT_YUV420P;
//~ if (fctx->flags & AVFMT_GLOBALHEADER)
vStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
vStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
#endif
AVDictionary *options = NULL;
if(faststart)
Expand All @@ -122,6 +121,7 @@ int janus_pp_h265_create(char *destination, char *metadata, gboolean faststart,
JANUS_LOG(LOG_ERR, "Error opening file for output (%d, %s)\n", res, av_err2str(res));
return -1;
}
fctx->url = g_strdup(filename);
if(avformat_write_header(fctx, &options) < 0) {
JANUS_LOG(LOG_ERR, "Error writing header\n");
return -1;
Expand Down Expand Up @@ -643,6 +643,7 @@ void janus_pp_h265_close(void) {
}
if(fctx != NULL) {
avio_close(fctx->pb);
g_free(fctx->url);
av_free(fctx);
}
}

0 comments on commit adea15f

Please sign in to comment.