Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

2014-12-16 Thread Christian Suloway
On 12/16/14, 3:23 AM, "Carl Eugen Hoyos"  wrote:

>Christian Suloway  row44.com> writes:
>
>> Close segment I/O context and append segment in
>> hls_write_trailer() only when segment I/O context
>> is allocated.
>
>Was this a regression since 25ccf5df?
>(And should be backported to 2.5?)

This does not appear specific to 25ccf5df and goes back to 2.2. Also, the
patch does not cover the mpegtsenc context accessing the null I/O context
from hls_write_trailer or hls_write_packet. I donĀ¹t know if this should be
covered in hlsenc or mpegtsenc.

Examples:

   177  void avio_write(AVIOContext *s, const unsigned char *buf, int size)
   178  {
-> 179  if (s->direct && !s->update_checksum) {
   180  avio_flush(s);
   181  writeout(s, buf, size);
   182  return;

* thread #1: tid = 0x1548b77, 0x0001002879f7
libavformat.56.dylib`avio_write(s=0x,
buf=0x7fff5fbff690, size=188) + 23 at aviobuf.c:179, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0xa0)
  * frame #0: 0x0001002879f7
libavformat.56.dylib`avio_write(s=0x,
buf=0x7fff5fbff690, size=188) + 23 at aviobuf.c:179
frame #1: 0x00010034542b
libavformat.56.dylib`mpegts_write_pes(s=0x000103032200,
st=0x0001021026f0, payload=0x00010303c0a8, payload_size=1256,
pts=1341180, dts=1341180, key=1) + 4347 at mpegtsenc.c:1187
frame #2: 0x000100344303
libavformat.56.dylib`mpegts_write_flush(s=0x000103032200) + 147 at
mpegtsenc.c:1379
frame #3: 0x000100344161
libavformat.56.dylib`mpegts_write_end(s=0x000103032200) + 33 at
mpegtsenc.c:1403
frame #4: 0x00010034d834
libavformat.56.dylib`av_write_trailer(s=0x000103032200) + 276 at
mux.c:949
frame #5: 0x0001002cdf1d
libavformat.56.dylib`hls_write_trailer(s=0x000103030400) + 45 at
hlsenc.c:476
frame #6: 0x00010034d834
libavformat.56.dylib`av_write_trailer(s=0x000103030400) + 276 at
mux.c:949
frame #7: 0x00010001bdb8 ffmpeg`transcode + 568 at ffmpeg.c:3799
frame #8: 0x00010001b3df ffmpeg`main(argc=11,
argv=0x7fff5fbffa28) + 447 at ffmpeg.c:3946

or

* thread #1: tid = 0x1564f17, 0x0001002879f7
libavformat.56.dylib`avio_write(s=0x,
buf=0x7fff5fbff3c0, size=188) + 23 at aviobuf.c:179, queue =
'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
address=0xa0)
  * frame #0: 0x0001002879f7
libavformat.56.dylib`avio_write(s=0x,
buf=0x7fff5fbff3c0, size=188) + 23 at aviobuf.c:179
frame #1: 0x00010034542b
libavformat.56.dylib`mpegts_write_pes(s=0x00010365f600,
st=0x00010210d6d0, payload=0x0001036694a8, payload_size=2619,
pts=396540, dts=396540, key=1) + 4347 at mpegtsenc.c:1187
frame #2: 0x0001003482c4
libavformat.56.dylib`mpegts_write_packet_internal(s=0x00010365f600,
pkt=0x7fff5fbff718) + 2068 at mpegtsenc.c:1341
frame #3: 0x000100344130
libavformat.56.dylib`mpegts_write_packet(s=0x00010365f600,
pkt=0x7fff5fbff718) + 64 at mpegtsenc.c:1393
frame #4: 0x00010034c6ef
libavformat.56.dylib`write_packet(s=0x00010365f600,
pkt=0x7fff5fbff718) + 975 at mux.c:598
frame #5: 0x00010034b7f5
libavformat.56.dylib`av_write_frame(s=0x00010365f600,
pkt=0x7fff5fbff718) + 421 at mux.c:654
frame #6: 0x00010034db6a
libavformat.56.dylib`ff_write_chained(dst=0x00010365f600,
dst_stream=1, pkt=0x7fff5fbff900, src=0x000103030400,
interleave=0) + 394 at mux.c:999
frame #7: 0x0001002cded1
libavformat.56.dylib`hls_write_packet(s=0x000103030400,
pkt=0x7fff5fbff900) + 929 at hlsenc.c:466
frame #8: 0x00010034c6ef
libavformat.56.dylib`write_packet(s=0x000103030400,
pkt=0x7fff5fbff900) + 975 at mux.c:598
frame #9: 0x00010034d77f
libavformat.56.dylib`av_write_trailer(s=0x000103030400) + 95 at
mux.c:934
frame #10: 0x00010001bdb8 ffmpeg`transcode + 568 at ffmpeg.c:3799
frame #11: 0x00010001b3df ffmpeg`main(argc=11,
argv=0x7fff5fbffa30) + 447 at ffmpeg.c:3946

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

2014-12-16 Thread Carl Eugen Hoyos
Christian Suloway  row44.com> writes:

> Close segment I/O context and append segment in 
> hls_write_trailer() only when segment I/O context 
> is allocated.

Was this a regression since 25ccf5df?
(And should be backported to 2.5?)

Carl Eugen

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

2014-12-15 Thread Michael Niedermayer
On Mon, Dec 15, 2014 at 06:10:46PM -0600, Christian Suloway wrote:
> Close segment I/O context and append segment in hls_write_trailer() only
> when segment I/O context is allocated.
> 
> Signed-off-by: Christian Suloway 
> ---
>  libavformat/hlsenc.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

2014-12-15 Thread Christian Suloway
Close segment I/O context and append segment in hls_write_trailer() only
when segment I/O context is allocated.

Signed-off-by: Christian Suloway 
---
 libavformat/hlsenc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 79f3a23..7645065 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -449,7 +449,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 av_opt_set(hls->avf->priv_data, "mpegts_flags", 
"resend_headers", 0);
 hls->number++;
 } else {
-avio_close(oc->pb);
+avio_closep(&oc->pb);
 
 ret = hls_start(s);
 }
@@ -474,10 +474,12 @@ static int hls_write_trailer(struct AVFormatContext *s)
 AVFormatContext *oc = hls->avf;
 
 av_write_trailer(oc);
-hls->size = avio_tell(hls->avf->pb) - hls->start_pos;
-avio_closep(&oc->pb);
+if (oc->pb) {
+hls->size = avio_tell(hls->avf->pb) - hls->start_pos;
+avio_closep(&oc->pb);
+hls_append_segment(hls, hls->duration, hls->start_pos, hls->size);
+}
 av_free(hls->basename);
-hls_append_segment(hls, hls->duration, hls->start_pos, hls->size);
 avformat_free_context(oc);
 hls->avf = NULL;
 hls_window(s, 1);
-- 
1.9.3 (Apple Git-50)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel