Closed jalonsoa closed 9 years ago
hi @jalonsoa, yes we can do it. If I'm not being betrayed by my memory, all you need to do is change the oformat on output_format_context:
diff --git ngx_http_aac_module.c ngx_http_aac_module.c
index dbff3a7..776de23 100644
--- ngx_http_aac_module.c
+++ ngx_http_aac_module.c
@@ -173,7 +173,7 @@ static int ngx_http_aac_extract_audio(ngx_pool_t *pool, ngx_log_t *log, ngx_str
io_context = avio_alloc_context(exchange_area, buffer_size, 1, (void *)destination, NULL, write_packet, NULL);
output_format_context->pb = io_context;
- output_format_context->oformat = av_guess_format("adts", NULL, NULL);
+ output_format_context->oformat = input_format_context->oformat;
avcodec_copy_context(output_audio_stream->codec, input_audio_stream->codec);
avformat_write_header(output_format_context, NULL);
Don't forget to change the mimetype to video/MP2T
and the lua script that generates the audio only m3u8 playlist.
Hi Flavio ! thanks for your patch .. but .. don't work .. ;-( ... the nginx crash .. I'm investigating about it, when have any info I will share.
thanks
j
On Tue, Jan 13, 2015 at 1:16 AM, Flávio Ribeiro notifications@github.com wrote:
hi @jalonsoa https://github.com/jalonsoa, yes we can do it. If I'm not being betrayed by my memory, all you need to do is change the oformat http://ffmpeg.org/doxygen/trunk/structAVFormatContext.html#a20d80ac07e38ff5c268d15aaf2798b98 on output_format_context:
diff --git ngx_http_aac_module.c ngx_http_aac_module.c index dbff3a7..776de23 100644--- ngx_http_aac_module.c+++ ngx_http_aac_module.c@@ -173,7 +173,7 @@ static int ngx_http_aac_extract_audio(ngx_pool_t pool, ngx_log_t log, ngx_str
io_context = avio_alloc_context(exchange_area, buffer_size, 1, (void *)destination, NULL, write_packet, NULL); output_format_context->pb = io_context;- output_format_context->oformat = av_guess_format("adts", NULL, NULL);+ output_format_context->oformat = input_format_context->oformat; avcodec_copy_context(output_audio_stream->codec, input_audio_stream->codec); avformat_write_header(output_format_context, NULL);
Don't forget to change the mimetype to video/MP2T and the lua script that generates the audio only m3u8.
— Reply to this email directly or view it on GitHub https://github.com/flavioribeiro/nginx-audio-track-for-hls-module/issues/23#issuecomment-69673316 .
Hi Flavio !
this is the gdb stack when the nginx crash.
/usr/lib/x86_64-linux-gnu/libavformat.so.53
(destination=0x24568d0, log=0x2451d40, pool=0x245fc50, source=...) at /mnt/filer/personales/root/sysadm/sources/ubuntu-12.04/nginx/nginx-1.7.4/debian/modules/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:180
/mnt/filer/personales/root/sysadm/sources/ubuntu-12.04/nginx/nginx-1.7.4/debian/modules/nginx-audio-track-for-hls-module/ngx_http_aac_module.c:27
ph=0x248a180) at src/http/ngx_http_core_module.c:1407
src/http/ngx_http_core_module.c:888
src/http/ngx_http_request.c:1902
src/http/ngx_http_request.c:1012
timer=
at src/event/ngx_event.c:248
data=
And ... one point. In line 143 ... the "goto exit" line should go after the log, right?
--- ngx_http_aac_module.c 2015-01-13 16:49:29.835110000 +0100
+++ ngx_http_aac_module.c.orig 2015-01-13 16:49:24.090053000 +0100
@@ -140,8 +140,8 @@
}
if (avformat_find_stream_info(input_format_context, NULL) < 0) {
- ngx_log_error(NGX_LOG_ERR, log, 0, "aac module: could not find stream info");
goto exit;
+ ngx_log_error(NGX_LOG_ERR, log, 0, "aac module: could not find stream info");
}
audio_stream_id = av_find_best_stream(input_format_context, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0);
Sorry, the patch is opposite ... the correct patch:
--- ngx_http_aac_module.c.orig 2015-01-13 16:49:24.090053000 +0100
+++ ngx_http_aac_module.c 2015-01-13 16:49:29.835110000 +0100
@@ -140,8 +140,8 @@
}
if (avformat_find_stream_info(input_format_context, NULL) < 0) {
- goto exit;
ngx_log_error(NGX_LOG_ERR, log, 0, "aac module: could not find stream info");
+ goto exit;
}
audio_stream_id = av_find_best_stream(input_format_context, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0);
hey @jalonsoa, yeah your patch makes sense. Can you send a pull request?
Regarding my patch, I'll try to figure out what's going on, but can you try this approach below first?
diff --git ngx_http_aac_module.c ngx_http_aac_module.c
index dbff3a7..fa87a00 100644
--- ngx_http_aac_module.c
+++ ngx_http_aac_module.c
@@ -123,6 +123,8 @@ static int ngx_http_aac_extract_audio(ngx_pool_t *pool, ngx_log_t *log, ngx_str
AVFormatContext *input_format_context = NULL;
AVFormatContext *output_format_context = NULL;
+ AVOutputFormat *fmt;
AVStream *input_audio_stream;
AVStream *output_audio_stream;
AVPacket packet, new_packet;
@@ -173,7 +175,8 @@ static int ngx_http_aac_extract_audio(ngx_pool_t *pool, ngx_log_t *log, ngx_str
io_context = avio_alloc_context(exchange_area, buffer_size, 1, (void *)destination, NULL, write_packet, NULL);
output_format_context->pb = io_context;
- output_format_context->oformat = av_guess_format("adts", NULL, NULL);
+ fmt = av_guess_format("mpegts", NULL, NULL);
+ output_format_context->oformat = fmt;
avcodec_copy_context(output_audio_stream->codec, input_audio_stream->codec);
avformat_write_header(output_format_context, NULL);
Hi Flavio, I'm trying with this at this moment. I'm preparing a new module option to select the ouput format. Is ok ?
thanks
great, tell me if the last diff works for you :beers:
Hi Flavio, your patch work fine, but I have a new problem. If we want that the user can select the output format (new parameter to select it), we can't suppose that the url get .aac extension to build the source path.
For example, if we select mpegts output format, we expect that the fragments in the new m3u8 audio list be ts files ... so you can't remove aac extension and paste ts to build the source path (ngx_http_aac_module.c, build_source_path function - line 209)
We have many ways
a .- remove the extension in nginx (rewrite), and the module paste the ts extension to get the source b .- remove the extension in the module (from the last dot to the end of the string) and paste the ts extension to get the source. c .- the module don't cut and paste any extension. Nginx rewrite the url to convert to source path, so the module open the file directly.
what do you think about ?
j
hi @jalonsoa, I think that the best way to deal with it is by searching for the extension and replacing to .ts in order to get the real file (letter b).
closed by 225babfaaba46fff21bfae718d4dc71f4eadf77d
Hi, android >4.4.3 don't support m3u8 live with aac files. Only support mpegts as fragments on m3u8 playlist.
We can generate an ts file with only the aac stream inside ?
thanks j