[FFmpeg-devel] Contribute to ffmpeg

2018-08-01 Thread Shardul Negi
Sir,
I am preparing for Google Summer of Codes. I am willing to contribute to
your Organization. I have chosen my project. It is "Cineform Improvements".
So please guide me what should I do next.
Thanks.

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


[FFmpeg-devel] mpeg2 input, tee output (udp+hls) dying at exactly 86400seconds

2018-08-01 Thread Ibrahim Tachijian
Hey,

I have a full 250mb report but but I will only include the most important
lines.
I have a live-transcode of an incoming mpeg2-ts that I output to tee, udp
and hls.
It is currently dying at exactly 86400 seconds.

You can find the first few lines here below:

ffmpeg started on 2018-07-31 at 13:15:30
Report written to "ffmpeg-20180731-131530.log"
Command line:
f_alias -analyzeduration 100 -i "
http://X.X.X.X4048/udp/239.193.9.189:3301?auth=c15b5077988d73c1a688272a051af1b3&e=1532959888&s=7236&t=0&p=&ident=123123F987789";
-map 0:0 -map 0:1 -filter:v "yadif,scale=-2:'min(576,ih)'" -c:v libx264
-preset superfast -g 50 -keyint_min 100 -sc_threshold 0 -b:v 900k -maxrate
900k -bufsize 2000k -c:a libfdk_$
ffmpeg version N-91403-gd24c9e5 Copyright (c) 2000-2018 the FFmpeg
developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/home/netsat/netsat_packages/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/netsat/netsat_packages/ffmpeg_build/include
--extra-ldflags=-L/home/netsat/netsat_packages/ffmpeg_build/lib
--extra-libs='-lpthread -lm' --bindir=/home/netsat/netsat_packages/bin
--enable-gpl --enable-libass --enable-libfdk-aac $
  libavutil  56. 18.102 / 56. 18.102
  libavcodec 58. 20.104 / 58. 20.104
  libavformat58. 17.101 / 58. 17.101
  libavdevice58.  4.101 / 58.  4.101
  libavfilter 7. 25.100 /  7. 25.100
  libswscale  5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc55.  2.100 / 55.  2.100




And here below you can find the last lines: (I have bolded the lines that I
think matters)

[libx264 @ 0x55d2032cd400] frame=2160210 QP=26.62 NAL=0 Slice:B Poc:16
I:51   P:589  SKIP:980  size=2671 bytes
[libx264 @ 0x55d2032cd400] frame=2160211 QP=26.79 NAL=0 Slice:B Poc:20
I:49   P:604  SKIP:967  size=2750 bytes
[libx264 @ 0x55d2032cd400] frame=2160212 QP=26.03 NAL=2 Slice:P Poc:30
I:615  P:716  SKIP:289  size=8557 bytes
*[out_0_0 @ 0x55d20328d6c0] EOF on sink link out_0_0:default.*
*[out_0_1 @ 0x55d203318b00] EOF on sink link out_0_1:default.*
*No more output streams to write to, finishing.*
[libx264 @ 0x55d2032cd400] frame=2160213 QP=26.67 NAL=2 Slice:B Poc:26
I:85   P:904  SKIP:631  size=4843 bytes
[libx264 @ 0x55d2032cd400] frame=2160214 QP=26.78 NAL=0 Slice:B Poc:24
I:34   P:581  SKIP:1005 size=2560 bytes
[libx264 @ 0x55d2032cd400] frame=2160215 QP=27.08 NAL=0 Slice:B Poc:28
I:36   P:643  SKIP:941  size=2603 bytes
[libx264 @ 0x55d2032cd400] frame=2160216 QP=26.13 NAL=2 Slice:P Poc:38
I:628  P:734  SKIP:258  size=8431 bytes
[libx264 @ 0x55d2032cd400] frame=2160217 QP=26.50 NAL=2 Slice:B Poc:34
I:103  P:840  SKIP:677  size=4457 bytes
[libx264 @ 0x55d2032cd400] frame=2160218 QP=27.03 NAL=0 Slice:B Poc:32
I:72   P:707  SKIP:841  size=3022 bytes
[libx264 @ 0x55d2032cd400] frame=2160219 QP=26.70 NAL=0 Slice:B Poc:36
I:39   P:707  SKIP:874  size=2772 bytes
[libx264 @ 0x55d2032cd400] frame=2160220 QP=26.06 NAL=2 Slice:P Poc:46
I:661  P:692  SKIP:267  size=8714 bytes
[libx264 @ 0x55d2032cd400] frame=2160221 QP=26.48 NAL=2 Slice:B Poc:42
I:113  P:906  SKIP:601  size=4768 bytes
[libx264 @ 0x55d2032cd400] frame=2160222 QP=27.02 NAL=0 Slice:B Poc:40
I:41   P:721  SKIP:858  size=2620 bytes
[libx264 @ 0x55d2032cd400] frame=2160223 QP=26.91 NAL=0 Slice:B Poc:44
I:46   P:790  SKIP:784  size=3131 bytes
[libx264 @ 0x55d2032cd400] frame=2160224 QP=26.47 NAL=2 Slice:P Poc:54
I:657  P:705  SKIP:258  size=9143 bytes
[libx264 @ 0x55d2032cd400] frame=2160225 QP=26.49 NAL=2 Slice:B Poc:50
I:137  P:960  SKIP:523  size=5323 bytes
[libx264 @ 0x55d2032cd400] frame=2160226 QP=26.67 NAL=0 Slice:B Poc:48
I:45   P:796  SKIP:779  size=3266 bytes
[libx264 @ 0x55d2032cd400] frame=2160227 QP=27.16 NAL=0 Slice:B Poc:52
I:52   P:788  SKIP:780  size=3405 bytes
[libx264 @ 0x55d2032cd400] frame=2160228 QP=26.32 NAL=2 Slice:P Poc:62
I:676  P:705  SKIP:239  size=9587 bytes
[libx264 @ 0x55d2032cd400] frame=2160229 QP=26.76 NAL=2 Slice:B Poc:58
I:88   P:998  SKIP:534  size=5147 bytes
[libx264 @ 0x55d2032cd400] frame=2160230 QP=27.38 NAL=0 Slice:B Poc:56
I:56   P:901  SKIP:663  size=3947 bytes
[libx264 @ 0x55d2032cd400] frame=2160231 QP=27.31 NAL=0 Slice:B Poc:60
I:144  P:703  SKIP:773  size=4801 bytes
[libfdk_aac @ 0x55d2032c8140] Trying to remove 768 more samples than there
are in the queue
[AVIOContext @ 0x55d2032804c0] Statistics: 0 seeks, 11375675 writeouts
[AVIOContext @ 0x55d2032b6500] Statistics: 0 seeks, 1 writeouts
[hls muxer @ 0x55d2036db340] deleting old segment playlist1533086124.ts
[hls @ 0x55d2036dac80] Opening
'/tmp/deleteme/7236_0_45c7ad8444/playlist.m3u8.tmp' for writing
[file @ 0x55d2032b6900] Setting default whitelist 'file,crypto'
EXT-X-MEDIA-SEQUENCE:1533086126
[AVIOContext @ 0x55d2032806c0] Statistics: 0 seeks, 1 writeouts
frame=2160232 fps= 25 q=-1.0 Lsize=N/A time=24:00:09.20 bitrate=N/A dup=366
drop=0 speed=   1x
video:9384589kB audio:674623kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown
Inpu

[FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak
Hi all,

Here's my first proposed patch for fixing https://trac.ffmpeg.org/ticket/7281 
.

I'm going to send a second patch that will apply the same set of fixes to 
dashenc.c.

Thanks,

Ronak

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


Re: [FFmpeg-devel] Contribute to ffmpeg

2018-08-01 Thread Thilo Borgmann
Hi,

Am 01.08.18 um 15:53 schrieb Shardul Negi:
> Sir,
> I am preparing for Google Summer of Codes. I am willing to contribute to
> your Organization. I have chosen my project. It is "Cineform Improvements".
> So please guide me what should I do next.
> Thanks.

you are always welcome to contribute, if it is in the context of GSoC (or 
similar) or not!

Concerning GSoC, you're about 6 months early, before you can apply for a 
possible next GSoC in 2019.
(There are no guarantees that there will be a next GSoC or that FFmpeg will 
again be part of it, though)

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Carl Eugen Hoyos
2018-08-01 18:39 GMT+02:00, Ronak :

> Here's my first proposed patch for fixing
> https://trac.ffmpeg.org/ticket/7281

No patch visible here:
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/232785.html

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak
I'm re-sending the attachment. Not sure why it's not showing up.



0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch
Description: Binary data


> On Aug 1, 2018, at 1:56 PM, Carl Eugen Hoyos  wrote:
> 
> 2018-08-01 18:39 GMT+02:00, Ronak :
> 
>> Here's my first proposed patch for fixing
>> https://trac.ffmpeg.org/ticket/7281
> 
> No patch visible here:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2018-August/232785.html
> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Carl Eugen Hoyos
2018-08-01 20:02 GMT+02:00, Ronak :
> I'm re-sending the attachment.

Your patch contains tabs that cannot be committed to FFmpeg's repository -
please remove them.

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


Re: [FFmpeg-devel] [PATCH] qt-faststart: Add mode for probing faststart-ness

2018-08-01 Thread Tomas Härdin
tis 2018-07-31 klockan 14:46 -0700 skrev Baptiste Coudurier:
> Hey Tomas,
> 
> > On Sat, Jul 28, 2018 at 1:56 AM, Tomas Härdin  wrote:
> 
> > lör 2018-07-28 klockan 10:31 +0530 skrev Gyan Doshi:
> > > 
> > > On 28-07-2018 03:33 AM, Tomas Härdin wrote:
> > > > 
> > > > woot! I didn't know the mov demuxer dumped such things. It is quite
> > > > slow however, since it will scan through every leaf atom in the
> > > > file.
> > > > For example, running time ffmpeg -i input.mov -v 56 2>&1 | wc on a
> > > > 1.5
> > > > GiB MP4 on an SSD takes:
> > > 
> > > Use the subfile protocol to forgo parsing the whole file, e.g.
> > > 
> > >  ffmpeg -i subfile,,start,0,end,1,,:in.mp4 -v 56 2>&1 | grep
> > > -e
> > > "type:'moov'" -e "type:'mdat'" | head -1 | grep moov
> > > 
> > > This assumes that at least one of the two targeted boxes moov/mdat
> > > start
> > > within the first 1 bytes.
> > 
> > Neat. This is similar to the first suggestion I had to the peertube
> > devs, dd:ing off the first MiB or so then probing that. We'll see what
> > they say, and what Baptiste thinks I guess
> 
> 
> Interesting, I can see the interest of checking this. Could ffprobe do that
> somehow ?
> Would be an interesting information to report.
> Not sure it belongs in qt-faststart, and not sure checking fragmented files
> would be in
> the scope of qt-faststart. What do you think ?

My main concern with adding this in ffprobe is the amount of plumbing
needed. Perhaps the demuxer could set a metadata field?

I judged separating fragmented from non-fragmented streamable files as
valuable for this patch, partly because I had to do something to make
qt-faststart not complain about fragmented files. But that also allows
it to abort early. Not that parsing top-level atoms only is
particularly hard work.. Do we know of any players that *don't* support
fragmented MP4?

For now PeerTube seem to be going with something similar to Gyan's
suggestion, so they don't have to keep more C code than necessary
around: https://gist.github.com/rigelk/95e41dacb66df652039e59350a9eb7b4

I think we might want users that actually need this before pushing.
Else it's just technical debt. Good exercise for me to get a bit better
grasp on FATE however

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


[FFmpeg-devel] lavf/dashdec: Fix memleak

2018-08-01 Thread jacek jogo
Hi.
This fix memleak in dashdec.
==5033== HEAP SUMMARY:
==5033== in use at exit: 86,144 bytes in 2,848 blocks
==5033==   total heap usage: 10,089 allocs, 7,241 frees, 38,902,613 bytes
allocated
==5033==
==5033== Searching for pointers to 2,848 not-freed blocks
==5033== Checked 9,139,304 bytes
==5033==
==5033== 528 bytes in 8 blocks are definitely lost in loss record 187 of 222
==5033==at 0x4C2CB5F: malloc (vg_replace_malloc.c:299)
==5033==by 0x6868D38: xmlBufCreateSize (in /usr/lib64/libxml2.so.2.9.8)
==5033==by 0x67F1029: xmlNodeGetContent (in /usr/lib64/libxml2.so.2.9.8)
==5033==by 0x41EA43: resolve_content_path (dashdec.c:757)
==5033==by 0x41EA43: parse_manifest_representation (dashdec.c:873)
==5033==by 0x41EA43: parse_manifest_adaptationset (dashdec.c:1095)
==5033==by 0x41EA43: parse_manifest (dashdec.c:1272)
==5033==by 0x420E2A: dash_read_header (dashdec.c:1927)
==5033==by 0x53CF77: avformat_open_input (utils.c:631)
==5033==by 0x2647F4: open_input_file (ffmpeg_opt.c:1069)
==5033==by 0x266121: open_files (ffmpeg_opt.c:3219)
==5033==by 0x266121: ffmpeg_parse_options (ffmpeg_opt.c:3259)
==5033==by 0x25E991: main (ffmpeg.c:4859)
==5033==
==5033== LEAK SUMMARY:
==5033==definitely lost: 528 bytes in 8 blocks
==5033==indirectly lost: 0 bytes in 0 blocks
==5033==  possibly lost: 0 bytes in 0 blocks
==5033==still reachable: 85,616 bytes in 2,840 blocks
==5033== suppressed: 0 bytes in 0 blocks
==5033== Reachable blocks (those to which a pointer was found) are not
shown.
==5033== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5033==
==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Can be reproduced with:  valgrind  --leak-check=full  -v ffmpeg -i
http://yt-dash-mse-test.commondatastorage.googleapis.com/media/motion-20120802-manifest.mpd
From 1fa3d049a17dd4d135bb79423e0551ee7ee7f25d Mon Sep 17 00:00:00 2001
From: Jacek Jendrzej 
Date: Wed, 1 Aug 2018 11:53:41 +0200
Subject: [PATCH] lavf/dashdec: Fix memleak

---
 libavformat/dashdec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 89f3ac2759..010a2e8387 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -754,9 +754,12 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur
 if (!(node = baseurl_nodes[rootId])) {
 continue;
 }
-if (ishttp(xmlNodeGetContent(node))) {
+text = xmlNodeGetContent(node);
+if (ishttp(text)) {
+xmlFree(text);
 break;
 }
+xmlFree(text);
 }
 
 node = baseurl_nodes[rootId];
-- 
2.18.0

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak
> On Aug 1, 2018, at 2:14 PM, Carl Eugen Hoyos  wrote:
> 
> 2018-08-01 20:02 GMT+02:00, Ronak :
>> I'm re-sending the attachment.
> 
> Your patch contains tabs that cannot be committed to FFmpeg's repository -
> please remove them.
> 

Sounds good. Tabs are now removed.



0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch
Description: Binary data



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

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 03:50, Ronak  wrote:
> 
> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
From: "Ronak Patel (Audible)" 
Date: Tue, 31 Jul 2018 19:05:18 -0400
Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
 algorithm to N.

This fixes the creation of the hls manifest in hlsenc.c by writing the header 
once in hls_write_header, and the segments individually in the hls_window 
method.
Files that would previously take over a week to fragment now take 1 minute on 
the same hardware. This was a 153 hour audio file (2.2GB of audio).

Signed-off-by: Ronak Patel 
---
 libavformat/hlsenc.c | 143 +++
 1 file changed, 76 insertions(+), 67 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b5644f0..b15645d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 }
 p = (char *)av_basename(dirname);
 *p = '\0';
-
 }
 
 while (segment) {
@@ -1365,63 +1364,37 @@ fail:
 return ret;
 }
 
-static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
+static int hls_write_manifest_segment(AVFormatContext *s, int last, 
VariantStream *vs)
 {
 HLSContext *hls = s->priv_data;
 HLSSegment *en;
-int target_duration = 0;
 int ret = 0;
-char temp_filename[1024];
-int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
vs->nb_entries);
-const char *proto = avio_find_protocol_name(s->url);
-int use_rename = proto && !strcmp(proto, "file");
-static unsigned warned_non_file;
+int byterange_mode;
 char *key_uri = NULL;
 char *iv_string = NULL;
 AVDictionary *options = NULL;
 double prog_date_time = vs->initial_prog_date_time;
 double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
&prog_date_time : NULL;
-int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size 
> 0);
-
-hls->version = 3;
-if (byterange_mode) {
-hls->version = 4;
-sequence = 0;
-}
-
-if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
-hls->version = 6;
-}
 
-if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-hls->version = 7;
-}
+if (last) {
 
-if (!use_rename && !warned_non_file++)
-av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this 
may lead to races and temporary partial files\n");
+if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
+ff_hls_write_end_list(hls->m3u8_out);
+}
 
-set_http_options(s, &options, hls);
-snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
"%s", vs->m3u8_name);
-if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, &options)) < 0)
-goto fail;
+if (vs->vtt_m3u8_name) {
+ff_hls_write_end_list(hls->sub_m3u8_out);
+}
+} else {
 
-for (en = vs->segments; en; en = en->next) {
-if (target_duration <= en->duration)
-target_duration = lrint(en->duration);
-}
+byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size 
> 0);
 
-vs->discontinuity_set = 0;
-ff_hls_write_playlist_header(hls->m3u8_out, hls->version, hls->allowcache,
- target_duration, sequence, hls->pl_type);
+en = vs->last_segment;
+if (en == NULL) {
+ret = 1;
+goto fail;
+}
 
