Re: [FFmpeg-devel] [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists

2021-05-31 Thread Przemysław Sobala
Could any maintainer take a look at that?
--
Best regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists

2021-05-24 Thread Przemysław Sobala
Hello all,
I wanted to follow Carl's advice (
https://trac.ffmpeg.org/ticket/9252#comment:4) and prepared a patch with
hidden indentation changes, via git format-patch --ignore-space-change
origin/master (see my previous message) but that patch does not apply then.
So once again I'm sending the whole patch that applies correctly, as an
attachment.

Really, contributing to FFmpeg should be made easier (e.g. reviewing
indentation changes is easy when sent as GitHub merge request)

--
Best regards.
Przemysław Sobala


On Fri, 21 May 2021 at 13:46, Przemysław Sobala 
wrote:

> With audio/video HLS playlists, audio chunklists are treated as
> alternative renditions for video chunklists. This is wrong for
> audio-only HLS playlists.
>
> fixes: 9252
>
> Please correct indentation of introduced if statement's body, before
> applying.
> ---
>  libavformat/dashenc.c | 39 +++
>  1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 07f191e2a2..c5da02840b 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1256,10 +1256,6 @@ static int write_manifest(AVFormatContext *s, int
> final)
>
>  if (c->hls_playlist) {
>  char filename_hls[1024];
> -const char *audio_group = "A1";
> -char audio_codec_str[128] = "\0";
> -int is_default = 1;
> -int max_audio_bitrate = 0;
>
>  // Publish master playlist only the configured rate
>  if (c->master_playlist_created && (!c->master_publish_rate ||
> @@ -1282,6 +1278,13 @@ static int write_manifest(AVFormatContext *s, int
> final)
>
>  ff_hls_write_playlist_version(c->m3u8_out, 7);
>
> +if (c->has_video) {
> +// treat audio streams as alternative renditions for video
> streams
> +const char *audio_group = "A1";
> +char audio_codec_str[128] = "\0";
> +int is_default = 1;
> +int max_audio_bitrate = 0;
> +
>  for (i = 0; i < s->nb_streams; i++) {
>  char playlist_file[64];
>  AVStream *st = s->streams[i];
> @@ -1336,6 +1339,34 @@ static int write_manifest(AVFormatContext *s, int
> final)
>  playlist_file, agroup,
>  codec_str_ptr, NULL, NULL);
>  }
> +
> +} else {
> +// treat audio streams as separate renditions
> +
> +for (i = 0; i < s->nb_streams; i++) {
> +char playlist_file[64];
> +char codec_str[128];
> +AVStream *st = s->streams[i];
> +OutputStream *os = >streams[i];
> +int stream_bitrate = os->muxer_overhead;
> +if (os->bit_rate > 0)
> +stream_bitrate += os->bit_rate;
> +else if (final)
> +stream_bitrate += os->pos * 8 * AV_TIME_BASE /
> c->total_duration;
> +else if (os->first_segment_bit_rate > 0)
> +stream_bitrate += os->first_segment_bit_rate;
> +if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
> +continue;
> +if (os->segment_type != SEGMENT_TYPE_MP4)
> +continue;
> +av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
> +get_hls_playlist_name(playlist_file,
> sizeof(playlist_file), NULL, i);
> +ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate,
> +playlist_file, NULL,
> +codec_str, NULL, NULL);
> +}
> +}
> +
>  dashenc_io_close(s, >m3u8_out, temp_filename);
>  if (use_rename)
>  if ((ret = ff_rename(temp_filename, filename_hls, s)) < 0)
> --
> 2.31.1
>
>
From 00e71833cef4b8e0052b8bd7dcb83758385cfd31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= 
Date: Thu, 20 May 2021 11:50:27 +0200
Subject: [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists

With audio/video HLS playlists, audio chunklists are treated as
alternative renditions for video chunklists. This is wrong for
audio-only HLS playlists.

fixes: 9252
---
 libavformat/dashenc.c | 137 ++
 1 file changed, 84 insertions(+), 53 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 07f191e2a2..c5da02840b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1256,10 

[FFmpeg-devel] [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists

2021-05-21 Thread Przemysław Sobala
With audio/video HLS playlists, audio chunklists are treated as
alternative renditions for video chunklists. This is wrong for
audio-only HLS playlists.

fixes: 9252

Please correct indentation of introduced if statement's body, before
applying.
---
 libavformat/dashenc.c | 39 +++
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 07f191e2a2..c5da02840b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1256,10 +1256,6 @@ static int write_manifest(AVFormatContext *s, int final)
 
 if (c->hls_playlist) {
 char filename_hls[1024];
-const char *audio_group = "A1";
-char audio_codec_str[128] = "\0";
-int is_default = 1;
-int max_audio_bitrate = 0;
 
 // Publish master playlist only the configured rate
 if (c->master_playlist_created && (!c->master_publish_rate ||
@@ -1282,6 +1278,13 @@ static int write_manifest(AVFormatContext *s, int final)
 
 ff_hls_write_playlist_version(c->m3u8_out, 7);
 
+if (c->has_video) {
+// treat audio streams as alternative renditions for video streams
+const char *audio_group = "A1";
+char audio_codec_str[128] = "\0";
+int is_default = 1;
+int max_audio_bitrate = 0;
+
 for (i = 0; i < s->nb_streams; i++) {
 char playlist_file[64];
 AVStream *st = s->streams[i];
@@ -1336,6 +1339,34 @@ static int write_manifest(AVFormatContext *s, int final)
 playlist_file, agroup,
 codec_str_ptr, NULL, NULL);
 }
+
+} else {
+// treat audio streams as separate renditions
+
+for (i = 0; i < s->nb_streams; i++) {
+char playlist_file[64];
+char codec_str[128];
+AVStream *st = s->streams[i];
+OutputStream *os = >streams[i];
+int stream_bitrate = os->muxer_overhead;
+if (os->bit_rate > 0)
+stream_bitrate += os->bit_rate;
+else if (final)
+stream_bitrate += os->pos * 8 * AV_TIME_BASE / 
c->total_duration;
+else if (os->first_segment_bit_rate > 0)
+stream_bitrate += os->first_segment_bit_rate;
+if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
+continue;
+if (os->segment_type != SEGMENT_TYPE_MP4)
+continue;
+av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
+get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
NULL, i);
+ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate,
+playlist_file, NULL,
+codec_str, NULL, NULL);
+}
+}
+
 dashenc_io_close(s, >m3u8_out, temp_filename);
 if (use_rename)
 if ((ret = ff_rename(temp_filename, filename_hls, s)) < 0)
-- 
2.31.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] lavf/dashenc.c: Fix creating audio-only HLS playlists

2021-05-20 Thread Przemysław Sobala

With audio/video HLS playlists, audio chunklists are treated as
alternative renditions for video chunklists. This is wrong for
audio-only HLS playlists.

fixes: 9252
---
 libavformat/dashenc.c | 137 ++
 1 file changed, 84 insertions(+), 53 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 07f191e2a2..c5da02840b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1256,10 +1256,6 @@ static int write_manifest(AVFormatContext *s, int 
final)


 if (c->hls_playlist) {
 char filename_hls[1024];
-const char *audio_group = "A1";
-char audio_codec_str[128] = "\0";
-int is_default = 1;
-int max_audio_bitrate = 0;

 // Publish master playlist only the configured rate
 if (c->master_playlist_created && (!c->master_publish_rate ||
@@ -1282,60 +1278,95 @@ static int write_manifest(AVFormatContext *s, 
int final)


 ff_hls_write_playlist_version(c->m3u8_out, 7);

-for (i = 0; i < s->nb_streams; i++) {
-char playlist_file[64];
-AVStream *st = s->streams[i];
-OutputStream *os = >streams[i];
-if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
-continue;
-if (os->segment_type != SEGMENT_TYPE_MP4)
-continue;
-get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
NULL, i);

-ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group,
- playlist_file, NULL, i, 
is_default);

-max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
-  os->muxer_overhead, 
max_audio_bitrate);
-if (!av_strnstr(audio_codec_str, os->codec_str, 
sizeof(audio_codec_str))) {

-if (strlen(audio_codec_str))
-av_strlcat(audio_codec_str, ",", 
sizeof(audio_codec_str));
-av_strlcat(audio_codec_str, os->codec_str, 
sizeof(audio_codec_str));

+if (c->has_video) {
+// treat audio streams as alternative renditions for video 
streams

+const char *audio_group = "A1";
+char audio_codec_str[128] = "\0";
+int is_default = 1;
+int max_audio_bitrate = 0;
+
+for (i = 0; i < s->nb_streams; i++) {
+char playlist_file[64];
+AVStream *st = s->streams[i];
+OutputStream *os = >streams[i];
+if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
+continue;
+if (os->segment_type != SEGMENT_TYPE_MP4)
+continue;
+get_hls_playlist_name(playlist_file, 
sizeof(playlist_file), NULL, i);
+ff_hls_write_audio_rendition(c->m3u8_out, (char 
*)audio_group,
+playlist_file, NULL, i, 
is_default);

+max_audio_bitrate = FFMAX(st->codecpar->bit_rate +
+os->muxer_overhead, 
max_audio_bitrate);
+if (!av_strnstr(audio_codec_str, os->codec_str, 
sizeof(audio_codec_str))) {

+if (strlen(audio_codec_str))
+av_strlcat(audio_codec_str, ",", 
sizeof(audio_codec_str));
+av_strlcat(audio_codec_str, os->codec_str, 
sizeof(audio_codec_str));

+}
+is_default = 0;
 }
-is_default = 0;
-}

-for (i = 0; i < s->nb_streams; i++) {
-char playlist_file[64];
-char codec_str[128];
-AVStream *st = s->streams[i];
-OutputStream *os = >streams[i];
-char *agroup = NULL;
-char *codec_str_ptr = NULL;
-int stream_bitrate = os->muxer_overhead;
-if (os->bit_rate > 0)
-stream_bitrate += os->bit_rate;
-else if (final)
-stream_bitrate += os->pos * 8 * AV_TIME_BASE / 
c->total_duration;

-else if (os->first_segment_bit_rate > 0)
-stream_bitrate += os->first_segment_bit_rate;
-if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
-continue;
-if (os->segment_type != SEGMENT_TYPE_MP4)
-continue;
-av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
-if (max_audio_bitrate) {
-agroup = (char *)audio_group;
-stream_bitrate += max_audio_bitrate;
-av_strlcat(codec_str, ",", sizeof(codec_str));
-av_strlcat(codec_str, audio_codec_str, sizeof(codec_str));
+for (i = 0; i < s->nb_streams; i++) {
+char playlist_file[64];
+char codec_str[128];
+AVStream *st = s->streams[i];
+OutputStream *os = >streams[i];
+char *agroup = NULL;
+

Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest

2020-06-21 Thread Przemysław Sobala
On Wed, Jun 17, 2020 at 1:58 PM Jeyapal, Karthick 
wrote:

>
> On 6/17/20 5:20 PM, Przemysław Sobala wrote:
> > If stream's bitrate is not specified:
> > - for static manifest: an average bitrate will be calculated and used,
> > - for dynamic manifest: first segment's bitrate will be calculated and
> used, as before,
> > for bandwidth setting in adaptation sets.
> > ---
> >  libavformat/dashenc.c | 24 
> >  1 file changed, 16 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> > index 05deb5c1b5..62193058d7 100644
> > --- a/libavformat/dashenc.c
> > +++ b/libavformat/dashenc.c
> > @@ -115,6 +115,7 @@ typedef struct OutputStream {
> >  int64_t last_dts, last_pts;
> >  int last_flags;
> >  int bit_rate;
> > +int first_segment_bit_rate;
> >  SegmentType segment_type;  /* segment type selected for this
> particular stream */
> >  const char *format_name;
> >  const char *extension_name;
> > @@ -840,8 +841,12 @@ static int write_adaptation_set(AVFormatContext *s,
> AVIOContext *out, int as_ind
> >  continue;
> >
> >  if (os->bit_rate > 0)
> > -snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"",
> > - os->bit_rate);
> > +snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"", os->bit_rate);
> > +else if (final) {
> > +int average_bit_rate = os->pos * 8 * AV_TIME_BASE /
> c->total_duration;
> > +snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"", average_bit_rate);
> > +} else if (os->first_segment_bit_rate > 0)
> > +snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"", os->first_segment_bit_rate);
> >
> >  if (as->media_type == AVMEDIA_TYPE_VIDEO) {
> >  avio_printf(out, "\t\t\t mimeType=\"video/%s\" codecs=\"%s\"%s width=\"%d\" height=\"%d\"",
> > @@ -1305,7 +1310,13 @@ static int write_manifest(AVFormatContext *s, int
> final)
> >  OutputStream *os = >streams[i];
> >  char *agroup = NULL;
> >  char *codec_str_ptr = NULL;
> > -int stream_bitrate = st->codecpar->bit_rate +
> os->muxer_overhead;
> > +int stream_bitrate = os->muxer_overhead;
> > +if (os->bit_rate > 0)
> > +stream_bitrate += os->bit_rate;
> > +else if (final)
> > +stream_bitrate += os->pos * 8 * AV_TIME_BASE /
> c->total_duration;
> > +else if (os->first_segment_bit_rate > 0)
> > +stream_bitrate += os->first_segment_bit_rate;
> >  if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
> >  continue;
> >  if (os->segment_type != SEGMENT_TYPE_MP4)
> > @@ -1958,11 +1969,8 @@ static int dash_flush(AVFormatContext *s, int
> final, int stream)
> >  os->total_pkt_size = 0;
> >  os->total_pkt_duration = 0;
> >
> > -if (!os->bit_rate) {
> > -// calculate average bitrate of first segment
> > -int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE
> / duration;
> > -    if (bitrate >= 0)
> > -os->bit_rate = bitrate;
> > +if (!os->bit_rate && !os->first_segment_bit_rate) {
> > +os->first_segment_bit_rate = (int64_t) range_length * 8 *
> AV_TIME_BASE / duration;
> >  }
> >  add_segment(os, os->filename, os->start_pts, os->max_pts -
> os->start_pts, os->pos, range_length, index_length, next_exp_index);
> >  av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d
> written to: %s\n", i, os->segment_index, os->full_path);
> LGTM. Thanks.
>

Can it be merged then (along with [PATCH 1/2])?

--
regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest

2020-06-17 Thread Przemysław Sobala
If stream's bitrate is not specified:
- for static manifest: an average bitrate will be calculated and used,
- for dynamic manifest: first segment's bitrate will be calculated and used, as 
before,
for bandwidth setting in adaptation sets.
---
 libavformat/dashenc.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 05deb5c1b5..62193058d7 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -115,6 +115,7 @@ typedef struct OutputStream {
 int64_t last_dts, last_pts;
 int last_flags;
 int bit_rate;
+int first_segment_bit_rate;
 SegmentType segment_type;  /* segment type selected for this particular 
stream */
 const char *format_name;
 const char *extension_name;
@@ -840,8 +841,12 @@ static int write_adaptation_set(AVFormatContext *s, 
AVIOContext *out, int as_ind
 continue;
 
 if (os->bit_rate > 0)
-snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"",
- os->bit_rate);
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->bit_rate);
+else if (final) {
+int average_bit_rate = os->pos * 8 * AV_TIME_BASE / 
c->total_duration;
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", average_bit_rate);
+} else if (os->first_segment_bit_rate > 0)
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->first_segment_bit_rate);
 
 if (as->media_type == AVMEDIA_TYPE_VIDEO) {
 avio_printf(out, "\t\t\tstreams[i];
 char *agroup = NULL;
 char *codec_str_ptr = NULL;
-int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
+int stream_bitrate = os->muxer_overhead;
+if (os->bit_rate > 0)
+stream_bitrate += os->bit_rate;
+else if (final)
+stream_bitrate += os->pos * 8 * AV_TIME_BASE / 
c->total_duration;
+else if (os->first_segment_bit_rate > 0)
+stream_bitrate += os->first_segment_bit_rate;
 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 continue;
 if (os->segment_type != SEGMENT_TYPE_MP4)
@@ -1958,11 +1969,8 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 os->total_pkt_size = 0;
 os->total_pkt_duration = 0;
 
-if (!os->bit_rate) {
-// calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
-if (bitrate >= 0)
-os->bit_rate = bitrate;
+if (!os->bit_rate && !os->first_segment_bit_rate) {
+os->first_segment_bit_rate = (int64_t) range_length * 8 * 
AV_TIME_BASE / duration;
 }
 add_segment(os, os->filename, os->start_pts, os->max_pts - 
os->start_pts, os->pos, range_length, index_length, next_exp_index);
 av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written 
to: %s\n", i, os->segment_index, os->full_path);
-- 
2.25.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest

2020-06-17 Thread Przemysław Sobala
If stream's bitrate is not specified:
- for static manifest: an average bitrate will be calculated and used,
- for dynamic manifest: first segment's bitrate will be calculated and used, as 
before,
for bandwidth setting in adaptation sets.
---
 libavformat/dashenc.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 05deb5c1b5..20edc9779c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -115,6 +115,7 @@ typedef struct OutputStream {
 int64_t last_dts, last_pts;
 int last_flags;
 int bit_rate;
+int first_segment_bit_rate;
 SegmentType segment_type;  /* segment type selected for this particular 
stream */
 const char *format_name;
 const char *extension_name;
@@ -840,8 +841,12 @@ static int write_adaptation_set(AVFormatContext *s, 
AVIOContext *out, int as_ind
 continue;
 
 if (os->bit_rate > 0)
-snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"",
- os->bit_rate);
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->bit_rate);
+else if (final) {
+int average_bit_rate = os->pos * 8 * AV_TIME_BASE / 
c->total_duration;
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", average_bit_rate);
+} else if (os->first_segment_bit_rate > 0)
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->first_segment_bit_rate);
 
 if (as->media_type == AVMEDIA_TYPE_VIDEO) {
 avio_printf(out, "\t\t\tstreams[i];
 char *agroup = NULL;
 char *codec_str_ptr = NULL;
-int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
+int stream_bitrate = os->muxer_overhead;
+if (os->bit_rate > 0)
+stream_bitrate += os->bit_rate;
+else if (final)
+stream_bitrate += os->pos * 8 * AV_TIME_BASE / 
c->total_duration;
+else if (os->first_segment_bit_rate > 0)
+stream_bitrate += os->first_segment_bit_rate;
 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 continue;
 if (os->segment_type != SEGMENT_TYPE_MP4)
@@ -1959,10 +1970,10 @@ static int dash_flush(AVFormatContext *s, int final, 
int stream)
 os->total_pkt_duration = 0;
 
 if (!os->bit_rate) {
-// calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
-if (bitrate >= 0)
-os->bit_rate = bitrate;
+// calculate average bitrate
+int64_t segment_bitrate = (int64_t) range_length * 8 * 
AV_TIME_BASE / duration;
+if (!os->first_segment_bit_rate && segment_bitrate)
+os->first_segment_bit_rate = segment_bitrate;
 }
 add_segment(os, os->filename, os->start_pts, os->max_pts - 
os->start_pts, os->pos, range_length, index_length, next_exp_index);
 av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written 
to: %s\n", i, os->segment_index, os->full_path);
-- 
2.25.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest

2020-06-16 Thread Przemysław Sobala
>
> +av_log(s, AV_LOG_INFO, "segment_bitrate: %"PRId64",
> os->first_segment_bit_rate: %i, os->average_bit_rate: %f\n",
> +segment_bitrate, os->first_segment_bit_rate,
> os->average_bit_rate);
>

Just found this redundant av_log. Will fix if the overall solution is
accepted.

--
regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] Revert "avformat/dashenc: use AVStream timebase when computing missing bitrate"

2020-06-16 Thread Przemysław Sobala
This reverts commit 2a9ffd89fcb09bd69b2130da039ad2caba79cf33 as duration is 
always in AV_TIME_BASE units
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3e587acdff..05deb5c1b5 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1960,7 +1960,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 
 if (!os->bit_rate) {
 // calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * (c->use_timeline ? 
os->ctx->streams[0]->time_base.den : AV_TIME_BASE) / duration;
+int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
 if (bitrate >= 0)
 os->bit_rate = bitrate;
 }
-- 
2.25.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest

2020-06-16 Thread Przemysław Sobala
If stream's bitrate is not specified:
- for static manifest: an average bitrate will be calculated and used,
- for dynamic manifest: first segment's bitrate will be calculated and used, as 
before,
for bandwidth setting in adaptation sets.

For dynamic manifest
---
 libavformat/dashenc.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 05deb5c1b5..6e1a6dbf3a 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -115,6 +115,8 @@ typedef struct OutputStream {
 int64_t last_dts, last_pts;
 int last_flags;
 int bit_rate;
+int first_segment_bit_rate;
+double average_bit_rate;
 SegmentType segment_type;  /* segment type selected for this particular 
stream */
 const char *format_name;
 const char *extension_name;
@@ -840,8 +842,11 @@ static int write_adaptation_set(AVFormatContext *s, 
AVIOContext *out, int as_ind
 continue;
 
 if (os->bit_rate > 0)
-snprintf(bandwidth_str, sizeof(bandwidth_str), " bandwidth=\"%d\"",
- os->bit_rate);
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->bit_rate);
+else if (final && os->average_bit_rate > 0)
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", (int) os->average_bit_rate);
+else if (os->first_segment_bit_rate > 0)
+snprintf(bandwidth_str, sizeof(bandwidth_str), " 
bandwidth=\"%d\"", os->first_segment_bit_rate);
 
 if (as->media_type == AVMEDIA_TYPE_VIDEO) {
 avio_printf(out, "\t\t\tstreams[i];
 char *agroup = NULL;
 char *codec_str_ptr = NULL;
-int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
+int stream_bitrate = os->muxer_overhead;
+if (os->bit_rate > 0)
+stream_bitrate += os->bit_rate;
+else if (final && os->average_bit_rate > 0)
+stream_bitrate += os->average_bit_rate;
+else if (os->first_segment_bit_rate > 0)
+stream_bitrate += os->first_segment_bit_rate;
 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 continue;
 if (os->segment_type != SEGMENT_TYPE_MP4)
@@ -1959,10 +1970,13 @@ static int dash_flush(AVFormatContext *s, int final, 
int stream)
 os->total_pkt_duration = 0;
 
 if (!os->bit_rate) {
-// calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
-if (bitrate >= 0)
-os->bit_rate = bitrate;
+// calculate average bitrate
+int64_t segment_bitrate = (int64_t) range_length * 8 * 
AV_TIME_BASE / duration;
+if (!os->first_segment_bit_rate)
+os->first_segment_bit_rate = segment_bitrate;
+os->average_bit_rate = (os->average_bit_rate * (os->segment_index 
- 1) + segment_bitrate) / os->segment_index;
+av_log(s, AV_LOG_INFO, "segment_bitrate: %"PRId64", 
os->first_segment_bit_rate: %i, os->average_bit_rate: %f\n",
+segment_bitrate, os->first_segment_bit_rate, 
os->average_bit_rate);
 }
 add_segment(os, os->filename, os->start_pts, os->max_pts - 
os->start_pts, os->pos, range_length, index_length, next_exp_index);
 av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written 
to: %s\n", i, os->segment_index, os->full_path);
-- 
2.25.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: Add hls_master_name option

2020-06-14 Thread Przemysław Sobala
Any comments about that?

--
Best regards
Przemysław Sobala

On Wed, Jun 10, 2020 at 1:15 PM Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> ---
>  doc/muxers.texi   | 4 +++-
>  libavformat/dashenc.c | 8 +---
>  2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index d6f9de3702..b1389a3227 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -267,8 +267,10 @@ Override User-Agent field in HTTP header. Applicable
> only for HTTP output.
>  @item http_persistent @var{http_persistent}
>  Use persistent HTTP connections. Applicable only for HTTP output.
>  @item hls_playlist @var{hls_playlist}
> -Generate HLS playlist files as well. The master playlist is generated
> with the filename master.m3u8.
> +Generate HLS playlist files as well. The master playlist is generated
> with the filename @var{hls_master_name}.
>  One media playlist file is generated for each stream with filenames
> media_0.m3u8, media_1.m3u8, etc.
> +@item hls_master_name @var{file_name}
> +HLS master playlist name. Default is "master.m3u8".
>  @item streaming @var{streaming}
>  Enable (1) or disable (0) chunk streaming mode of output. In chunk
> streaming
>  mode, each frame will be a moof fragment which forms a chunk.
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 00a37b175d..3e587acdff 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -171,6 +171,7 @@ typedef struct DASHContext {
>  const char *user_agent;
>  AVDictionary *http_opts;
>  int hls_playlist;
> +const char *hls_master_name;
>  int http_persistent;
>  int master_playlist_created;
>  AVIOContext *mpd_out;
> @@ -1261,9 +1262,9 @@ static int write_manifest(AVFormatContext *s, int
> final)
>  return 0;
>
>  if (*c->dirname)
> -snprintf(filename_hls, sizeof(filename_hls), "%smaster.m3u8",
> c->dirname);
> +snprintf(filename_hls, sizeof(filename_hls), "%s%s",
> c->dirname, c->hls_master_name);
>  else
> -snprintf(filename_hls, sizeof(filename_hls), "master.m3u8");
> +snprintf(filename_hls, sizeof(filename_hls), "%s",
> c->hls_master_name);
>
>  snprintf(temp_filename, sizeof(temp_filename), use_rename ?
> "%s.tmp" : "%s", filename_hls);
>
> @@ -2292,7 +2293,7 @@ static int dash_write_trailer(AVFormatContext *s)
>
>  if (c->hls_playlist && c->master_playlist_created) {
>  char filename[1024];
> -snprintf(filename, sizeof(filename), "%smaster.m3u8",
> c->dirname);
> +snprintf(filename, sizeof(filename), "%s%s", c->dirname,
> c->hls_master_name);
>  dashenc_delete_file(s, filename);
>  }
>  }
> @@ -2349,6 +2350,7 @@ static const AVOption options[] = {
>  { "http_user_agent", "override User-Agent field in HTTP header",
> OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
>  { "http_persistent", "Use persistent HTTP connections",
> OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
>  { "hls_playlist", "Generate HLS playlist files(master.m3u8,
> media_%d.m3u8)", OFFSET(hls_playlist), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0,
> 1, E },
> +{ "hls_master_name", "HLS master playlist name",
> OFFSET(hls_master_name), AV_OPT_TYPE_STRING, {.str = "master.m3u8"}, 0, 0,
> E },
>  { "streaming", "Enable/Disable streaming mode of output. Each frame
> will be moof fragment", OFFSET(streaming), AV_OPT_TYPE_BOOL, { .i64 = 0 },
> 0, 1, E },
>  { "timeout", "set timeout for socket I/O operations",
> OFFSET(timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags =
> E },
>  { "index_correction", "Enable/Disable segment index correction
> logic", OFFSET(index_correction), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
> --
> 2.25.4
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/dashenc: Add hls_master_name option

2020-06-10 Thread Przemysław Sobala
---
 doc/muxers.texi   | 4 +++-
 libavformat/dashenc.c | 8 +---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index d6f9de3702..b1389a3227 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -267,8 +267,10 @@ Override User-Agent field in HTTP header. Applicable only 
for HTTP output.
 @item http_persistent @var{http_persistent}
 Use persistent HTTP connections. Applicable only for HTTP output.
 @item hls_playlist @var{hls_playlist}
-Generate HLS playlist files as well. The master playlist is generated with the 
filename master.m3u8.
+Generate HLS playlist files as well. The master playlist is generated with the 
filename @var{hls_master_name}.
 One media playlist file is generated for each stream with filenames 
media_0.m3u8, media_1.m3u8, etc.
+@item hls_master_name @var{file_name}
+HLS master playlist name. Default is "master.m3u8".
 @item streaming @var{streaming}
 Enable (1) or disable (0) chunk streaming mode of output. In chunk streaming
 mode, each frame will be a moof fragment which forms a chunk.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 00a37b175d..3e587acdff 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -171,6 +171,7 @@ typedef struct DASHContext {
 const char *user_agent;
 AVDictionary *http_opts;
 int hls_playlist;
+const char *hls_master_name;
 int http_persistent;
 int master_playlist_created;
 AVIOContext *mpd_out;
@@ -1261,9 +1262,9 @@ static int write_manifest(AVFormatContext *s, int final)
 return 0;
 
 if (*c->dirname)
-snprintf(filename_hls, sizeof(filename_hls), "%smaster.m3u8", 
c->dirname);
+snprintf(filename_hls, sizeof(filename_hls), "%s%s", c->dirname, 
c->hls_master_name);
 else
-snprintf(filename_hls, sizeof(filename_hls), "master.m3u8");
+snprintf(filename_hls, sizeof(filename_hls), "%s", 
c->hls_master_name);
 
 snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : 
"%s", filename_hls);
 
@@ -2292,7 +2293,7 @@ static int dash_write_trailer(AVFormatContext *s)
 
 if (c->hls_playlist && c->master_playlist_created) {
 char filename[1024];
-snprintf(filename, sizeof(filename), "%smaster.m3u8", c->dirname);
+snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
c->hls_master_name);
 dashenc_delete_file(s, filename);
 }
 }
@@ -2349,6 +2350,7 @@ static const AVOption options[] = {
 { "http_user_agent", "override User-Agent field in HTTP header", 
OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
 { "http_persistent", "Use persistent HTTP connections", 
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 { "hls_playlist", "Generate HLS playlist files(master.m3u8, 
media_%d.m3u8)", OFFSET(hls_playlist), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E 
},
+{ "hls_master_name", "HLS master playlist name", OFFSET(hls_master_name), 
AV_OPT_TYPE_STRING, {.str = "master.m3u8"}, 0, 0, E },
 { "streaming", "Enable/Disable streaming mode of output. Each frame will 
be moof fragment", OFFSET(streaming), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { "timeout", "set timeout for socket I/O operations", OFFSET(timeout), 
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E },
 { "index_correction", "Enable/Disable segment index correction logic", 
OFFSET(index_correction), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
-- 
2.25.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-06-08 Thread Przemysław Sobala
On Thu, Jun 4, 2020 at 3:13 PM Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> On Thu, Jun 4, 2020 at 11:24 AM Jeyapal, Karthick 
> wrote:
>
>>
>> On 6/4/20 1:29 PM, Przemysław Sobala wrote:
>> > On Tue, Jun 2, 2020 at 10:19 AM Przemysław Sobala <
>> > przemyslaw.sob...@gmail.com> wrote:
>> >
>> >> On Mon, Jun 1, 2020 at 3:30 PM Jeyapal, Karthick 
>> >> wrote:
>> >>
>> >>>
>> >>> On 6/1/20 5:24 PM, Przemysław Sobala wrote:
>> >>>> On Mon, Jun 1, 2020 at 10:06 AM Anton Khirnov 
>> >>> wrote:
>> >>>>
>> >>>>> Quoting Przemysław Sobala (2020-05-27 17:07:22)
>> >>>>>> ---
>> >>>>>>  libavformat/dashenc.c | 2 +-
>> >>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>>>>
>> >>>>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> >>>>>> index 0cf0df50ef..00a37b175d 100644
>> >>>>>> --- a/libavformat/dashenc.c
>> >>>>>> +++ b/libavformat/dashenc.c
>> >>>>>> @@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int
>> >>>>> final, int stream)
>> >>>>>>
>> >>>>>>  if (!os->bit_rate) {
>> >>>>>>  // calculate average bitrate of first segment
>> >>>>>> -int64_t bitrate = (int64_t) range_length * 8 *
>> >>> AV_TIME_BASE
>> >>>>> / duration;
>> >>>>>> +int64_t bitrate = (int64_t) range_length * 8 *
>> >>>>> (c->use_timeline ? os->ctx->streams[0]->time_base.den :
>> AV_TIME_BASE) /
>> >>>>> duration;
>> >>>>>
>> >>>>> That does not look like an AVCodecContext
>> >>>>>
>> >>>>
>> >>>> Of course not. time_base is AVStream's field. I don't know why I
>> wrote
>> >>>> AVCodecContext... Please amend that commit message if possible.
>> >>> Amended and Pushed!
>> >>>
>> >>> Thanks,
>> >>> Karthick
>> >>>
>> >>>
>> >> Thanks.
>> >> What do you think about computing an average bitrate for all segments,
>> not
>> >> only the first one (in case of a static - not dynamic - DASH
>> manifest), if
>> >> one would not want to specify bitrate while encoding using x264 CRF
>> rate
>> >> control? I could prepare such a patch that, if bitrate is not
>> specified,
>> >> it'd be computed at the end, for static manifest, for all segments.
>> It'd be
>> >> more accurate comparing to the first segment's bitrate.
>> >>
>> >
>> > Any comments about that?
>> Any patch that fixes/improves the current behavior is always welcome :)
>>
>
> I was thinking about something like (diff against release/4.2 branch):
>
>
> $ git diff origin/release/4.2 -- libavformat/dashenc.c
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index f0e45da89ad..60250b6d33a 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -88,6 +88,7 @@ typedef struct OutputStream {
>  int64_t first_pts, start_pts, max_pts;
>  int64_t last_dts, last_pts;
>  int bit_rate;
> +double average_bit_rate;
>  SegmentType segment_type;  /* segment type selected for this
> particular stream */
>  const char *format_name;
>  const char *extension_name;
> @@ -775,6 +776,9 @@ static int write_adaptation_set(AVFormatContext *s,
> AVIOContext *out, int as_ind
>  if (os->bit_rate > 0)
>  snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"",
>   os->bit_rate);
> +else if (final)
> +snprintf(bandwidth_str, sizeof(bandwidth_str), "
> bandwidth=\"%d\"",
> + (int) os->average_bit_rate);
>
>  if (as->media_type == AVMEDIA_TYPE_VIDEO) {
>  AVStream *st = s->streams[i];
> @@ -1618,12 +1622,10 @@ static int dash_flush(AVFormatContext *s, int
> final, int stream)
>  os->total_pkt_size = 0;
>
>  if (!os->bit_rate) {
> -// calculate average bitrate of first segment
> -int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE /
> 

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-06-04 Thread Przemysław Sobala
On Thu, Jun 4, 2020 at 11:24 AM Jeyapal, Karthick 
wrote:

>
> On 6/4/20 1:29 PM, Przemysław Sobala wrote:
> > On Tue, Jun 2, 2020 at 10:19 AM Przemysław Sobala <
> > przemyslaw.sob...@gmail.com> wrote:
> >
> >> On Mon, Jun 1, 2020 at 3:30 PM Jeyapal, Karthick 
> >> wrote:
> >>
> >>>
> >>> On 6/1/20 5:24 PM, Przemysław Sobala wrote:
> >>>> On Mon, Jun 1, 2020 at 10:06 AM Anton Khirnov 
> >>> wrote:
> >>>>
> >>>>> Quoting Przemysław Sobala (2020-05-27 17:07:22)
> >>>>>> ---
> >>>>>>  libavformat/dashenc.c | 2 +-
> >>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>>
> >>>>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> >>>>>> index 0cf0df50ef..00a37b175d 100644
> >>>>>> --- a/libavformat/dashenc.c
> >>>>>> +++ b/libavformat/dashenc.c
> >>>>>> @@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int
> >>>>> final, int stream)
> >>>>>>
> >>>>>>  if (!os->bit_rate) {
> >>>>>>  // calculate average bitrate of first segment
> >>>>>> -int64_t bitrate = (int64_t) range_length * 8 *
> >>> AV_TIME_BASE
> >>>>> / duration;
> >>>>>> +int64_t bitrate = (int64_t) range_length * 8 *
> >>>>> (c->use_timeline ? os->ctx->streams[0]->time_base.den :
> AV_TIME_BASE) /
> >>>>> duration;
> >>>>>
> >>>>> That does not look like an AVCodecContext
> >>>>>
> >>>>
> >>>> Of course not. time_base is AVStream's field. I don't know why I wrote
> >>>> AVCodecContext... Please amend that commit message if possible.
> >>> Amended and Pushed!
> >>>
> >>> Thanks,
> >>> Karthick
> >>>
> >>>
> >> Thanks.
> >> What do you think about computing an average bitrate for all segments,
> not
> >> only the first one (in case of a static - not dynamic - DASH manifest),
> if
> >> one would not want to specify bitrate while encoding using x264 CRF rate
> >> control? I could prepare such a patch that, if bitrate is not specified,
> >> it'd be computed at the end, for static manifest, for all segments.
> It'd be
> >> more accurate comparing to the first segment's bitrate.
> >>
> >
> > Any comments about that?
> Any patch that fixes/improves the current behavior is always welcome :)
>

I was thinking about something like (diff against release/4.2 branch):


$ git diff origin/release/4.2 -- libavformat/dashenc.c
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index f0e45da89ad..60250b6d33a 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -88,6 +88,7 @@ typedef struct OutputStream {
 int64_t first_pts, start_pts, max_pts;
 int64_t last_dts, last_pts;
 int bit_rate;
+double average_bit_rate;
 SegmentType segment_type;  /* segment type selected for this
particular stream */
 const char *format_name;
 const char *extension_name;
@@ -775,6 +776,9 @@ static int write_adaptation_set(AVFormatContext *s,
AVIOContext *out, int as_ind
 if (os->bit_rate > 0)
 snprintf(bandwidth_str, sizeof(bandwidth_str), "
bandwidth=\"%d\"",
  os->bit_rate);
+else if (final)
+snprintf(bandwidth_str, sizeof(bandwidth_str), "
bandwidth=\"%d\"",
+ (int) os->average_bit_rate);

 if (as->media_type == AVMEDIA_TYPE_VIDEO) {
 AVStream *st = s->streams[i];
@@ -1618,12 +1622,10 @@ static int dash_flush(AVFormatContext *s, int
final, int stream)
 os->total_pkt_size = 0;

 if (!os->bit_rate) {
-// calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE /
av_rescale_q(os->max_pts - os->start_pts,
-
st->time_base,
-
AV_TIME_BASE_Q);
-if (bitrate >= 0)
-os->bit_rate = bitrate;
+// calculate average bitrate
+int64_t duration = av_rescale_q(os->max_pts - os->start_pts,
st->time_base, AV_TIME_BASE_Q);
+int64_t segment_bitrate = (int64_t) range_length * 8 *
AV_TIME_BASE / duration;
+os->average_bit_rate = (os->average_bit_rate *
(os->segment_index - 1) + segment_bitrate) / os->segment_inde

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-06-04 Thread Przemysław Sobala
On Tue, Jun 2, 2020 at 10:19 AM Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> On Mon, Jun 1, 2020 at 3:30 PM Jeyapal, Karthick 
> wrote:
>
>>
>> On 6/1/20 5:24 PM, Przemysław Sobala wrote:
>> > On Mon, Jun 1, 2020 at 10:06 AM Anton Khirnov 
>> wrote:
>> >
>> >> Quoting Przemysław Sobala (2020-05-27 17:07:22)
>> >>> ---
>> >>>  libavformat/dashenc.c | 2 +-
>> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> >>> index 0cf0df50ef..00a37b175d 100644
>> >>> --- a/libavformat/dashenc.c
>> >>> +++ b/libavformat/dashenc.c
>> >>> @@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int
>> >> final, int stream)
>> >>>
>> >>>  if (!os->bit_rate) {
>> >>>  // calculate average bitrate of first segment
>> >>> -int64_t bitrate = (int64_t) range_length * 8 *
>> AV_TIME_BASE
>> >> / duration;
>> >>> +int64_t bitrate = (int64_t) range_length * 8 *
>> >> (c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE) /
>> >> duration;
>> >>
>> >> That does not look like an AVCodecContext
>> >>
>> >
>> > Of course not. time_base is AVStream's field. I don't know why I wrote
>> > AVCodecContext... Please amend that commit message if possible.
>> Amended and Pushed!
>>
>> Thanks,
>> Karthick
>>
>>
> Thanks.
> What do you think about computing an average bitrate for all segments, not
> only the first one (in case of a static - not dynamic - DASH manifest), if
> one would not want to specify bitrate while encoding using x264 CRF rate
> control? I could prepare such a patch that, if bitrate is not specified,
> it'd be computed at the end, for static manifest, for all segments. It'd be
> more accurate comparing to the first segment's bitrate.
>

Any comments about that?

--
pozdrawiam
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-06-02 Thread Przemysław Sobala
On Mon, Jun 1, 2020 at 3:30 PM Jeyapal, Karthick 
wrote:

>
> On 6/1/20 5:24 PM, Przemysław Sobala wrote:
> > On Mon, Jun 1, 2020 at 10:06 AM Anton Khirnov  wrote:
> >
> >> Quoting Przemysław Sobala (2020-05-27 17:07:22)
> >>> ---
> >>>  libavformat/dashenc.c | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> >>> index 0cf0df50ef..00a37b175d 100644
> >>> --- a/libavformat/dashenc.c
> >>> +++ b/libavformat/dashenc.c
> >>> @@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int
> >> final, int stream)
> >>>
> >>>  if (!os->bit_rate) {
> >>>  // calculate average bitrate of first segment
> >>> -int64_t bitrate = (int64_t) range_length * 8 *
> AV_TIME_BASE
> >> / duration;
> >>> +int64_t bitrate = (int64_t) range_length * 8 *
> >> (c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE) /
> >> duration;
> >>
> >> That does not look like an AVCodecContext
> >>
> >
> > Of course not. time_base is AVStream's field. I don't know why I wrote
> > AVCodecContext... Please amend that commit message if possible.
> Amended and Pushed!
>
> Thanks,
> Karthick
>
>
Thanks.
What do you think about computing an average bitrate for all segments, not
only the first one (in case of a static - not dynamic - DASH manifest), if
one would not want to specify bitrate while encoding using x264 CRF rate
control? I could prepare such a patch that, if bitrate is not specified,
it'd be computed at the end, for static manifest, for all segments. It'd be
more accurate comparing to the first segment's bitrate.

--
Regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-06-01 Thread Przemysław Sobala
On Mon, Jun 1, 2020 at 10:06 AM Anton Khirnov  wrote:

> Quoting Przemysław Sobala (2020-05-27 17:07:22)
> > ---
> >  libavformat/dashenc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> > index 0cf0df50ef..00a37b175d 100644
> > --- a/libavformat/dashenc.c
> > +++ b/libavformat/dashenc.c
> > @@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int
> final, int stream)
> >
> >  if (!os->bit_rate) {
> >  // calculate average bitrate of first segment
> > -int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE
> / duration;
> > +int64_t bitrate = (int64_t) range_length * 8 *
> (c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE) /
> duration;
>
> That does not look like an AVCodecContext
>

Of course not. time_base is AVStream's field. I don't know why I wrote
AVCodecContext... Please amend that commit message if possible.

--
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/dashenc: use AVCodecContext timebase when computing missing bitrate

2020-05-27 Thread Przemysław Sobala
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 0cf0df50ef..00a37b175d 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1959,7 +1959,7 @@ static int dash_flush(AVFormatContext *s, int final, int 
stream)
 
 if (!os->bit_rate) {
 // calculate average bitrate of first segment
-int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / 
duration;
+int64_t bitrate = (int64_t) range_length * 8 * (c->use_timeline ? 
os->ctx->streams[0]->time_base.den : AV_TIME_BASE) / duration;
 if (bitrate >= 0)
 os->bit_rate = bitrate;
 }
-- 
2.25.2

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-03-10 Thread Przemysław Sobala
On Wed, Mar 8, 2017 at 9:27 AM, Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> On Fri, Mar 3, 2017 at 9:38 AM, Przemysław Sobala <
> przemyslaw.sob...@gmail.com> wrote:
>
>> From: Przemysław Sobala <przemyslaw.sob...@gmail.com>
>>
>> Provides a way to change bandwidth parameter inside DASH manifest after a
>> non-CBR H.264 encoding.
>> Caller now is able to compute the bitrate by itself, after all packets
>> have been written, and then set that value in 
>> AVFormatContext->streams->codecpar->bit_rate
>> before calling av_write_trailer. As a result that value will be set in DASH
>> manifest.
>> ---
>>  libavformat/dashenc.c | 42 ++
>>  1 file changed, 30 insertions(+), 12 deletions(-)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index fa56505..011d2ea 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int
>> final)
>>  return 0;
>>  }
>>
>> +static int set_bitrate(AVFormatContext *s)
>> +{
>> +DASHContext *c = s->priv_data;
>> +int i;
>> +
>> +for (i = 0; i < s->nb_streams; i++) {
>> +OutputStream *os = >streams[i];
>> +
>> +os->bit_rate = s->streams[i]->codecpar->bit_rate;
>> +if (os->bit_rate) {
>> +snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
>> + " bandwidth=\"%d\"", os->bit_rate);
>> +} else {
>> +int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT
>> ?
>> +AV_LOG_ERROR : AV_LOG_WARNING;
>> +av_log(s, level, "No bit rate set for stream %d\n", i);
>> +if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
>> +return AVERROR(EINVAL);
>> +}
>> +}
>> +
>> +return 0;
>> +}
>> +
>>  static int dash_init(AVFormatContext *s)
>>  {
>>  DASHContext *c = s->priv_data;
>> @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
>>  if (!c->streams)
>>  return AVERROR(ENOMEM);
>>
>> +ret = set_bitrate(s);
>> +if (ret < 0)
>> +return ret;
>> +
>>  for (i = 0; i < s->nb_streams; i++) {
>>  OutputStream *os = >streams[i];
>>  AVFormatContext *ctx;
>> @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
>>  AVDictionary *opts = NULL;
>>  char filename[1024];
>>
>> -os->bit_rate = s->streams[i]->codecpar->bit_rate;
>> -if (os->bit_rate) {
>> -snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
>> - " bandwidth=\"%d\"", os->bit_rate);
>> -} else {
>> -int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT
>> ?
>> -AV_LOG_ERROR : AV_LOG_WARNING;
>> -av_log(s, level, "No bit rate set for stream %d\n", i);
>> -if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
>> -        return AVERROR(EINVAL);
>> -}
>> -
>>  ctx = avformat_alloc_context();
>>  if (!ctx)
>>  return AVERROR(ENOMEM);
>> @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
>>  {
>>  DASHContext *c = s->priv_data;
>>
>> +set_bitrate(s);
>> +
>>  if (s->nb_streams > 0) {
>>  OutputStream *os = >streams[0];
>>  // If no segments have been written so far, try to do a crude
>> --
>> 2.7.4
>>
>>
> ping
>
>
ping, 7 days timeout
can anyone tak a look at this?
[
http://ffmpeg.org/developer.html#Always-wait-long-enough-before-pushing-changes
]

--
Regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-03-08 Thread Przemysław Sobala
On Fri, Mar 3, 2017 at 9:38 AM, Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> From: Przemysław Sobala <przemyslaw.sob...@gmail.com>
>
> Provides a way to change bandwidth parameter inside DASH manifest after a
> non-CBR H.264 encoding.
> Caller now is able to compute the bitrate by itself, after all packets
> have been written, and then set that value in 
> AVFormatContext->streams->codecpar->bit_rate
> before calling av_write_trailer. As a result that value will be set in DASH
> manifest.
> ---
>  libavformat/dashenc.c | 42 ++
>  1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index fa56505..011d2ea 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int
> final)
>  return 0;
>  }
>
> +static int set_bitrate(AVFormatContext *s)
> +{
> +DASHContext *c = s->priv_data;
> +int i;
> +
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +
> +os->bit_rate = s->streams[i]->codecpar->bit_rate;
> +if (os->bit_rate) {
> +snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> + " bandwidth=\"%d\"", os->bit_rate);
> +} else {
> +int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> +AV_LOG_ERROR : AV_LOG_WARNING;
> +av_log(s, level, "No bit rate set for stream %d\n", i);
> +if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> +return AVERROR(EINVAL);
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int dash_init(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
> @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
>  if (!c->streams)
>  return AVERROR(ENOMEM);
>
> +ret = set_bitrate(s);
> +if (ret < 0)
> +return ret;
> +
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  AVFormatContext *ctx;
> @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
>  AVDictionary *opts = NULL;
>  char filename[1024];
>
> -os->bit_rate = s->streams[i]->codecpar->bit_rate;
> -if (os->bit_rate) {
> -snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> - " bandwidth=\"%d\"", os->bit_rate);
> -} else {
> -int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> -AV_LOG_ERROR : AV_LOG_WARNING;
> -av_log(s, level, "No bit rate set for stream %d\n", i);
> -if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> -return AVERROR(EINVAL);
> -}
> -
>  ctx = avformat_alloc_context();
>  if (!ctx)
>  return AVERROR(ENOMEM);
> @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>
> +set_bitrate(s);
> +
>  if (s->nb_streams > 0) {
>  OutputStream *os = >streams[0];
>  // If no segments have been written so far, try to do a crude
> --
> 2.7.4
>
>
ping
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-03-03 Thread Przemysław Sobala
From: Przemysław Sobala <przemyslaw.sob...@gmail.com>

Provides a way to change bandwidth parameter inside DASH manifest after a 
non-CBR H.264 encoding.
Caller now is able to compute the bitrate by itself, after all packets have 
been written, and then set that value in 
AVFormatContext->streams->codecpar->bit_rate before calling av_write_trailer. 
As a result that value will be set in DASH manifest.
---
 libavformat/dashenc.c | 42 ++
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index fa56505..011d2ea 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int final)
 return 0;
 }
 
+static int set_bitrate(AVFormatContext *s)
+{
+DASHContext *c = s->priv_data;
+int i;
+
+for (i = 0; i < s->nb_streams; i++) {
+OutputStream *os = >streams[i];
+
+os->bit_rate = s->streams[i]->codecpar->bit_rate;
+if (os->bit_rate) {
+snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
+ " bandwidth=\"%d\"", os->bit_rate);
+} else {
+int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
+AV_LOG_ERROR : AV_LOG_WARNING;
+av_log(s, level, "No bit rate set for stream %d\n", i);
+if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
+return AVERROR(EINVAL);
+}
+}
+
+return 0;
+}
+
 static int dash_init(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
@@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
 if (!c->streams)
 return AVERROR(ENOMEM);
 
+ret = set_bitrate(s);
+if (ret < 0)
+return ret;
+
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
 AVFormatContext *ctx;
@@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
 AVDictionary *opts = NULL;
 char filename[1024];
 
-os->bit_rate = s->streams[i]->codecpar->bit_rate;
-if (os->bit_rate) {
-snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
- " bandwidth=\"%d\"", os->bit_rate);
-} else {
-int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
-AV_LOG_ERROR : AV_LOG_WARNING;
-av_log(s, level, "No bit rate set for stream %d\n", i);
-if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
-return AVERROR(EINVAL);
-}
-
 ctx = avformat_alloc_context();
 if (!ctx)
 return AVERROR(ENOMEM);
@@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
 
+set_bitrate(s);
+
 if (s->nb_streams > 0) {
 OutputStream *os = >streams[0];
 // If no segments have been written so far, try to do a crude
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-03-01 Thread Przemysław Sobala
23 lut 2017 21:39 "Przemysław Sobala" <przemyslaw.sob...@gmail.com>
napisał(a):

On Wednesday, February 22, 2017, Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> From: Przemysław Sobala <przemyslaw.sob...@gmail.com>
>
> Provides a way to change bandwidth (bitrate) parameter after CRF H.264
> encoding (details: http://ffmpeg.org/pipermail/li
> bav-user/2017-February/010141.html)
>
> Signed-off-by: Przemysław Sobala <przemyslaw.sob...@grupawp.pl>
> ---
>  libavformat/dashenc.c | 42 ++
>  1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index fa56505..011d2ea 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int
> final)
>  return 0;
>  }
>
> +static int set_bitrate(AVFormatContext *s)
> +{
> +DASHContext *c = s->priv_data;
> +int i;
> +
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +
> +os->bit_rate = s->streams[i]->codecpar->bit_rate;
> +if (os->bit_rate) {
> +snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> + " bandwidth=\"%d\"", os->bit_rate);
> +} else {
> +int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> +AV_LOG_ERROR : AV_LOG_WARNING;
> +av_log(s, level, "No bit rate set for stream %d\n", i);
> +if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> +return AVERROR(EINVAL);
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int dash_init(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
> @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
>  if (!c->streams)
>  return AVERROR(ENOMEM);
>
> +ret = set_bitrate(s);
> +if (ret < 0)
> +return ret;
> +
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  AVFormatContext *ctx;
> @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
>  AVDictionary *opts = NULL;
>  char filename[1024];
>
> -os->bit_rate = s->streams[i]->codecpar->bit_rate;
> -if (os->bit_rate) {
> -snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> - " bandwidth=\"%d\"", os->bit_rate);
> -} else {
> -int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> -AV_LOG_ERROR : AV_LOG_WARNING;
> -av_log(s, level, "No bit rate set for stream %d\n", i);
> -if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> -return AVERROR(EINVAL);
> -}
> -
>  ctx = avformat_alloc_context();
>  if (!ctx)
>      return AVERROR(ENOMEM);
> @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>
> +set_bitrate(s);
> +
>  if (s->nb_streams > 0) {
>  OutputStream *os = >streams[0];
>  // If no segments have been written so far, try to do a crude
> --
> 2.7.4
>
>
Any comment on this?

--
Best regards
Przemysław Sobala


ping?

--
Regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-02-23 Thread Przemysław Sobala
On Wednesday, February 22, 2017, Przemysław Sobala <
przemyslaw.sob...@gmail.com> wrote:

> From: Przemysław Sobala <przemyslaw.sob...@gmail.com <javascript:;>>
>
> Provides a way to change bandwidth (bitrate) parameter after CRF H.264
> encoding (details: http://ffmpeg.org/pipermail/libav-user/2017-February/
> 010141.html)
>
> Signed-off-by: Przemysław Sobala <przemyslaw.sob...@grupawp.pl
> <javascript:;>>
> ---
>  libavformat/dashenc.c | 42 ++
>  1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index fa56505..011d2ea 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int
> final)
>  return 0;
>  }
>
> +static int set_bitrate(AVFormatContext *s)
> +{
> +DASHContext *c = s->priv_data;
> +int i;
> +
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +
> +os->bit_rate = s->streams[i]->codecpar->bit_rate;
> +if (os->bit_rate) {
> +snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> + " bandwidth=\"%d\"", os->bit_rate);
> +} else {
> +int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> +AV_LOG_ERROR : AV_LOG_WARNING;
> +av_log(s, level, "No bit rate set for stream %d\n", i);
> +if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> +return AVERROR(EINVAL);
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int dash_init(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
> @@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
>  if (!c->streams)
>  return AVERROR(ENOMEM);
>
> +ret = set_bitrate(s);
> +if (ret < 0)
> +return ret;
> +
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  AVFormatContext *ctx;
> @@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
>  AVDictionary *opts = NULL;
>  char filename[1024];
>
> -os->bit_rate = s->streams[i]->codecpar->bit_rate;
> -if (os->bit_rate) {
> -snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
> - " bandwidth=\"%d\"", os->bit_rate);
> -} else {
> -int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
> -AV_LOG_ERROR : AV_LOG_WARNING;
> -av_log(s, level, "No bit rate set for stream %d\n", i);
> -if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
> -return AVERROR(EINVAL);
> -}
> -
>  ctx = avformat_alloc_context();
>  if (!ctx)
>  return AVERROR(ENOMEM);
> @@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
>
> +set_bitrate(s);
> +
>  if (s->nb_streams > 0) {
>  OutputStream *os = >streams[0];
>  // If no segments have been written so far, try to do a crude
> --
> 2.7.4
>
>
Any comment on this?

--
Best regards
Przemysław Sobala
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/dashenc: update bitrates on dash_write_trailer

2017-02-22 Thread Przemysław Sobala
From: Przemysław Sobala <przemyslaw.sob...@gmail.com>

Provides a way to change bandwidth (bitrate) parameter after CRF H.264 encoding 
(details: http://ffmpeg.org/pipermail/libav-user/2017-February/010141.html)

Signed-off-by: Przemysław Sobala <przemyslaw.sob...@grupawp.pl>
---
 libavformat/dashenc.c | 42 ++
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index fa56505..011d2ea 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -561,6 +561,30 @@ static int write_manifest(AVFormatContext *s, int final)
 return 0;
 }
 
+static int set_bitrate(AVFormatContext *s)
+{
+DASHContext *c = s->priv_data;
+int i;
+
+for (i = 0; i < s->nb_streams; i++) {
+OutputStream *os = >streams[i];
+
+os->bit_rate = s->streams[i]->codecpar->bit_rate;
+if (os->bit_rate) {
+snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
+ " bandwidth=\"%d\"", os->bit_rate);
+} else {
+int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
+AV_LOG_ERROR : AV_LOG_WARNING;
+av_log(s, level, "No bit rate set for stream %d\n", i);
+if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
+return AVERROR(EINVAL);
+}
+}
+
+return 0;
+}
+
 static int dash_init(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
@@ -597,6 +621,10 @@ static int dash_init(AVFormatContext *s)
 if (!c->streams)
 return AVERROR(ENOMEM);
 
+ret = set_bitrate(s);
+if (ret < 0)
+return ret;
+
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
 AVFormatContext *ctx;
@@ -604,18 +632,6 @@ static int dash_init(AVFormatContext *s)
 AVDictionary *opts = NULL;
 char filename[1024];
 
-os->bit_rate = s->streams[i]->codecpar->bit_rate;
-if (os->bit_rate) {
-snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
- " bandwidth=\"%d\"", os->bit_rate);
-} else {
-int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
-AV_LOG_ERROR : AV_LOG_WARNING;
-av_log(s, level, "No bit rate set for stream %d\n", i);
-if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
-return AVERROR(EINVAL);
-}
-
 ctx = avformat_alloc_context();
 if (!ctx)
 return AVERROR(ENOMEM);
@@ -981,6 +997,8 @@ static int dash_write_trailer(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
 
+set_bitrate(s);
+
 if (s->nb_streams > 0) {
 OutputStream *os = >streams[0];
 // If no segments have been written so far, try to do a crude
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_fps: set fps value boundaries

2016-05-09 Thread Przemysław Sobala

W dniu 09.05.2016 o 15:00, Michael Niedermayer pisze:

On Mon, May 09, 2016 at 11:17:23AM +0200, Przemysław Sobala wrote:

---
  libavfilter/vf_fps.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


applied

but there are many more that have AV_OPT_TYPE_VIDEO_RATE with 0,0

thx



Yes, I've noticed that.
It turns out that setting video rate by string via 'av_opt_set' does not
validate value boundaries while setting by AVRational via
av_opt_set_video_rate does.

--
Regards
Przemysław Sobala


Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 850,00 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. 
Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - 
Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavutil/opt: add writing AV_OPT_TYPE_VIDEO_RATE AVOption

2016-05-09 Thread Przemysław Sobala
---
 libavutil/opt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 70a68d9..e63bd8a 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -136,6 +136,7 @@ static int write_number(void *obj, const AVOption *o, void 
*dst, double num, int
 *(double*)dst = num * intnum / den;
 break;
 case AV_OPT_TYPE_RATIONAL:
+case AV_OPT_TYPE_VIDEO_RATE:
 if ((int) num == num)
 *(AVRational *)dst = (AVRational) { num *intnum, den };
 else
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH] avfilter/vf_fps: set fps value boundaries

2016-05-09 Thread Przemysław Sobala
---
 libavfilter/vf_fps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 0500e97..20ccd79 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -62,7 +62,7 @@ typedef struct FPSContext {
 #define V AV_OPT_FLAG_VIDEO_PARAM
 #define F AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption fps_options[] = {
-{ "fps", "A string describing desired output framerate", 
OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, .flags = V|F },
+{ "fps", "A string describing desired output framerate", 
OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, 0, INT_MAX, V|F },
 { "start_time", "Assume the first PTS should be this value.", 
OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX}, -DBL_MAX, DBL_MAX, V 
},
 { "round", "set rounding method for timestamps", OFFSET(rounding), 
AV_OPT_TYPE_INT, { .i64 = AV_ROUND_NEAR_INF }, 0, 5, V|F, "round" },
 { "zero", "round towards 0",  OFFSET(rounding), AV_OPT_TYPE_CONST, { 
.i64 = AV_ROUND_ZERO }, 0, 5, V|F, "round" },
-- 
1.8.3.1

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


[FFmpeg-devel] Error while setting fps filter value

2016-05-02 Thread Przemysław Sobala

Hello,
I'm writing here because no one has answered me on libav-user mailing list.

I'm trying to add the fps video filter to my filter chain.
I set the 'fps' option using:

av_opt_set_video_rate(fps_filter_ctx, "fps", (AVRational) {15,1},
AV_OPT_SEARCH_CHILDREN);

but after that I can see an error log entry:

[fps] Value 15.00 for parameter 'fps' out of range [0 - 0]

After using

av_opt_set(fps_filter_ctx, "fps", "15", AV_OPT_SEARCH_CHILDREN);

everything works fine but I'm not in favour of AVRational -> char[] ->
AVRational conversion

I've figured out, that there are two things missing:
1) 'fps' AVOption is missing minimum and maximum valid values (vf_fps.c)
- hence my "out of range" error, but even after adding those I got
"Invalid argument" error, because...
2) write_number function (opt.c) is missing a case for
"AV_OPT_TYPE_VIDEO_RATE"

I could create a patch if you agree with me, just tell me what fps
AVOption value boundaries to set?
--
Regards
Przemysław Sobala


Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 850,00 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. 
Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - 
Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Need help with transcoding example

2016-03-31 Thread Przemysław Sobala

Hello
   I've altered doc/examples/transcoding.c to encode using aac codec:

--- a/doc/examples/transcoding.c
+++ b/doc/examples/transcoding.c
@@ -114,7 +114,12 @@
 if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO
 || dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
 /* in this example, we choose transcoding to same codec */
+   if (dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+   encoder = avcodec_find_encoder_by_name("aac");
+   avcodec_get_context_defaults3(enc_ctx, encoder);
+   } else {
 encoder = avcodec_find_encoder(dec_ctx->codec_id);
+   }
 if (!encoder) {
 av_log(NULL, AV_LOG_FATAL, "Necessary encoder not
found\n");
 return AVERROR_INVALIDDATA;

And then transcoding fails as with:
[aac @ 0x28d5780] more samples than frame size (avcodec_encode_audio2)
Do I have to add some more filters to filter chain or use libswrresample
as in example transcode_aac.c?

Full output with DEBUG logging:
$ ./doc/examples/transcoding input.avi /tmp/tmp.avi
[file @ 0x27d2740] Setting default whitelist 'file'
[avi @ 0x27d2040] Format avi probed with size=2048 and score=100
[avi @ 0x27d28a0] use odml:1
[avi @ 0x27d2040] overriding sample_size
[avi @ 0x27d2040] Before avformat_find_stream_info() pos: 10030 bytes
read:118568 seeks:4
[avi @ 0x27d2040] All info found
[avi @ 0x27d2040] After avformat_find_stream_info() pos: 58896 bytes
read:151336 seeks:4 frames:2
detected 2 logical cores
Input #0, avi, from 'input.avi':
  Metadata:
encoder : Lavf52.64.2
  Duration: 00:00:10.00, start: 0.00, bitrate: 2704 kb/s
Stream #0:0, 1, 1/25: Video: mpeg4 (Simple Profile), 1 reference
frame (xvid / 0x64697678), yuv420p(left), 1024x576 [SAR 1:1 DAR 16:9],
1/25, 2372 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1, 1, 32/1225: Audio: mp3 (U[0][0][0] / 0x0055), 44100
Hz, stereo, s16p, 320 kb/s
[mpeg4 @ 0x27f74a0] intra_quant_bias = 0 inter_quant_bias = -64
Output #0, avi, to '/tmp/tmp.avi':
Stream #0:0, 0, 0/0: Video: mpeg4, 1 reference frame, yuv420p,
1024x576 [SAR 1:1 DAR 16:9], 1/25, q=2-31, 128 kb/s, 25 tbc
Stream #0:1, 0, 0/0: Audio: aac (LC), 44100 Hz, stereo, fltp, 128 kb/s
[file @ 0x29fad80] Setting default whitelist 'file'
[avi @ 0x27f6aa0] Using AVStream.codec.time_base as a timebase hint to
the muxer is deprecated. Set AVStream.time_base instead.
[avi @ 0x27f6aa0] Using AVStream.codec.time_base as a timebase hint to
the muxer is deprecated. Set AVStream.time_base instead.
[in @ 0x2a03e40] Setting 'video_size' to value '1024x576'
[in @ 0x2a03e40] Setting 'pix_fmt' to value '0'
[in @ 0x2a03e40] Setting 'time_base' to value '1/25'
[in @ 0x2a03e40] Setting 'pixel_aspect' to value '1/1'
[in @ 0x2a03e40] w:1024 h:576 pixfmt:yuv420p tb:1/25 fr:0/1 sar:1/1
sws_param:
[AVFilterGraph @ 0x2a03480] query_formats: 3 queried, 2 merged, 0
already done, 0 delayed
[in @ 0x2a06880] Setting 'time_base' to value '1/44100'
[in @ 0x2a06880] Setting 'sample_rate' to value '44100'
[in @ 0x2a06880] Setting 'sample_fmt' to value 's16p'
[in @ 0x2a06880] Setting 'channel_layout' to value '0x3'
[in @ 0x2a06880] tb:1/44100 samplefmt:s16p samplerate:44100 chlayout:0x3
[Parsed_anull_0 @ 0x2a079a0] auto-inserting filter 'auto-inserted
resampler 0' between the filter 'in' and the filter 'Parsed_anull_0'
[AVFilterGraph @ 0x2a05f00] query_formats: 3 queried, 3 merged, 3
already done, 0 delayed
[auto-inserted resampler 0 @ 0x2a094e0] [SWR @ 0x2a098c0] Using s16p
internally between filters
[auto-inserted resampler 0 @ 0x2a094e0] ch:2 chl:stereo fmt:s16p
r:44100Hz -> ch:2 chl:stereo fmt:fltp r:44100Hz
Demuxer gave frame of stream_index 1
Going to reencode the frame
Pushing decoded frame to filters
Pulling filtered frame from filters
Encoding frame
[aac @ 0x28d5780] more samples than frame size (avcodec_encode_audio2)
[aac @ 0x28d5780] Qavg: -nan
[AVIOContext @ 0x27da900] Statistics: 151336 bytes read, 4 seeks
[AVIOContext @ 0x2a02f20] Statistics: 0 seeks, 1 writeouts
--
Regards
Przemysław Sobala


Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 850,00 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzi

Re: [FFmpeg-devel] 2.9/3.0, 2.8.5, ...

2016-03-15 Thread Przemysław Sobala

W dniu 15.03.2016 o 14:40, Carl Eugen Hoyos pisze:

Przemysław Sobala  grupawp.pl> writes:


I know it's a bit late but could you backport fixes for
#4841, #4849, #5121, #5267


None of these were reported as regresions and I don't think
any of them describe a security issue.
Generally, backports should be held to a minimum to avoid
issues like ticket #5090.


All of them are simple functionality bugs fixes.


and also 2241cc17606a616a227613c166ddd3ac789f3798


sorry, my mistake, I was thinking about:
http://git.videolan.org/?p=ffmpeg.git;a=commit;h=0d097a869c38850c9ac09bccef60a229470f489b


I was unable to find this one.


to 2.8 at least?


Which distribution are you or your customers using?



I'm stuck with release/2.8 at Centos 7 (RHEL 7) distro.

Regards
Pszemek



Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 850,00 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. 
Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - 
Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] 2.9/3.0, 2.8.5, ...

2016-03-15 Thread Przemysław Sobala

W dniu 01.01.2016 o 15:19, Michael Niedermayer pisze:
(...)


Also ill likely make another round of point releases from the
2.8/2.7/2.6/2.5 branches soon, that is if someone wants to backport
something or fix and backport ...



I know it's a bit late but could you backport fixes for #4841, #4849,
#5121, #5267 and also 2241cc17606a616a227613c166ddd3ac789f3798 to 2.8 at
least?

Regards
Pszemek


Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 850,00 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. 
Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - 
Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC][PATCH]lavf/matroskaenc: Assume 48kHz sample rate for Opus initial padding.

2016-01-05 Thread Przemysław Sobala

W dniu 05.01.2016 o 13:23, Carl Eugen Hoyos pisze:

Hi!

Attached patch may fix this issue reported for Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1227153
Completely untested but I believe the patch matches a
comment in libopusenc.c line 90.

Please comment, Carl Eugen


After applying your patch, I can confirm that the webm file is now
playable in Firefox.
--
Regards
Przemysław Sobala


Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 800,00 zł, Numer 
Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Warszawie, ul. 
Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - 
Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] FFmpeg 2.8.2

2015-11-13 Thread Przemysław Sobala

W dniu 08.11.2015 o 20:23, Michael Niedermayer pisze:

Hi

I will probably make 2.8.2 soon (days/week), if you want somethig
backported, please backport sooner

thx



Can you include commit 6540fe04a3f9a11ba7084a49b3ee5fa2fc5b32ab
libvpxenc: remove some unused ctrl id mappings
Author: James Zern <jz...@google.com>

in next 2.8.* release so that we will be able to use libvpx 1.5.0
version with that release?
--
Regards
Przemysław Sobala



Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 580004, kapitał zakładowy: 317 957 800,00 zł, Numer 
Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/img2dec: Fix memory leak

2015-09-29 Thread Przemysław Sobala
Fixes #4886
---
 libavformat/img2dec.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 70f0b09..2c0fd9a 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -444,14 +444,17 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
 }
 
 res = av_new_packet(pkt, size[0] + size[1] + size[2]);
-if (res < 0)
-return res;
+if (res < 0) {
+goto fail;
+}
 pkt->stream_index = 0;
 pkt->flags   |= AV_PKT_FLAG_KEY;
 if (s->ts_from_file) {
 struct stat img_stat;
-if (stat(filename, _stat))
-return AVERROR(EIO);
+if (stat(filename, _stat)) {
+res = AVERROR(EIO);
+goto fail;
+}
 pkt->pts = (int64_t)img_stat.st_mtime;
 #if HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
 if (s->ts_from_file == 2)
@@ -485,18 +488,29 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
 if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
 av_free_packet(pkt);
 if (ret[0] < 0) {
-return ret[0];
+res = ret[0];
 } else if (ret[1] < 0) {
-return ret[1];
-} else if (ret[2] < 0)
-return ret[2];
-return AVERROR_EOF;
+res = ret[1];
+} else if (ret[2] < 0) {
+res = ret[2];
+} else {
+res = AVERROR_EOF;
+}
+goto fail;
 } else {
 s->img_count++;
 s->img_number++;
 s->pts++;
 return 0;
 }
+
+fail:
+if (!s->is_pipe) {
+for (i = 0; i < 3; i++) {
+avio_closep([i]);
+}
+}
+return res;
 }
 
 static int img_read_close(struct AVFormatContext* s1)
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH] lavf/img2dec: Fix memory leak

2015-09-29 Thread Przemysław Sobala
Fixes #4886
---
 libavformat/img2dec.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 70f0b09..fcd2b76 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -444,8 +444,12 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
 }
 
 res = av_new_packet(pkt, size[0] + size[1] + size[2]);
-if (res < 0)
+if (res < 0) {
+for (i = 0; i < 3; i++) {
+avio_closep([i]);
+}
 return res;
+}
 pkt->stream_index = 0;
 pkt->flags   |= AV_PKT_FLAG_KEY;
 if (s->ts_from_file) {
-- 
1.8.3.1

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


Re: [FFmpeg-devel] [PATCH] lavf/img2dec: Fix memory leak

2015-09-29 Thread Przemysław Sobala

W dniu 29.09.2015 o 12:22, Hendrik Leppkes pisze:

On Tue, Sep 29, 2015 at 12:14 PM, Przemysław Sobala
<przemyslaw.sob...@grupawp.pl> wrote:

Fixes #4886
---
  libavformat/img2dec.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 70f0b09..fcd2b76 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -444,8 +444,12 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
  }

  res = av_new_packet(pkt, size[0] + size[1] + size[2]);
-if (res < 0)
+if (res < 0) {
+for (i = 0; i < 3; i++) {
+avio_closep([i]);
+}
  return res;
+}
  pkt->stream_index = 0;
  pkt->flags   |= AV_PKT_FLAG_KEY;
  if (s->ts_from_file) {
--
1.8.3.1



This needs a !s->is_pipe check, otherwise it shall not be closed.


OK. New patch attached,


Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 317 957 800,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
>From c7b66f88c21498b2ef603c2753cc24337e05ac07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= <przemyslaw.sob...@grupawp.pl>
Date: Tue, 29 Sep 2015 10:49:49 +0200
Subject: [PATCH] lavf/img2dec: Fix memory leak

Fixes #4886
---
 libavformat/img2dec.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 70f0b09..a0a4c71 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -444,8 +444,14 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
 }
 
 res = av_new_packet(pkt, size[0] + size[1] + size[2]);
-if (res < 0)
+if (res < 0) {
+if (!s->is_pipe) {
+for (i = 0; i < 3; i++) {
+avio_closep([i]);
+}
+}
 return res;
+}
 pkt->stream_index = 0;
 pkt->flags   |= AV_PKT_FLAG_KEY;
 if (s->ts_from_file) {
-- 
1.8.3.1

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


[FFmpeg-devel] doc/examples/transcoding: Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.

2015-09-28 Thread Przemysław Sobala

Hello
I'm trying to get rid of deprecated code/runtime warnings.
How would you change doc/examples/transcoding.c to remove

[mp4 @ 0x2002e00] Using AVStream.codec.time_base as a timebase hint to
the muxer is deprecated. Set AVStream.time_base instead.
[mp4 @ 0x2002e00] Using AVStream.codec.time_base as a timebase hint to
the muxer is deprecated. Set AVStream.time_base instead.

warning?

--
Regards
Przemysław Sobala



Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 317 957 800,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/imgconvert: Support non-planar colorspaces while padding

2015-09-19 Thread Przemysław Sobala

W dniu 19.09.2015 o 04:14, Michael Niedermayer pisze:

On Fri, Sep 18, 2015 at 04:31:16PM +0200, Przemysław Sobala wrote:

---
  libavcodec/imgconvert.c | 99 -
  1 file changed, 65 insertions(+), 34 deletions(-)

diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index dc67560..a523bd5 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -236,54 +236,85 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, 
int height, int width,
  int x_shift;
  int yheight;
  int i, y;
+int max_step[4];

-if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB ||
-!is_yuv_planar(desc)) return -1;
+if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
+return -1;

-for (i = 0; i < 3; i++) {
-x_shift = i ? desc->log2_chroma_w : 0;
-y_shift = i ? desc->log2_chroma_h : 0;
+if (is_yuv_planar(desc)) {
+for (i = 0; i < 3; i++) {
+x_shift = i ? desc->log2_chroma_w : 0;
+y_shift = i ? desc->log2_chroma_h : 0;

-if (padtop || padleft) {
-memset(dst->data[i], color[i],
-dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
-}
+if (padtop || padleft) {
+memset(dst->data[i], color[i],
+dst->linesize[i] * (padtop >> y_shift) + (padleft >> 
x_shift));
+}

-if (padleft || padright) {
-optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
-(dst->linesize[i] - (padright >> x_shift));
-yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
-for (y = 0; y < yheight; y++) {
-memset(optr, color[i], (padleft + padright) >> x_shift);
-optr += dst->linesize[i];
+if (padleft || padright) {
+optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+(dst->linesize[i] - (padright >> x_shift));
+yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
+for (y = 0; y < yheight; y++) {
+memset(optr, color[i], (padleft + padright) >> x_shift);
+optr += dst->linesize[i];
+}
  }
+
+if (src) { /* first line */
+uint8_t *iptr = src->data[i];
+optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+(padleft >> x_shift);
+memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
+iptr += src->linesize[i];
+optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+(dst->linesize[i] - (padright >> x_shift));
+yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
+for (y = 0; y < yheight; y++) {
+memset(optr, color[i], (padleft + padright) >> x_shift);
+memcpy(optr + ((padleft + padright) >> x_shift), iptr,
+   (width - padleft - padright) >> x_shift);
+iptr += src->linesize[i];
+optr += dst->linesize[i];
+}
+}
+
+if (padbottom || padright) {
+optr = dst->data[i] + dst->linesize[i] *
+((height - padbottom) >> y_shift) - (padright >> x_shift);
+memset(optr, color[i],dst->linesize[i] *
+(padbottom >> y_shift) + (padright >> x_shift));
+}
+}


this only reindents the code, moving the reindention to a seperate
patch would make it more readable


I've rearranged the code a bit.


+} else {



+if (src)
+return -1;


why ?



Because it's not yet implemented.
I've added a comment.
New patch attached.

--
Regards
Przemysław Sobala


Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 317 957 800,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnośc

[FFmpeg-devel] Triple GET request while encoding remote JPEG image

2015-09-10 Thread Przemysław Sobala
000 duration: 0.000



[image2 @ 0x2f24380] stream: start_time: 0.000 duration: 0.040
bitrate=58137 kb/s


[image2 @ 0x2f24380] After avformat_find_stream_info() pos: 0 bytes
read:2486 seeks:0 frames:1


Input #0, image2, from 'http://i.wp.pl/a/i/dppadmin/sport/wid_15524107.jpg':
  Duration: 00:00:00.04, start: 0.00, bitrate: 58137 kb/s
Stream #0:0, 1, 1/25: Video: mjpeg, 1 reference frame, yuvj420p(pc,
bt470bg/unknown/unknown, center), 1004x1500 [SAR 100:100 DAR 251:375],
1/25, 25 tbr, 25 tbn, 25 tbc
[cut]
Output #0, mjpeg, to '/dev/null':
  Metadata:
encoder : Lavf57.0.100
Stream #0:0, 0, 1/25: Video: mjpeg, 1 reference frame, yuvj420p(pc,
center), 1004x1500 [SAR 100:100 DAR 251:375], 1/25, q=2-31, 200 kb/s, 25
fps, 25 tbn, 25 tbc
Metadata:
  encoder : Lavc57.1.100 mjpeg
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[cut]
video:191kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.00%
Input file #0 (http://i.wp.pl/a/i/dppadmin/sport/wid_15524107.jpg):
  Input stream #0:0 (video): 1 packets read (290686 bytes); 1 frames
decoded;
  Total: 1 packets (290686 bytes) demuxed
Output file #0 (/dev/null):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (195672
bytes);
  Total: 1 packets (195672 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x2f2b860] Statistics: 0 seeks, 6 writeouts
[AVIOContext @ 0x2f303e0] Statistics: 2486 bytes read, 0 seeks

--
Regards
Przemysław Sobala



Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 317 957 800,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Connection timeout to HTTP resource

2015-08-27 Thread Przemysław Sobala

W dniu 26.08.2015 o 18:27, Stephan Holljes pisze:

Hi,

On Wed, Aug 26, 2015 at 11:35 AM, Przemysław Sobala
przemyslaw.sob...@grupawp.pl wrote:

Hi
I wanted to configure tcp connection timeout while connecting to eg.
http://google.com:81.

ffmpeg -i http://google.com:81?timeout=100
doesn't pass timeout param to tcp proto, as tcp proto doesn't support
URL query string


TCP does support some parsing for URL query strings (see
tcp.c:tcp_open around line 83 and following), but when used with HTTP
the query is not parsed and simply sent with the request as it
could/should contain information only relevant to the server handling
the request.



ffmpeg -timeout 100 -i http://google.com:81
doesn't pass timeout param to tcp proto, as tcp proto doestn't support
AVDictionary and url_open2


AFAIK this should happen through AVOptions and should work. When I run
the command with -loglevel trace the parameter gets set properly. I
added logging for s-rw_timeout in tcp.c:tcp_open, and that value also
gets set correctly.



So I tried to correct the second case, and ended up with patch:

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index bee349e..2f7726f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -59,7 +59,8 @@ static const AVClass tcp_class = {
  };

  /* return non zero if error */
-static int tcp_open(URLContext *h, const char *uri, int flags)
+static int tcp_open(URLContext *h, const char *uri, int flags,
+ AVDictionary **options)
  {
  struct addrinfo hints = { 0 }, *ai, *cur_ai;
  int port, fd = -1;
@@ -244,7 +245,7 @@ static int tcp_get_file_handle(URLContext *h)

  URLProtocol ff_tcp_protocol = {
  .name= tcp,
-.url_open= tcp_open,
+.url_open2   = tcp_open,
  .url_accept  = tcp_accept,
  .url_read= tcp_read,
  .url_write   = tcp_write,

Now it works (ffmpeg -timeout 100 -i http://google.com:81). What do
you think about that?


If that's the complete patch it doesn't really change anything since
options isn't used anywhere in tcp_open() AFAICT.
I also couldn't reproduce the behaviour you described. When running:

ffmpeg -timeout 100 -i http://google.com:81

with the latest git master the connection properly times out.


You're right. I must have missed something. So I got everything I need.
One last question: why FFmpeg reports
http://google.com:81: Network is unreachable
while tcp_open returns AVERROR(ETIMEDOUT) ?
--
Regards
Przemysław Sobala


Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 311.005.050,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] Connection timeout to HTTP resource

2015-08-26 Thread Przemysław Sobala

Hi
I wanted to configure tcp connection timeout while connecting to eg.
http://google.com:81.

ffmpeg -i http://google.com:81?timeout=100
doesn't pass timeout param to tcp proto, as tcp proto doesn't support
URL query string

ffmpeg -timeout 100 -i http://google.com:81
doesn't pass timeout param to tcp proto, as tcp proto doestn't support
AVDictionary and url_open2

So I tried to correct the second case, and ended up with patch:

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index bee349e..2f7726f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -59,7 +59,8 @@ static const AVClass tcp_class = {
 };

 /* return non zero if error */
-static int tcp_open(URLContext *h, const char *uri, int flags)
+static int tcp_open(URLContext *h, const char *uri, int flags,
+ AVDictionary **options)
 {
 struct addrinfo hints = { 0 }, *ai, *cur_ai;
 int port, fd = -1;
@@ -244,7 +245,7 @@ static int tcp_get_file_handle(URLContext *h)

 URLProtocol ff_tcp_protocol = {
 .name= tcp,
-.url_open= tcp_open,
+.url_open2   = tcp_open,
 .url_accept  = tcp_accept,
 .url_read= tcp_read,
 .url_write   = tcp_write,

Now it works (ffmpeg -timeout 100 -i http://google.com:81). What do
you think about that?

--
Regards
Przemysław Sobala


Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 1 245 651,90 zł (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 311.005.050,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

WP Shopping Spółka z ograniczoną odpowiedzialnością z siedzibą w Gdańsku, ul. 
Romualda Traugutta 115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego 
- Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w 
Gdańsku pod nr KRS: 546914, kapitał zakładowy: 170.000,00 złotych (w 
całości wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] mjpegdec: add 0x14121200 pixel format support

2014-07-22 Thread Przemysław Sobala

Hello
   Patch adds support for 0x14121200 pixel format to MJPEG decoder. I
can deliver a sample image but don't know where upload to?

--
psze...@wp-sa.pl

[http://i.wp.pl/a/i/sg/mail/all/logo_wp.png]http://www.wp.pl  [Nowy 
lider polskiego internetu]

Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137 A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 378.000,00 zł (w całości wpłacony), 
Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137 A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 311.005.000,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

Wirtualna Polska Spółka Akcyjna z siedzibą w Gdańsku, ul. Romualda Traugutta 
115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w Gdańsku pod 
nr KRS: 068548, kapitał zakładowy: 67.980.024,00 złotych (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216

From 7db6d738d74295757d5eca2e9ed1da484b4d8b78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Przemys=C5=82aw=20Sobala?= psze...@wp-sa.pl
Date: Tue, 22 Jul 2014 15:52:41 +0200
Subject: [PATCH] [mjpegdec] add pix_fmt: 0x14121200

---
 libavcodec/mjpegdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 1a774dd..ea84d9a 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -485,6 +485,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 s-avctx-pix_fmt = AV_PIX_FMT_GRAY16;
 break;
 case 0x1200:
+case 0x14121200:
 case 0x22211100:
 case 0x22112100:
 if (s-bits = 8) s-avctx-pix_fmt = s-cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
-- 
1.7.11.3

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


Re: [FFmpeg-devel] [PATCH] mjpegdec: add 0x14121200 pixel format support

2014-07-22 Thread Przemysław Sobala

W dniu 22.07.2014 17:03, Carl Eugen Hoyos pisze:

Przemysław Sobala pszemus at wp-sa.pl writes:


Patch adds support for 0x14121200 pixel format
to MJPEG decoder.



I can deliver a sample image but don't know
where upload to?


Please provide a sample, either upload to
http://www.datafilehost.com/ or read
https://ffmpeg.org/bugreports.html (there is
no filesize limit).

Carl Eugen


sample input file:
http://www.datafilehost.com/d/8ef264ae

--
Przemysław Sobala

[http://i.wp.pl/a/i/sg/mail/all/logo_wp.png]http://www.wp.pl  [Nowy 
lider polskiego internetu]

Główne Spółki Grupy Wirtualna Polska:

Wirtualna Polska Holding Spółka Akcyjna z siedzibą w Warszawie, ul. Jutrzenki 
137 A, 02-231 Warszawa, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. Warszawy w Warszawie 
pod nr KRS: 407130, kapitał zakładowy: 378.000,00 zł (w całości wpłacony), 
Numer Identyfikacji Podatkowej (NIP): 521-31-11-513

Grupa Wirtualna Polska Spółka z ograniczoną odpowiedzialnością z siedzibą w 
Warszawie, ul. Jutrzenki 137 A, 02-231 Warszawa, wpisana do Krajowego Rejestru 
Sądowego - Rejestru Przedsiębiorców prowadzonego przez Sąd Rejonowy dla m.st. 
Warszawy w Warszawie pod nr KRS: 373814, kapitał zakładowy: 311.005.000,00 
zł, Numer Identyfikacji Podatkowej (NIP): 527-26-45-593

Wirtualna Polska Spółka Akcyjna z siedzibą w Gdańsku, ul. Romualda Traugutta 
115 C, 80-226 Gdańsk, wpisana do Krajowego Rejestru Sądowego - Rejestru 
Przedsiębiorców prowadzonego przez Sąd Rejonowy Gdańsk - Północ w Gdańsku pod 
nr KRS: 068548, kapitał zakładowy: 67.980.024,00 złotych (w całości 
wpłacony), Numer Identyfikacji Podatkowej (NIP): 957-07-51-216

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