Commit
source: http://pastebin.com/fGLBsdqb Many thanks / all credit to @kvaster [12:15] < kvaster> I've made a patch for newer libav locally. Will be able to submit today a bit later. [12:17] < kvaster> http://pastebin.com/fGLBsdqb [12:23] < kvaster> it was just small api changes inside libav, I'm worried only about audio stream buffer sizes. [12:24] < kvaster> Anyway this is working for me at least.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,47 +50,47 @@ libav_log_callback(void *ptr, int level, const char *fmt, va_list vl) | |
| /** | ||
| * Translate a component type to a libavcodec id | ||
| */ | ||
| enum CodecID | ||
| enum AVCodecID | ||
| streaming_component_type2codec_id(streaming_component_type_t type) | ||
| { | ||
| enum CodecID codec_id = CODEC_ID_NONE; | ||
| enum AVCodecID codec_id = AV_CODEC_ID_NONE; | ||
|
|
||
This comment has been minimized.
Sorry, something went wrong.
dreamcat4
Author
Owner
|
||
| switch(type) { | ||
| case SCT_H264: | ||
| codec_id = CODEC_ID_H264; | ||
| codec_id = AV_CODEC_ID_H264; | ||
| break; | ||
| case SCT_MPEG2VIDEO: | ||
| codec_id = CODEC_ID_MPEG2VIDEO; | ||
| codec_id = AV_CODEC_ID_MPEG2VIDEO; | ||
| break; | ||
| case SCT_VP8: | ||
| codec_id = CODEC_ID_VP8; | ||
| codec_id = AV_CODEC_ID_VP8; | ||
| break; | ||
| case SCT_AC3: | ||
| codec_id = CODEC_ID_AC3; | ||
| codec_id = AV_CODEC_ID_AC3; | ||
| break; | ||
| case SCT_EAC3: | ||
| codec_id = CODEC_ID_EAC3; | ||
| codec_id = AV_CODEC_ID_EAC3; | ||
| break; | ||
| case SCT_AAC: | ||
| codec_id = CODEC_ID_AAC; | ||
| codec_id = AV_CODEC_ID_AAC; | ||
| break; | ||
| case SCT_MPEG2AUDIO: | ||
| codec_id = CODEC_ID_MP2; | ||
| codec_id = AV_CODEC_ID_MP2; | ||
| break; | ||
| case SCT_VORBIS: | ||
| codec_id = CODEC_ID_VORBIS; | ||
| codec_id = AV_CODEC_ID_VORBIS; | ||
| break; | ||
| case SCT_DVBSUB: | ||
| codec_id = CODEC_ID_DVB_SUBTITLE; | ||
| codec_id = AV_CODEC_ID_DVB_SUBTITLE; | ||
| break; | ||
| case SCT_TEXTSUB: | ||
| codec_id = CODEC_ID_TEXT; | ||
| codec_id = AV_CODEC_ID_TEXT; | ||
| break; | ||
| case SCT_TELETEXT: | ||
| codec_id = CODEC_ID_DVB_TELETEXT; | ||
| codec_id = AV_CODEC_ID_DVB_TELETEXT; | ||
| break; | ||
| default: | ||
| codec_id = CODEC_ID_NONE; | ||
| codec_id = AV_CODEC_ID_NONE; | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -102,45 +102,45 @@ streaming_component_type2codec_id(streaming_component_type_t type) | |
| * Translate a libavcodec id to a component type | ||
| */ | ||
| streaming_component_type_t | ||
| codec_id2streaming_component_type(enum CodecID id) | ||
| codec_id2streaming_component_type(enum AVCodecID id) | ||
| { | ||
| streaming_component_type_t type = CODEC_ID_NONE; | ||
| streaming_component_type_t type = AV_CODEC_ID_NONE; | ||
|
|
||
| switch(id) { | ||
| case CODEC_ID_H264: | ||
| case AV_CODEC_ID_H264: | ||
| type = SCT_H264; | ||
| break; | ||
| case CODEC_ID_MPEG2VIDEO: | ||
| case AV_CODEC_ID_MPEG2VIDEO: | ||
| type = SCT_MPEG2VIDEO; | ||
| break; | ||
| case CODEC_ID_VP8: | ||
| case AV_CODEC_ID_VP8: | ||
| type = SCT_VP8; | ||
| break; | ||
| case CODEC_ID_AC3: | ||
| case AV_CODEC_ID_AC3: | ||
| type = SCT_AC3; | ||
| break; | ||
| case CODEC_ID_EAC3: | ||
| case AV_CODEC_ID_EAC3: | ||
| type = SCT_EAC3; | ||
| break; | ||
| case CODEC_ID_AAC: | ||
| case AV_CODEC_ID_AAC: | ||
| type = SCT_AAC; | ||
| break; | ||
| case CODEC_ID_MP2: | ||
| case AV_CODEC_ID_MP2: | ||
| type = SCT_MPEG2AUDIO; | ||
| break; | ||
| case CODEC_ID_VORBIS: | ||
| case AV_CODEC_ID_VORBIS: | ||
| type = SCT_VORBIS; | ||
| break; | ||
| case CODEC_ID_DVB_SUBTITLE: | ||
| case AV_CODEC_ID_DVB_SUBTITLE: | ||
| type = SCT_DVBSUB; | ||
| break; | ||
| case CODEC_ID_TEXT: | ||
| case AV_CODEC_ID_TEXT: | ||
| type = SCT_TEXTSUB; | ||
| break; | ||
| case CODEC_ID_DVB_TELETEXT: | ||
| case AV_CODEC_ID_DVB_TELETEXT: | ||
| type = SCT_TELETEXT; | ||
| break; | ||
| case CODEC_ID_NONE: | ||
| case AV_CODEC_ID_NONE: | ||
| type = SCT_NONE; | ||
| break; | ||
| default: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,9 +108,9 @@ typedef struct transcoder { | |
|
|
||
|
|
||
|
|
||
| #define WORKING_ENCODER(x) (x == CODEC_ID_H264 || x == CODEC_ID_MPEG2VIDEO || \ | ||
| x == CODEC_ID_VP8 || x == CODEC_ID_AAC || \ | ||
| x == CODEC_ID_MP2 || x == CODEC_ID_VORBIS) | ||
| #define WORKING_ENCODER(x) (x == AV_CODEC_ID_H264 || x == AV_CODEC_ID_MPEG2VIDEO || \ | ||
| x == AV_CODEC_ID_VP8 || x == AV_CODEC_ID_AAC || \ | ||
| x == AV_CODEC_ID_MP2 || x == AV_CODEC_ID_VORBIS) | ||
|
|
||
|
|
||
| uint32_t transcoding_enabled = 0; | ||
|
|
@@ -121,11 +121,11 @@ uint32_t transcoding_enabled = 0; | |
| static AVCodec * | ||
| transcoder_get_decoder(streaming_component_type_t ty) | ||
| { | ||
| enum CodecID codec_id; | ||
| enum AVCodecID codec_id; | ||
| AVCodec *codec; | ||
|
|
||
| codec_id = streaming_component_type2codec_id(ty); | ||
| if (codec_id == CODEC_ID_NONE) { | ||
| if (codec_id == AV_CODEC_ID_NONE) { | ||
| tvhlog(LOG_ERR, "transcode", "Unsupported input codec %s", | ||
| streaming_component_type2txt(ty)); | ||
| return NULL; | ||
|
|
@@ -150,11 +150,11 @@ transcoder_get_decoder(streaming_component_type_t ty) | |
| static AVCodec * | ||
| transcoder_get_encoder(streaming_component_type_t ty) | ||
| { | ||
| enum CodecID codec_id; | ||
| enum AVCodecID codec_id; | ||
| AVCodec *codec; | ||
|
|
||
| codec_id = streaming_component_type2codec_id(ty); | ||
| if (codec_id == CODEC_ID_NONE) { | ||
| if (codec_id == AV_CODEC_ID_NONE) { | ||
| tvhlog(LOG_ERR, "transcode", "Unable to find %s codec", | ||
| streaming_component_type2txt(ty)); | ||
| return NULL; | ||
|
|
@@ -214,7 +214,7 @@ transcoder_stream_subtitle(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| icodec = ss->sub_icodec; | ||
| //ocodec = ss->sub_ocodec; | ||
|
|
||
| if (ictx->codec_id == CODEC_ID_NONE) { | ||
| if (ictx->codec_id == AV_CODEC_ID_NONE) { | ||
| ictx->codec_id = icodec->id; | ||
|
|
||
| if (avcodec_open2(ictx, icodec, NULL) < 0) { | ||
|
|
@@ -272,7 +272,7 @@ transcoder_stream_audio(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| icodec = as->aud_icodec; | ||
| ocodec = as->aud_ocodec; | ||
|
|
||
| if (ictx->codec_id == CODEC_ID_NONE) { | ||
| if (ictx->codec_id == AV_CODEC_ID_NONE) { | ||
| ictx->codec_id = icodec->id; | ||
|
|
||
| if (avcodec_open2(ictx, icodec, NULL) < 0) { | ||
|
|
@@ -391,7 +391,7 @@ transcoder_stream_audio(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| break; | ||
| } | ||
|
|
||
| if (octx->codec_id == CODEC_ID_NONE) { | ||
| if (octx->codec_id == AV_CODEC_ID_NONE) { | ||
| octx->codec_id = ocodec->id; | ||
|
|
||
| if (avcodec_open2(octx, ocodec, NULL) < 0) { | ||
|
|
@@ -478,7 +478,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| buf = out = deint = NULL; | ||
| opts = NULL; | ||
|
|
||
| if (ictx->codec_id == CODEC_ID_NONE) { | ||
| if (ictx->codec_id == AV_CODEC_ID_NONE) { | ||
| ictx->codec_id = icodec->id; | ||
|
|
||
| if (avcodec_open2(ictx, icodec, NULL) < 0) { | ||
|
|
@@ -523,7 +523,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| vs->vid_enc_frame->sample_aspect_ratio.num = vs->vid_dec_frame->sample_aspect_ratio.num; | ||
| vs->vid_enc_frame->sample_aspect_ratio.den = vs->vid_dec_frame->sample_aspect_ratio.den; | ||
|
|
||
| if(octx->codec_id == CODEC_ID_NONE) { | ||
| if(octx->codec_id == AV_CODEC_ID_NONE) { | ||
| // Common settings | ||
| octx->width = vs->vid_width ? vs->vid_width : ictx->width; | ||
| octx->height = vs->vid_height ? vs->vid_height : ictx->height; | ||
|
|
@@ -534,7 +534,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt) | |
|
|
||
| switch (ts->ts_type) { | ||
| case SCT_MPEG2VIDEO: | ||
| octx->codec_id = CODEC_ID_MPEG2VIDEO; | ||
| octx->codec_id = AV_CODEC_ID_MPEG2VIDEO; | ||
| octx->pix_fmt = PIX_FMT_YUV420P; | ||
| octx->flags |= CODEC_FLAG_GLOBAL_HEADER; | ||
|
|
||
|
|
@@ -547,7 +547,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| break; | ||
|
|
||
| case SCT_VP8: | ||
| octx->codec_id = CODEC_ID_VP8; | ||
| octx->codec_id = AV_CODEC_ID_VP8; | ||
| octx->pix_fmt = PIX_FMT_YUV420P; | ||
|
|
||
| octx->qmin = 10; | ||
|
|
@@ -561,7 +561,7 @@ transcoder_stream_video(transcoder_stream_t *ts, th_pkt_t *pkt) | |
| break; | ||
|
|
||
| case SCT_H264: | ||
| octx->codec_id = CODEC_ID_H264; | ||
| octx->codec_id = AV_CODEC_ID_H264; | ||
| octx->pix_fmt = PIX_FMT_YUV420P; | ||
| octx->flags |= CODEC_FLAG_GLOBAL_HEADER; | ||
|
|
||
|
|
@@ -951,8 +951,8 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc) | |
| as->aud_ictx->thread_count = sysconf(_SC_NPROCESSORS_ONLN); | ||
| as->aud_octx->thread_count = sysconf(_SC_NPROCESSORS_ONLN); | ||
|
|
||
| as->aud_dec_size = AVCODEC_MAX_AUDIO_FRAME_SIZE*2; | ||
| as->aud_enc_size = AVCODEC_MAX_AUDIO_FRAME_SIZE*2; | ||
| as->aud_dec_size = 192000*2; | ||
| as->aud_enc_size = 192000*2; | ||
|
|
||
This comment has been minimized.
Sorry, something went wrong.
dreamcat4
Author
Owner
|
||
| as->aud_dec_sample = av_malloc(as->aud_dec_size + FF_INPUT_BUFFER_PADDING_SIZE); | ||
| as->aud_enc_sample = av_malloc(as->aud_enc_size + FF_INPUT_BUFFER_PADDING_SIZE); | ||
|
|
||
2 comments
on commit d18bc8d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop version now. It was 'draft' patch made locally in a fast way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kvaster yes - done in next commits of dreamcat4/libav branch. It compiles for me now with ffmpeg-2.2.4. So next I'm gonna do some basic testing myself, see if it will work or segfault (on HEAD).
This is wrong, because future versions newer than
56will also work too (until more / future API breakage). It should be changed into being a min version requirement, as older version even before 55 may continue to work. For example .53 or something.Ideally the version check should also really depend the
ffmpegorlibavsince the exact version number is different in each case. Some version drift since they branch away from each other. Else the min version can be the higher min one of{ffmpeg,libav}.Previously it accept any oldest version. Maybe that still true (I don't know). In which case (for feature-based configuration) the version check could instead be dropped entirely. Which probably wouldn't hurt anybody, since everybody these days use some 55 or newer versions.