-if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
vs->discontinuity_set==0 ){
-avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
-vs->discontinuity_set = 1;
-}
-if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
-avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
-}
-for (en = vs->segments; en; en = en->next) {
 if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
strcmp(en->key_uri, key_uri) ||
 av_strcasecmp(en->iv_string, iv_string))) {
 avio_printf(hls->m3u8_out, "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", 
en->key_uri);
@@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 if (ret < 0) {
 av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
 }
-}
-
-if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
-ff_hls_write_end_list(hls->m3u8_out);
 
-if( vs->vtt_m3u8_name ) {
-if ((ret = hlsenc_io_open(s, &hls->sub_m3u8_out, vs->vtt_m3u8_name, 
&options)) < 0)
-goto fail;
-ff_hls_write_playlist_header(hls->sub_m3u8_out, hls->version, 
hls->allowcache,
- target_duration, sequence, 
PLAYLIST_TYPE_NONE);
-for (en = vs->segments; en; en = en->next) {
+if

Re: [FFmpeg-devel] [PATCH] avformat/matroska: Parse generic encryption info from packets.

2018-08-01 Thread Jacob Trimble
On Mon, Jul 23, 2018 at 1:59 PM Jacob Trimble  wrote:
>
> On Thu, Jul 12, 2018 at 4:45 PM Jacob Trimble  wrote:
> >
> > The attached patch adds parsing for WebM encryption info into the
> > AVEncryptionInfo side-data.  The AVEncryptionInitInfo will be handled
> > in another patch.
> >
> > Spec: https://www.webmproject.org/docs/webm-encryption/
> >
> > I am currently seeing a problem with this when using Opus audio.  In
> > read_frame_internal, it will try to parse the resulting packet.  For
> > video, which uses subsample encryption, it is able to parse the
> > headers; but for Opus, which uses full-sample encryption, it fails to
> > parse the headers.  This causes the read_frame_internal to drop the
> > packet.
> >
> > I have traced a workaround to opus_parse in opus_parser.c: instead of
> > setting poutbuf to NULL, set it to the buffer and just pass the packet
> > to the app to handle it.  The frame will be decrypted before passing
> > to the decoder.  I can't just disable parsing in the demuxer because I
> > want to parse the packets for clear content and when using subsample
> > encryption.
> >
> > Does anyone have any other ideas to work around this?  Is there a way
> > to allow parsing but ignore errors?
>
> Ping.

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


Re: [FFmpeg-devel] [PATCH] libavfilter: temporarily remove DNN framework and vf_sr filter

2018-08-01 Thread Ronald S. Bultje
Hi Pedro,

On Tue, Jul 31, 2018 at 1:22 PM, Pedro Arthur  wrote:

> 2018-07-28 14:31 GMT-03:00 Pedro Arthur :
> > 2018-07-27 14:24 GMT-03:00 Rostislav Pehlivanov :
> >> On 27 July 2018 at 18:12, Rostislav Pehlivanov 
> wrote:
> >>
> >>>
> >>> And the coding style is just the tip, there are dozens of things I
> >>> disagree with, such as the custom float to 8 bit conversions, when
> filters
> >>> already exist which take in floats (zscale).
> >>>
> >>
> >> I should probably expand on what I mean by the custom float conversion:
> >> make the filter accept a float pixel format, such as
> AV_PIX_FMT_GBRPF32. We
> >> have one, we use it in vf_tonemap and vf_zscale. Users will need to
> specify
> >> a filter to convert to float first, which will match what they have to
> do
> >> for vf_zscale and vf_tonemap. If you need to process YUV then add a
> float
> >> YUV format, but please, don't do custom conversions in filters.
> > It seems there is a patch adding YUV float formats in the ml, I asked
> > the student to make a patch removing the conversion and supporting
> > only float formats when the yuv float format get in the tree.
> Just to update on the matter, there are currently two patches on ml,
> one which fixes the code style and one which removes a huge amount of
> stored data from the sr filter.
> We are working on removing the format conversion from sr filter,
> adding the needed floating formats to swscale.


Thanks for taking the time/effort to address some of our concerns.

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: Parse encryption init info from streams.

2018-08-01 Thread Jacob Trimble
On Mon, Jul 23, 2018 at 2:01 PM Jacob Trimble  wrote:
>
> On Thu, Jul 12, 2018 at 5:05 PM Jacob Trimble  wrote:
> >
> > Signed-off-by: Jacob Trimble 
> > ---
> >  libavformat/matroskadec.c | 43 +--
> >  1 file changed, 32 insertions(+), 11 deletions(-)
> >
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index 1ded431b80..bfef329e59 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -2080,7 +2080,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
> >  int extradata_offset = 0;
> >  uint32_t fourcc = 0;
> >  AVIOContext b;
> > -char* key_id_base64 = NULL;
> > +char* key_id = NULL;
> > +int key_id_size = 0;
> >  int bit_depth = -1;
> >
> >  /* Apply some sanity checks. */
> > @@ -2133,14 +2134,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
> >  if (encodings[0].encryption.key_id.size > 0) {
> >  /* Save the encryption key id to be stored later as a
> > metadata tag. */
> > -const int b64_size = 
> > AV_BASE64_SIZE(encodings[0].encryption.key_id.size);
> > -key_id_base64 = av_malloc(b64_size);
> > -if (key_id_base64 == NULL)
> > -return AVERROR(ENOMEM);
> > -
> > -av_base64_encode(key_id_base64, b64_size,
> > - encodings[0].encryption.key_id.data,
> > - encodings[0].encryption.key_id.size);
> > +key_id = encodings[0].encryption.key_id.data;
> > +key_id_size = encodings[0].encryption.key_id.size;
> >  } else {
> >  encodings[0].scope = 0;
> >  av_log(matroska->ctx, AV_LOG_ERROR,
> > @@ -2198,14 +2193,40 @@ static int matroska_parse_tracks(AVFormatContext *s)
> >
> >  st = track->stream = avformat_new_stream(s, NULL);
> >  if (!st) {
> > -av_free(key_id_base64);
> >  return AVERROR(ENOMEM);
> >  }
> >
> > -if (key_id_base64) {
> > +if (key_id) {
> > +AVEncryptionInitInfo *init_info;
> > +uint8_t *side_data;
> > +size_t side_data_size;
> > +const int b64_size = AV_BASE64_SIZE(key_id_size);
> > +char *key_id_base64 = av_malloc(b64_size);
> > +if (!key_id_base64)
> > +return AVERROR(ENOMEM);
> > +av_base64_encode(key_id_base64, b64_size, key_id, key_id_size);
> > +
> >  /* export encryption key id as base64 metadata tag */
> >  av_dict_set(&st->metadata, "enc_key_id", key_id_base64, 0);
> >  av_freep(&key_id_base64);
> > +
> > +
> > +/* Convert the key ID to a generic encryption init info */
> > +init_info = av_encryption_init_info_alloc(/* system_id_size */ 
> > 0, /* num_key_ids */ 1,
> > +  /* key_id_size */ 
> > key_id_size, /* data_size */ 0);
> > +if (!init_info)
> > +return AVERROR(ENOMEM);
> > +memcpy(init_info->key_ids[0], key_id, key_id_size);
> > +side_data = av_encryption_init_info_add_side_data(init_info, 
> > &side_data_size);
> > +av_encryption_init_info_free(init_info);
> > +if (!side_data)
> > +return AVERROR(ENOMEM);
> > +ret = av_stream_add_side_data(st, 
> > AV_PKT_DATA_ENCRYPTION_INIT_INFO,
> > +  side_data, side_data_size);
> > +if (ret < 0) {
> > +av_free(side_data);
> > +return ret;
> > +}
> >  }
> >
> >  if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") &&
> > --
> > 2.18.0.203.gfac676dfb9-goog
> >
>
> Ping.

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


Re: [FFmpeg-devel] Why not integrate libyuv as a scale filter

2018-08-01 Thread Carl Eugen Hoyos
2018-07-28 13:34 GMT+02:00, Jeff <163j...@163.com>:
> Hi Carl,
>
>
> Sorry for late reply.
>
>
> I make a simple test on my MacBook Pro (13-inch, 2016, 2 GHz Intel Core i5,
> 8 GB 1867 MHz LPDDR3).
> I read a 1088x1920 BGR24 frame from local disk, and then scale it to
> 480x854-YUV420P 500
> times respectively by libswscale & libyuv. The result shows that libswscale
> take about 4.19
> seconds while libyuv just take about 0.93 seconds. Which means libyuv is
> about 4~5 times
> faster than the libswscale on my test. Is that say something?

Not sure.
My question was if libyuv is multi-threaded (if it is, it should be
possible to get the scale filter to the same speed), if it outputs
the same quality and what kind of asm optimization it uses.

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak

> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 03:50, Ronak  wrote:
>> 
>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
> From: "Ronak Patel (Audible)" 
> Date: Tue, 31 Jul 2018 19:05:18 -0400
> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
> algorithm to N.
> 
> This fixes the creation of the hls manifest in hlsenc.c by writing the header 
> once in hls_write_header, and the segments individually in the hls_window 
> method.
> Files that would previously take over a week to fragment now take 1 minute on 
> the same hardware. This was a 153 hour audio file (2.2GB of audio).
> 
> Signed-off-by: Ronak Patel 
> ---
> libavformat/hlsenc.c | 143 +++
> 1 file changed, 76 insertions(+), 67 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b5644f0..b15645d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
> HLSContext *hls,
> }
> p = (char *)av_basename(dirname);
> *p = '\0';
> -
> }
> 
> while (segment) {
> @@ -1365,63 +1364,37 @@ fail:
> return ret;
> }
> 
> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
> HLSContext *hls = s->priv_data;
> HLSSegment *en;
> -int target_duration = 0;
> int ret = 0;
> -char temp_filename[1024];
> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
> vs->nb_entries);
> -const char *proto = avio_find_protocol_name(s->url);
> -int use_rename = proto && !strcmp(proto, "file");
> -static unsigned warned_non_file;
> +int byterange_mode;
> char *key_uri = NULL;
> char *iv_string = NULL;
> AVDictionary *options = NULL;
> double prog_date_time = vs->initial_prog_date_time;
> double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
> &prog_date_time : NULL;
> -int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> -
> -hls->version = 3;
> -if (byterange_mode) {
> -hls->version = 4;
> -sequence = 0;
> -}
> -
> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> -hls->version = 6;
> -}
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> -hls->version = 7;
> -}
> +if (last) {
> 
> -if (!use_rename && !warned_non_file++)
> -av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, 
> this may lead to races and temporary partial files\n");
> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
> +ff_hls_write_end_list(hls->m3u8_out);
> +}
> 
> -set_http_options(s, &options, hls);
> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
> "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, &options)) < 
> 0)
> -goto fail;
> +if (vs->vtt_m3u8_name) {
> +ff_hls_write_end_list(hls->sub_m3u8_out);
> +}
> +} else {
> 
> -for (en = vs->segments; en; en = en->next) {
> -if (target_duration <= en->duration)
> -target_duration = lrint(en->duration);
> -}
> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> 
> -vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
> hls->allowcache,
> - target_duration, sequence, hls->pl_type);
> +en = vs->last_segment;
> +if (en == NULL) {
> +ret = 1;
> +goto fail;
> +}
> 
> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
> vs->discontinuity_set==0 ){
> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
> -vs->discontinuity_set = 1;
> -}
> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
> -}
> -for (en = vs->segments; en; en = en->next) {
> if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
> strcmp(en->key_uri, key_uri) ||
> av_strcasecmp(en->iv_string, iv_string))) 
> {
> avio_printf(hls->m3u8_out, 
> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
> VariantStream *vs)
> if (ret < 0) {
> av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
> }
> -}
> -
> -if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)
> -ff_hls_write_end_list(hls->m3u8_out);
> 
> -if( vs->vtt_m3u8_name ) {
> -if ((ret = hlsenc_io_open(s, &hls->sub_m3u8_out, vs

Re: [FFmpeg-devel] [PATCH 6/8] avcodec/h264_redundant_pps_bsf: implement a AVBSFContext.flush() callback

2018-08-01 Thread Mark Thompson
On 28/07/18 22:59, Michael Niedermayer wrote:
> On Fri, Jul 27, 2018 at 11:57:47AM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> I'm not 100% sure this is correct. I also don't know if the CBS contexts need
>> to be fully reinitialized or not in this scenario. Because if so, then every
>> bsf using cbs will require a flush() callback as well.
>>
>>  libavcodec/h264_redundant_pps_bsf.c | 9 +
>>  1 file changed, 9 insertions(+)
> 
> Do we have a fate test for this ?

No - I don't have a public file it applies to.  (I can share an example 
privately.)

> Also from a quick look, isnt this filter lacking checks ?
> it removes PPS but i see no check that these PPS differ only in the qp
> related parameters. Also doesnt this filter miss that there can be multiple
> PPS with different id#

The problematic streams repeatedly overwrite PPS id 0 with different 
parameters, and that's what we're fixing up here - using a stream like that in 
any case with global extradata fails on seeking or fragmenting.

> Maybe iam missing something and this is of course not about the
> patch at hand but it looks like this is a quite specific filter that
> cannot saftely be applied to h264 in general and if so this is not
> obvious from the documentation.

The documentation says the filter "applies a specific fixup to some Blu-ray 
streams", which implies that it doesn't apply to anything else?  Feel free to 
add some additional text which clarifies it to your reading if you don't agree.

Thanks,

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


Re: [FFmpeg-devel] [PATCH 6/8] avcodec/h264_redundant_pps_bsf: implement a AVBSFContext.flush() callback

2018-08-01 Thread James Almer
On 8/1/2018 7:20 PM, Mark Thompson wrote:
> The problematic streams repeatedly overwrite PPS id 0 with different 
> parameters, and that's what we're fixing up here - using a stream like that 
> in any case with global extradata fails on seeking or fragmenting.

So is this patch correct? Should i even add a flush() function, for that
matter? It's obvious this filter will never be autoinserted by any of
our decoders, but we can't say what API users may want to do.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [GSoC] FFserver libmicrohttpd interface

2018-08-01 Thread Stephan Holljes
After fighting for a bit too long, I am finally submitting this patch series
that adds the more mature libmicrohttpd library. Client disconnect detection
is not really taken care of as of now, clients will be disconnected once
av_interleaved_write_frame() fails. This may be worth looking into more
closely, see below.

Other fixes and improvements are also contained, the most important ones:
  - fix compilation (fileserver.c/.h's fileserver_schedule() was broken.
  - properly handle file requests if no fileserver is running (prevents crash)

At the moment there is a memory-leak I can't seem to fix. It is the connection-
closure (**con_cls) in lmhttpd.c:answer_to_connection(). In the libmicrohttpd
examples a function to free it is passed to MHD_create_response_from_callback(),
however this leads to a heap-use-after-free bug. This happens when a client
disconnects prematurely.

Another but I could not reliably reproduce is the skipping of segments from the
server side. It occurs very rarely and as I said I could not reproduce it yet.

There may even be more bugs I am currently unaware of, these just took the
highest priority for fixing in my opinion.

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


[FFmpeg-devel] [PATCH 3/7] ffserver.c: better logging

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 087963a..9cc501c 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -724,7 +724,6 @@ void *fileserver_thread(void *arg)
 struct FileserverClient *c;
 for (;;) {
 usleep(50);
-av_log(NULL, AV_LOG_WARNING, "Checking clients, fileserver-thread %s: 
", fs->server_name);
 clients_served = 0;
 for (i = 0; i < MAX_CLIENTS; i++) {
 c = &fs->clients[i];
@@ -740,7 +739,7 @@ void *fileserver_thread(void *arg)
 }
 pthread_mutex_unlock(&c->client_lock);
 }
-av_log(NULL, AV_LOG_WARNING, "%d/%d served\n", clients_served, 
MAX_CLIENTS);
+av_log(NULL, AV_LOG_INFO, "Checked clients, fileserver-thread %s %d/%d 
served\n", fs->server_name, clients_served, MAX_CLIENTS);
 if (fs->shutdown) {
 printf("shutting down\n");
 break;
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 4/7] ffserver.c: replace server logging context with NULL, since libmicrohttpd's daemon context is not known to libavutil.

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 9cc501c..59c1b4d 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -490,11 +490,11 @@ void *accept_thread(void *arg)
 for (i = 0; i < config->nb_streams; i++) {
 if (info->pubs[i]) {
 publisher_gen_status_json(info->pubs[i], status);
-av_log(server, AV_LOG_INFO, status);
+av_log(NULL, AV_LOG_INFO, status);
 }
 }
 client = NULL;
-av_log(server, AV_LOG_DEBUG, "Accepting new clients.\n");
+av_log(NULL, AV_LOG_DEBUG, "Accepting new clients.\n");
 reply_code = 200;
 
 if ((ret = info->httpd->accept(server, &client, NULL)) < 0) {
@@ -503,7 +503,7 @@ void *accept_thread(void *arg)
 } else if (ret == HTTPD_CLIENT_ERROR) {
 info->httpd->close(server, client);
 }
-av_log(server, AV_LOG_WARNING, "Error during accept, retrying.\n");
+av_log(NULL, AV_LOG_WARNING, "Error during accept, retrying.\n");
 continue;
 }
 
@@ -666,7 +666,7 @@ void *accept_thread(void *arg)
 ofmt_ctx->pb = client_ctx;
 ret = avformat_write_header(ofmt_ctx, &mkvopts);
 if (ret < 0) {
-av_log(client, AV_LOG_ERROR, "Could not write header to client: 
%s.\n", av_err2str(ret));
+av_log(client_ctx, AV_LOG_ERROR, "Could not write header to 
client: %s.\n", av_err2str(ret));
 publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 avformat_free_context(ofmt_ctx);
@@ -679,7 +679,7 @@ void *accept_thread(void *arg)
 ofmt_ctx = NULL;
 
 }
-av_log(server, AV_LOG_INFO, "Shutting down http server.\n");
+av_log(NULL, AV_LOG_INFO, "Shutting down http server.\n");
 info->httpd->shutdown(server);
 av_log(NULL, AV_LOG_INFO, "Shut down http server.\n");
 return NULL;
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 7/7] Update Documentation

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 Documentation.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation.txt b/Documentation.txt
index 3eb52b8..6295e4c 100644
--- a/Documentation.txt
+++ b/Documentation.txt
@@ -54,7 +54,8 @@ HTTPD-API
 
 To be independent of a specific http server implementation, an interface is
 provided that an http server implementation has to provide. At the time of
-writing an implementation using the libavformat http server is provided.
+writing an implementation using the libavformat http server and an
+implementation using the libmicrotthpd library are provided.
 
 The HTTPDInterface struct takes the following function pointers:
 
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 1/7] fileserver.c/.h: Fix fileserver_schedule()

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 fileserver.c | 1 -
 fileserver.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/fileserver.c b/fileserver.c
index a3460e3..d2f8c7f 100644
--- a/fileserver.c
+++ b/fileserver.c
@@ -49,7 +49,6 @@ void fileserver_schedule(struct FileserverContext *fs, struct 
FFServerInfo *ffin
 fsc->buf = NULL;
 fsc->size = 0;
 }
-fsc->ofmt_ctx = ofmt_ctx;
 pthread_mutex_unlock(&fsc->client_lock);
 } else {
 av_log(NULL, AV_LOG_WARNING, "Could not find free client slot.\n");
diff --git a/fileserver.h b/fileserver.h
index 6e449c0..bb4893c 100644
--- a/fileserver.h
+++ b/fileserver.h
@@ -45,7 +45,7 @@ struct FileserverContext {
  * @param ffinfo pointer to an FFServerInfo struct containing information for 
serving the file
  * @param filename filename of the file to serve
  */
-void fileserver_schedule(struct FileserverContext *fs, struct FFServerInfo 
*ffinfo, AVIOContext *ofmt_ctx, const char *filename);
+void fileserver_schedule(struct FileserverContext *fs, struct FFServerInfo 
*ffinfo, const char *filename);
 
 /**
  * Initialize a Fileservercontext
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 2/7] ffserver.c: Disconnect client if file was requested, but no fileserver was started.

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/ffserver.c b/ffserver.c
index 3b3451e..087963a 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -578,6 +578,11 @@ void *accept_thread(void *arg)
 continue;
 }
 
+if (!info->fs && requested_file[0]) {
+info->httpd->close(server, client);
+continue;
+}
+
 avio_buffer = av_malloc(AV_BUFSIZE);
 if (!avio_buffer) {
 av_log(client_ctx, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 6/7] ffserver.c: Reduce buffer from 30 to 10 seconds

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffserver.c b/ffserver.c
index de96c7b..bda7d33 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -45,7 +45,7 @@
 #include "httpd.h"
 #include "configreader.h"
 
-#define BUFFER_SECS 30
+#define BUFFER_SECS 10
 #define LISTEN_TIMEOUT_MSEC 1000
 #define AUDIO_ONLY_SEGMENT_SECONDS 2
 
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 5/7] lmhttpd.c/ffserver.c/httpd.h/Makefile: Add libmicrohttpd httpd interface implementation.

2018-08-01 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 Makefile   |   8 +-
 ffserver.c |   2 +-
 httpd.h|   1 +
 lmhttpd.c  | 310 +
 4 files changed, 318 insertions(+), 3 deletions(-)
 create mode 100644 lmhttpd.c

diff --git a/Makefile b/Makefile
index 18f3ac3..4714734 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,12 @@
 all: ffserver
 LAV_FLAGS = $(shell pkg-config --libs --cflags libavformat libavcodec 
libavutil)
 LUA_FLAGS = $(shell pkg-config --libs --cflags lua5.3)
+MHD_FLAGS = $(shell pkg-config --libs --cflags libmicrohttpd)
 CFLAGS=-fsanitize=address -fsanitize=undefined
 # LAV_FLAGS = -L/usr/local/lib -lavcodec -lavformat -lavutil
 
-ffserver: segment.o publisher.o fileserver.o lavfhttpd.o configreader.o 
ffserver.c
-   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(LUA_FLAGS) -lpthread -o ffserver 
segment.o publisher.o fileserver.o lavfhttpd.o configreader.o ffserver.c
+ffserver: segment.o publisher.o fileserver.o lavfhttpd.o lmhttpd.o 
configreader.o ffserver.c
+   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(LUA_FLAGS) $(MHD_FLAGS) -lpthread 
-o ffserver segment.o publisher.o fileserver.o lavfhttpd.o lmhttpd.o 
configreader.o ffserver.c
 
 segment.o: segment.c segment.h
cc -g -Wall $(CFLAGS) $(LAV_FLAGS) -lpthread -c segment.c
@@ -19,6 +20,9 @@ fileserver.o: fileserver.c fileserver.h
 lavfhttpd.o: lavfhttpd.c httpd.h
cc -g -Wall $(CFLAGS) $(LAV_FLAGS) -lpthread -c lavfhttpd.c
 
+lmhttpd.o: lmhttpd.c httpd.h
+   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(MHD_FLAGS) -lpthread -c lmhttpd.c
+
 configreader.o: configreader.c configreader.h httpd.h
cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(LUA_FLAGS) -c configreader.c
 clean:
diff --git a/ffserver.c b/ffserver.c
index 59c1b4d..de96c7b 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -797,7 +797,7 @@ void *run_server(void *arg) {
 ainfo.fs = fs;
 ainfo.ifmt_ctxs = ifmt_ctxs;
 ainfo.nb_pub = config->nb_streams;
-ainfo.httpd = &lavfhttpd;
+ainfo.httpd = &lmhttpd;
 ainfo.config = config;
 
 rinfos = av_mallocz_array(config->nb_streams, sizeof(struct ReadInfo));
diff --git a/httpd.h b/httpd.h
index 1b2566e..e61211a 100644
--- a/httpd.h
+++ b/httpd.h
@@ -83,4 +83,5 @@ struct FFServerInfo {
 
 /** Current HTTPDInterface implementation using lavformat */
 extern struct HTTPDInterface lavfhttpd;
+extern struct HTTPDInterface lmhttpd;
 #endif
diff --git a/lmhttpd.c b/lmhttpd.c
new file mode 100644
index 000..b4fcdc6
--- /dev/null
+++ b/lmhttpd.c
@@ -0,0 +1,310 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LMHTTPD_H
+#define LMHTTPD_H
+
+#define MAX_CLIENTS 16
+#define INITIAL_BUFSIZE 16 * 1024 * 1024
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include "httpd.h"
+
+struct MHDServer {
+struct MHD_Daemon *daemon;
+AVFifoBuffer *clients;
+};
+
+struct ConnectionInfo {
+AVFifoBuffer *buffer;
+pthread_mutex_t buffer_lock;
+struct MHD_Connection *connection;
+int close_connection;
+};
+
+
+/**
+ * Helper callback that fills the libmicrohttpd-client buffer with data.
+ */
+
+ssize_t helper_callback(void *cls, uint64_t pos, char *buf, size_t max)
+{
+struct ConnectionInfo *cinfo = (struct ConnectionInfo*) cls;
+pthread_mutex_lock(&cinfo->buffer_lock);
+int buf_size = av_fifo_size(cinfo->buffer);
+if (buf_size > 0) {
+max = max > buf_size ? buf_size : max;
+av_fifo_generic_read(cinfo->buffer, buf, max, NULL);
+} else {
+max = 0;
+}
+if (max == 0 && cinfo->close_connection) {
+av_fifo_free(cinfo->buffer);
+pthread_mutex_unlock(&cinfo->buffer_lock);
+av_free(cinfo);
+return MHD_CONTENT_READER_END_OF_STREAM;
+}
+pthread_mutex_unlock(&cinfo->buffer_lock);
+return max;
+}
+
+/**
+ * Free allocated callback params. Usually passed to 
MHD_create_response_from_callback, however it frees data too soon.
+ */
+
+static void free_callback_param (void *cls)
+{
+av_free(cls);
+}
+
+/**
+ * Callback that handles incoming connections.
+ *
+ * Incoming connections are initialized and added to a queue of new clients.
+ */
+
+static int answer_to_connection (void *cls, struct MHD_Con

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 06:20, Ronak  wrote:
> 
>> 
>> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
>> 
>> 
>> 
>>> On Aug 2, 2018, at 03:50, Ronak  wrote:
>>> 
>>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
>> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
>> From: "Ronak Patel (Audible)" 
>> Date: Tue, 31 Jul 2018 19:05:18 -0400
>> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
>> algorithm to N.
>> 
>> This fixes the creation of the hls manifest in hlsenc.c by writing the 
>> header once in hls_write_header, and the segments individually in the 
>> hls_window method.
>> Files that would previously take over a week to fragment now take 1 minute 
>> on the same hardware. This was a 153 hour audio file (2.2GB of audio).
>> 
>> Signed-off-by: Ronak Patel 
>> ---
>> libavformat/hlsenc.c | 143 
>> +++
>> 1 file changed, 76 insertions(+), 67 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index b5644f0..b15645d 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>> }
>> p = (char *)av_basename(dirname);
>> *p = '\0';
>> -
>> }
>> 
>> while (segment) {
>> @@ -1365,63 +1364,37 @@ fail:
>> return ret;
>> }
>> 
>> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> {
>> HLSContext *hls = s->priv_data;
>> HLSSegment *en;
>> -int target_duration = 0;
>> int ret = 0;
>> -char temp_filename[1024];
>> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
>> vs->nb_entries);
>> -const char *proto = avio_find_protocol_name(s->url);
>> -int use_rename = proto && !strcmp(proto, "file");
>> -static unsigned warned_non_file;
>> +int byterange_mode;
>> char *key_uri = NULL;
>> char *iv_string = NULL;
>> AVDictionary *options = NULL;
>> double prog_date_time = vs->initial_prog_date_time;
>> double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
>> &prog_date_time : NULL;
>> -int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>> (hls->max_seg_size > 0);
>> -
>> -hls->version = 3;
>> -if (byterange_mode) {
>> -hls->version = 4;
>> -sequence = 0;
>> -}
>> -
>> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
>> -hls->version = 6;
>> -}
>> 
>> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> -hls->version = 7;
>> -}
>> +if (last) {
>> 
>> -if (!use_rename && !warned_non_file++)
>> -av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, 
>> this may lead to races and temporary partial files\n");
>> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
>> +ff_hls_write_end_list(hls->m3u8_out);
>> +}
>> 
>> -set_http_options(s, &options, hls);
>> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
>> "%s", vs->m3u8_name);
>> -if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, &options)) 
>> < 0)
>> -goto fail;
>> +if (vs->vtt_m3u8_name) {
>> +ff_hls_write_end_list(hls->sub_m3u8_out);
>> +}
>> +} else {
>> 
>> -for (en = vs->segments; en; en = en->next) {
>> -if (target_duration <= en->duration)
>> -target_duration = lrint(en->duration);
>> -}
>> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>> (hls->max_seg_size > 0);
>> 
>> -vs->discontinuity_set = 0;
>> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
>> hls->allowcache,
>> - target_duration, sequence, hls->pl_type);
>> +en = vs->last_segment;
>> +if (en == NULL) {
>> +ret = 1;
>> +goto fail;
>> +}
>> 
>> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && 
>> vs->discontinuity_set==0 ){
>> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
>> -vs->discontinuity_set = 1;
>> -}
>> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
>> -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
>> -}
>> -for (en = vs->segments; en; en = en->next) {
>> if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
>> strcmp(en->key_uri, key_uri) ||
>> av_strcasecmp(en->iv_string, 
>> iv_string))) {
>> avio_printf(hls->m3u8_out, 
>> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
>> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int last, 
>> VariantStream *vs)
>> if (ret < 0) {
>> av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
>> }
>> -}
>> -
>> -if 

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Steven Liu


> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 06:20, Ronak  wrote:
>> 
>>> 
>>> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
>>> 
>>> 
>>> 
 On Aug 2, 2018, at 03:50, Ronak  wrote:
 
 <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
>>> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
>>> From: "Ronak Patel (Audible)" 
>>> Date: Tue, 31 Jul 2018 19:05:18 -0400
>>> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an N^2
>>> algorithm to N.
>>> 
>>> This fixes the creation of the hls manifest in hlsenc.c by writing the 
>>> header once in hls_write_header, and the segments individually in the 
>>> hls_window method.
>>> Files that would previously take over a week to fragment now take 1 minute 
>>> on the same hardware. This was a 153 hour audio file (2.2GB of audio).
>>> 
>>> Signed-off-by: Ronak Patel 
>>> ---
>>> libavformat/hlsenc.c | 143 
>>> +++
>>> 1 file changed, 76 insertions(+), 67 deletions(-)
>>> 
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index b5644f0..b15645d 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>>> HLSContext *hls,
>>>}
>>>p = (char *)av_basename(dirname);
>>>*p = '\0';
>>> -
>>>}
>>> 
>>>while (segment) {
>>> @@ -1365,63 +1364,37 @@ fail:
>>>return ret;
>>> }
>>> 
>>> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>>> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
>>> VariantStream *vs)
>>> {
>>>HLSContext *hls = s->priv_data;
>>>HLSSegment *en;
>>> -int target_duration = 0;
>>>int ret = 0;
>>> -char temp_filename[1024];
>>> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
>>> vs->nb_entries);
>>> -const char *proto = avio_find_protocol_name(s->url);
>>> -int use_rename = proto && !strcmp(proto, "file");
>>> -static unsigned warned_non_file;
>>> +int byterange_mode;
>>>char *key_uri = NULL;
>>>char *iv_string = NULL;
>>>AVDictionary *options = NULL;
>>>double prog_date_time = vs->initial_prog_date_time;
>>>double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
>>> &prog_date_time : NULL;
>>> -int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>>> (hls->max_seg_size > 0);
>>> -
>>> -hls->version = 3;
>>> -if (byterange_mode) {
>>> -hls->version = 4;
>>> -sequence = 0;
>>> -}
>>> -
>>> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
>>> -hls->version = 6;
>>> -}
>>> 
>>> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>>> -hls->version = 7;
>>> -}
>>> +if (last) {
>>> 
>>> -if (!use_rename && !warned_non_file++)
>>> -av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, 
>>> this may lead to races and temporary partial files\n");
>>> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
>>> +ff_hls_write_end_list(hls->m3u8_out);
>>> +}
>>> 
>>> -set_http_options(s, &options, hls);
>>> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
>>> "%s", vs->m3u8_name);
>>> -if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, &options)) 
>>> < 0)
>>> -goto fail;
>>> +if (vs->vtt_m3u8_name) {
>>> +ff_hls_write_end_list(hls->sub_m3u8_out);
>>> +}
>>> +} else {
>>> 
>>> -for (en = vs->segments; en; en = en->next) {
>>> -if (target_duration <= en->duration)
>>> -target_duration = lrint(en->duration);
>>> -}
>>> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
>>> (hls->max_seg_size > 0);
>>> 
>>> -vs->discontinuity_set = 0;
>>> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
>>> hls->allowcache,
>>> - target_duration, sequence, hls->pl_type);
>>> +en = vs->last_segment;
>>> +if (en == NULL) {
>>> +ret = 1;
>>> +goto fail;
>>> +}
>>> 
>>> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
>>> && vs->discontinuity_set==0 ){
>>> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
>>> -vs->discontinuity_set = 1;
>>> -}
>>> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
>>> -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
>>> -}
>>> -for (en = vs->segments; en; en = en->next) {
>>>if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
>>> strcmp(en->key_uri, key_uri) ||
>>>av_strcasecmp(en->iv_string, 
>>> iv_string))) {
>>>avio_printf(hls->m3u8_out, 
>>> "#EXT-X-KEY:METHOD=AES-128,URI=\"%s\"", en->key_uri);
>>> @@ -1444,17 +1417,8 @@ static int hls_window(AVFormatContext *s, int l

Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak Patel

> On Aug 1, 2018, at 7:30 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
>> 
>> 
>> 
 On Aug 2, 2018, at 06:20, Ronak  wrote:
 
 
 On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
 
 
 
> On Aug 2, 2018, at 03:50, Ronak  wrote:
> 
> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
 From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
 From: "Ronak Patel (Audible)" 
 Date: Tue, 31 Jul 2018 19:05:18 -0400
 Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an 
 N^2
 algorithm to N.
 
 This fixes the creation of the hls manifest in hlsenc.c by writing the 
 header once in hls_write_header, and the segments individually in the 
 hls_window method.
 Files that would previously take over a week to fragment now take 1 minute 
 on the same hardware. This was a 153 hour audio file (2.2GB of audio).
 
 Signed-off-by: Ronak Patel 
 ---
 libavformat/hlsenc.c | 143 
 +++
 1 file changed, 76 insertions(+), 67 deletions(-)
 
 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index b5644f0..b15645d 100644
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext *s, 
 HLSContext *hls,
   }
   p = (char *)av_basename(dirname);
   *p = '\0';
 -
   }
 
   while (segment) {
 @@ -1365,63 +1364,37 @@ fail:
   return ret;
 }
 
 -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
 VariantStream *vs)
 {
   HLSContext *hls = s->priv_data;
   HLSSegment *en;
 -int target_duration = 0;
   int ret = 0;
 -char temp_filename[1024];
 -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
 vs->nb_entries);
 -const char *proto = avio_find_protocol_name(s->url);
 -int use_rename = proto && !strcmp(proto, "file");
 -static unsigned warned_non_file;
 +int byterange_mode;
   char *key_uri = NULL;
   char *iv_string = NULL;
   AVDictionary *options = NULL;
   double prog_date_time = vs->initial_prog_date_time;
   double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
 &prog_date_time : NULL;
 -int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
 (hls->max_seg_size > 0);
 -
 -hls->version = 3;
 -if (byterange_mode) {
 -hls->version = 4;
 -sequence = 0;
 -}
 -
 -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
 -hls->version = 6;
 -}
 
 -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 -hls->version = 7;
 -}
 +if (last) {
 
 -if (!use_rename && !warned_non_file++)
 -av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, 
 this may lead to races and temporary partial files\n");
 +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
 +ff_hls_write_end_list(hls->m3u8_out);
 +}
 
 -set_http_options(s, &options, hls);
 -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" 
 : "%s", vs->m3u8_name);
 -if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, 
 &options)) < 0)
 -goto fail;
 +if (vs->vtt_m3u8_name) {
 +ff_hls_write_end_list(hls->sub_m3u8_out);
 +}
 +} else {
 
 -for (en = vs->segments; en; en = en->next) {
 -if (target_duration <= en->duration)
 -target_duration = lrint(en->duration);
 -}
 +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
 (hls->max_seg_size > 0);
 
 -vs->discontinuity_set = 0;
 -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
 hls->allowcache,
 - target_duration, sequence, hls->pl_type);
 +en = vs->last_segment;
 +if (en == NULL) {
 +ret = 1;
 +goto fail;
 +}
 
 -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
 && vs->discontinuity_set==0 ){
 -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
 -vs->discontinuity_set = 1;
 -}
 -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
 -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
 -}
 -for (en = vs->segments; en; en = en->next) {
   if ((hls->encrypt || hls->key_info_file) && (!key_uri || 
 strcmp(en->key_uri, key_uri) ||
   av_strcasecmp(en->iv_string, 
 iv_st

[FFmpeg-devel] [PATCH] doc/filters: add tonemap_opencl document.

2018-08-01 Thread Ruiling Song
Signed-off-by: Ruiling Song 
---
 doc/filters.texi | 158 +++
 1 file changed, 158 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6695999c84..f622d03226 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17776,6 +17776,164 @@ Apply sobel operator with scale set to 2 and delta 
set to 10
 @end example
 @end itemize
 
+@section tonemap_opencl
+
+Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
+
+It accepts the following parameters:
+
+@table @option
+@item tonemap
+Specify the tone-mapping operator to be used.
+
+Possible values are:
+@table @var
+@item none
+Do not apply any tone mapping, only desaturate overbright pixels.
+
+@item clip
+Hard-clip any out-of-range values. Use it for perfect color accuracy for
+in-range values, while distorting out-of-range values.
+
+@item linear
+Stretch the entire reference gamut to a linear multiple of the display.
+
+@item gamma
+Fit a logarithmic transfer between the tone curves.
+
+@item reinhard
+Preserve overall image brightness with a simple curve, using nonlinear
+contrast, which results in flattening details and degrading color accuracy.
+
+@item hable
+Preserve both dark and bright details better than @var{reinhard}, at the cost
+of slightly darkening everything. Use it when detail preservation is more
+important than color and brightness accuracy.
+
+@item mobius
+Smoothly map out-of-range values, while retaining contrast and colors for
+in-range material as much as possible. Use it when color accuracy is more
+important than detail preservation.
+@end table
+
+@item param
+Tune the tone mapping algorithm.
+
+This affects the following algorithms:
+@table @var
+@item none
+Ignored.
+
+@item linear
+Specifies the scale factor to use while stretching.
+Default to 1.0.
+
+@item gamma
+Specifies the exponent of the function.
+Default to 1.8.
+
+@item clip
+Specify an extra linear coefficient to multiply into the signal before 
clipping.
+Default to 1.0.
+
+@item reinhard
+Specify the local contrast coefficient at the display peak.
+Default to 0.5, which means that in-gamut values will be about half as bright
+as when clipping.
+
+@item hable
+Ignored.
+
+@item mobius
+Specify the transition point from linear to mobius transform. Every value
+below this point is guaranteed to be mapped 1:1. The higher the value, the
+more accurate the result will be, at the cost of losing bright details.
+Default to 0.3, which due to the steep initial slope still preserves in-range
+colors fairly accurately.
+@end table
+
+@item desat
+Apply desaturation for highlights that exceed this level of brightness. The
+higher the parameter, the more color information will be preserved. This
+setting helps prevent unnaturally blown-out colors for super-highlights, by
+(smoothly) turning into white instead. This makes images feel more natural,
+at the cost of reducing information about out-of-range colors.
+
+The default value is 0.5, and the algorithm here is a little different from
+the cpu version tonemap currently. A setting of 0.0 disables this option.
+
+@item threshold
+The tonemapping algorithm parameters is fine-tuned per each scene. And a 
threshold
+is used to detect whether the scene has changed or not. If the distance beween
+the current frame average brightness and the current running average exceeds
+a threshold value, we would re-calculate scene average and peak brightness.
+The default value is 0.2.
+
+@item format
+Specify the output pixel format.
+
+Currently supported formats are:
+@table @var
+@item p010
+@item nv12
+@end table
+
+@item range, r
+Set the output color range.
+
+Possible values are:
+@table @var
+@item tv/mpeg
+@item pc/jpeg
+@end table
+
+Default is same as input.
+
+@item primaries, p
+Set the output color primaries.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@item transfer, t
+Set the output transfer characteristics.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is bt709.
+
+@item matrix, m
+Set the output colorspace matrix.
+
+Possible value are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using 
linear operator.
+@example
+-i INPUT -vf "hwupload, 
format=p010,tonemap_opencl=t=bt2020:tonemap=linear:format=p010, hwdownload" 
OUTPUT
+@end example
+@end itemize
+
 @section unsharp_opencl
 
 Sharpen or blur the input video.
-- 
2.17.0

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


Re: [FFmpeg-devel] [PATCH 1/2] docs/filters: add documentation to all existing OpenCL filters

2018-08-01 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Danil Iashchenko
> Sent: Tuesday, July 31, 2018 8:14 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Danil Iashchenko 
> Subject: [FFmpeg-devel] [PATCH 1/2] docs/filters: add documentation to all
> existing OpenCL filters
> 
> docs/filters: add documentation to all existing OpenCL filters
> 
> ---
> 
> Thanks for your comments! Most of the issues have been fixed.
> 
> >The filer source has many more options defined.
> >In addition, there are many missing values for the tonemap algo; it appears 
> >not
> all are effected. If that's the case, remove or note that in the AVOptions 
> table.
> 
> It seems I'd need more time than expected to fully acquaint myself with
> tonemap_opencl so as to write appropriately detailed documentation, (as you
> said, there are a lot of options, and it's unclear which ones are actually 
> working).
> This hinders overall progress on the documentation and filter implementation 
> of
> my GSoC project and there is not much time left. I suggest putting it on the
> backburner for the moment and leaving it out until the next patch.
> Again, only tonemap_opencl presents an issue; the rest of the documentation is
> fine.
I am sorry for the late reply. I just write a patch to add the tonemap_opencl 
filter document.
It is based on this patch.

Thanks!
Ruiling 

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


Re: [FFmpeg-devel] First Patch for hlsenc.c for https://trac.ffmpeg.org/ticket/7281

2018-08-01 Thread Ronak Patel


> On Aug 1, 2018, at 9:30 PM, Ronak Patel  
> wrote:
> 
> 
>> On Aug 1, 2018, at 7:30 PM, Steven Liu  wrote:
>> 
>> 
>> 
>>> On Aug 2, 2018, at 07:22, Steven Liu  wrote:
>>> 
>>> 
>>> 
> On Aug 2, 2018, at 06:20, Ronak  wrote:
> 
> 
> On Aug 1, 2018, at 4:41 PM, Steven Liu  wrote:
> 
> 
> 
>> On Aug 2, 2018, at 03:50, Ronak  
>> wrote:
>> 
>> <0001-libavformat-hlsenc-Fix-HLS-Manifest-Generation-from-.patch>
> From e7ff03ed52c709d647a112833427b44c41e3ed12 Mon Sep 17 00:00:00 2001
> From: "Ronak Patel (Audible)" 
> Date: Tue, 31 Jul 2018 19:05:18 -0400
> Subject: [PATCH] libavformat/hlsenc: Fix HLS Manifest Generation from an 
> N^2
> algorithm to N.
> 
> This fixes the creation of the hls manifest in hlsenc.c by writing the 
> header once in hls_write_header, and the segments individually in the 
> hls_window method.
> Files that would previously take over a week to fragment now take 1 
> minute on the same hardware. This was a 153 hour audio file (2.2GB of 
> audio).
> 
> Signed-off-by: Ronak Patel 
> ---
> libavformat/hlsenc.c | 143 
> +++
> 1 file changed, 76 insertions(+), 67 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b5644f0..b15645d 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -488,7 +488,6 @@ static int hls_delete_old_segments(AVFormatContext 
> *s, HLSContext *hls,
>  }
>  p = (char *)av_basename(dirname);
>  *p = '\0';
> -
>  }
> 
>  while (segment) {
> @@ -1365,63 +1364,37 @@ fail:
>  return ret;
> }
> 
> -static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
> +static int hls_write_manifest_segment(AVFormatContext *s, int last, 
> VariantStream *vs)
> {
>  HLSContext *hls = s->priv_data;
>  HLSSegment *en;
> -int target_duration = 0;
>  int ret = 0;
> -char temp_filename[1024];
> -int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - 
> vs->nb_entries);
> -const char *proto = avio_find_protocol_name(s->url);
> -int use_rename = proto && !strcmp(proto, "file");
> -static unsigned warned_non_file;
> +int byterange_mode;
>  char *key_uri = NULL;
>  char *iv_string = NULL;
>  AVDictionary *options = NULL;
>  double prog_date_time = vs->initial_prog_date_time;
>  double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? 
> &prog_date_time : NULL;
> -int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> -
> -hls->version = 3;
> -if (byterange_mode) {
> -hls->version = 4;
> -sequence = 0;
> -}
> -
> -if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
> -hls->version = 6;
> -}
> 
> -if (hls->segment_type == SEGMENT_TYPE_FMP4) {
> -hls->version = 7;
> -}
> +if (last) {
> 
> -if (!use_rename && !warned_non_file++)
> -av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, 
> this may lead to races and temporary partial files\n");
> +if ((hls->flags & HLS_OMIT_ENDLIST==0)) {
> +ff_hls_write_end_list(hls->m3u8_out);
> +}
> 
> -set_http_options(s, &options, hls);
> -snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" 
> : "%s", vs->m3u8_name);
> -if ((ret = hlsenc_io_open(s, &hls->m3u8_out, temp_filename, 
> &options)) < 0)
> -goto fail;
> +if (vs->vtt_m3u8_name) {
> +ff_hls_write_end_list(hls->sub_m3u8_out);
> +}
> +} else {
> 
> -for (en = vs->segments; en; en = en->next) {
> -if (target_duration <= en->duration)
> -target_duration = lrint(en->duration);
> -}
> +byterange_mode = (hls->flags & HLS_SINGLE_FILE) || 
> (hls->max_seg_size > 0);
> 
> -vs->discontinuity_set = 0;
> -ff_hls_write_playlist_header(hls->m3u8_out, hls->version, 
> hls->allowcache,
> - target_duration, sequence, 
> hls->pl_type);
> +en = vs->last_segment;
> +if (en == NULL) {
> +ret = 1;
> +goto fail;
> +}
> 
> -if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence 
> && vs->discontinuity_set==0 ){
> -avio_printf(hls->m3u8_out, "#EXT-X-DISCONTINUITY\n");
> -vs->discontinuity_set = 1;
> -}
> -if (vs->has_video && (hls->flags & HLS_INDEPENDENT_SEGMENTS)) {
> -avio_printf(hls->m3u8_out, "#EXT-X-INDEPENDENT-SEGMENTS\n");
> -}
> -for (en = vs->segments; e

Re: [FFmpeg-devel] lavf/dashdec: Fix memleak

2018-08-01 Thread Liu Steven


> 在 2018年8月1日,下午6:03,jacek jogo  写道:
> 
> Hi.
> This fix memleak in dashdec.
> ==5033== HEAP SUMMARY:
> ==5033== in use at exit: 86,144 bytes in 2,848 blocks
> ==5033==   total heap usage: 10,089 allocs, 7,241 frees, 38,902,613 bytes
> allocated
> ==5033==
> ==5033== Searching for pointers to 2,848 not-freed blocks
> ==5033== Checked 9,139,304 bytes
> ==5033==
> ==5033== 528 bytes in 8 blocks are definitely lost in loss record 187 of 222
> ==5033==at 0x4C2CB5F: malloc (vg_replace_malloc.c:299)
> ==5033==by 0x6868D38: xmlBufCreateSize (in /usr/lib64/libxml2.so.2.9.8)
> ==5033==by 0x67F1029: xmlNodeGetContent (in /usr/lib64/libxml2.so.2.9.8)
> ==5033==by 0x41EA43: resolve_content_path (dashdec.c:757)
> ==5033==by 0x41EA43: parse_manifest_representation (dashdec.c:873)
> ==5033==by 0x41EA43: parse_manifest_adaptationset (dashdec.c:1095)
> ==5033==by 0x41EA43: parse_manifest (dashdec.c:1272)
> ==5033==by 0x420E2A: dash_read_header (dashdec.c:1927)
> ==5033==by 0x53CF77: avformat_open_input (utils.c:631)
> ==5033==by 0x2647F4: open_input_file (ffmpeg_opt.c:1069)
> ==5033==by 0x266121: open_files (ffmpeg_opt.c:3219)
> ==5033==by 0x266121: ffmpeg_parse_options (ffmpeg_opt.c:3259)
> ==5033==by 0x25E991: main (ffmpeg.c:4859)
> ==5033==
> ==5033== LEAK SUMMARY:
> ==5033==definitely lost: 528 bytes in 8 blocks
> ==5033==indirectly lost: 0 bytes in 0 blocks
> ==5033==  possibly lost: 0 bytes in 0 blocks
> ==5033==still reachable: 85,616 bytes in 2,840 blocks
> ==5033== suppressed: 0 bytes in 0 blocks
> ==5033== Reachable blocks (those to which a pointer was found) are not
> shown.
> ==5033== To see them, rerun with: --leak-check=full --show-leak-kinds=all
> ==5033==
> ==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> ==5033== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
> 
> Can be reproduced with:  valgrind  --leak-check=full  -v ffmpeg -i
> http://yt-dash-mse-test.commondatastorage.googleapis.com/media/motion-20120802-manifest.mpd
> <0001-lavf-dashdec-Fix-memleak.patch>___


what about 
modify 
---
libavformat/dashdec.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 89f3ac2759..010a2e8387 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -754,9 +754,12 @@ static int resolve_content_path(AVFormatContext *s, const 
char *url, int *max_ur
if (!(node = baseurl_nodes[rootId])) {
continue;
}
-if (ishttp(xmlNodeGetContent(node))) {
+text = xmlNodeGetContent(node);
+if (ishttp(text)) {
+xmlFree(text);
break;
}
+xmlFree(text);
}

node = baseurl_nodes[rootId];
-- 
2.18.0

to 


From 1fa3d049a17dd4d135bb79423e0551ee7ee7f25d Mon Sep 17 00:00:00 2001
From: Jacek Jendrzej 
Date: Wed, 1 Aug 2018 11:53:41 +0200
Subject: [PATCH] lavf/dashdec: Fix memleak

---
libavformat/dashdec.c | 5 -
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 89f3ac2759..010a2e8387 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -754,9 +754,12 @@ static int resolve_content_path(AVFormatContext *s, const 
char *url, int *max_ur
if (!(node = baseurl_nodes[rootId])) {
continue;
}
-if (ishttp(xmlNodeGetContent(node))) {
+text = xmlNodeGetContent(node);
+xmlFree(text);
+if (ishttp(text)) {
break;
}
}

node = baseurl_nodes[rootId];
-- 
2.18.0




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



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


[FFmpeg-devel] [PATCH] avformat/avs: add descriptive name and url

2018-08-01 Thread Gyan Doshi
From c9118d4d64a661fddd431a7437994c31eafb32c6 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Thu, 2 Aug 2018 10:47:10 +0530
Subject: [PATCH] avformat/avs: add descriptive name and url

AVS now more commonly refers to the Chinese AVS format. This demuxer
processes video files for Creature Shock game
---
 libavformat/avs.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/avs.c b/libavformat/avs.c
index 763ba63f64..62f5a42ac9 100644
--- a/libavformat/avs.c
+++ b/libavformat/avs.c
@@ -19,6 +19,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+/**
+ * @file
+ * Argonaut Games' Creature Shock demuxer
+ * @see http://wiki.multimedia.cx/index.php?title=AVS
+ */
+
 #include "avformat.h"
 #include "voc.h"
 
@@ -225,7 +231,7 @@ static int avs_read_close(AVFormatContext * s)
 
 AVInputFormat ff_avs_demuxer = {
 .name   = "avs",
-.long_name  = NULL_IF_CONFIG_SMALL("AVS"),
+.long_name  = NULL_IF_CONFIG_SMALL("Argonaut Games Creature Shock"),
 .priv_data_size = sizeof(AvsFormat),
 .read_probe = avs_probe,
 .read_header= avs_read_header,
-- 
2.18.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel