Skip to content

Commit

Permalink
libavformat: add side_data copy in concat demuxer
Browse files Browse the repository at this point in the history
Adds support for concat demuxer to copy the side data information
from the input file to the resulting file. It will behave like the
metadata copy, where the metadata of the first file is kept in the
the output file.

Extract the current code that already performs the stream side_data
copy into a separate method and reuse the method in the concat demuxer.

Signed-off-by: Gerard Sole <[email protected]>
  • Loading branch information
GerardSoleCa authored and Cigaes committed Dec 22, 2021
1 parent 2ac8bce commit 18ad360
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions libavformat/concatdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
avpriv_set_pts_info(st, 64, source_st->time_base.num, source_st->time_base.den);

av_dict_copy(&st->metadata, source_st->metadata, 0);
ff_stream_side_data_copy(st, source_st);
return 0;
}

Expand Down
9 changes: 9 additions & 0 deletions libavformat/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,15 @@ int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *a
*/
int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);

/**
* Copy side data from source to destination stream
*
* @param dst pointer to destination AVStream
* @param src pointer to source AVStream
* @return >=0 on success, AVERROR code on error
*/
int ff_stream_side_data_copy(AVStream *dst, const AVStream *src);

/**
* Wrap ffurl_move() and log if error happens.
*
Expand Down
9 changes: 9 additions & 0 deletions libavformat/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
if (ret < 0)
return ret;

ret = ff_stream_side_data_copy(dst, src);
if (ret < 0)
return ret;

return 0;
}

int ff_stream_side_data_copy(AVStream *dst, const AVStream *src)
{
/* Free existing side data*/
for (int i = 0; i < dst->nb_side_data; i++)
av_free(dst->side_data[i].data);
Expand Down
2 changes: 1 addition & 1 deletion tests/ref/fate/concat-demuxer-extended-lavf-mxf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
29e4e502a912b6d863e75d44e156ed31 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
d367d7f6df7292cbf454c6d07fca9b04 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
2 changes: 1 addition & 1 deletion tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8de04a786521677a593283c44a53572e *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
1fac6962d4c5f1070d0d2db5ab7d86aa *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
1 change: 1 addition & 0 deletions tests/ref/fate/concat-demuxer-simple1-lavf-mxf
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ Strings Metadata
video|0|37|1.480000|34|1.360000|1|0.040000|24786|212480|K_|1
Strings Metadata
0|mpeg2video|4|video|[0][0][0][0]|0x0000|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
CPB properties|0|0|0|49152|-1
1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
1 change: 1 addition & 0 deletions tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ Strings Metadata
audio|1|65280|1.360000|65280|1.360000|1920|0.040000|7680|2074624|K_|1
Strings Metadata
0|mpeg2video|0|video|[0][0][0][0]|0x0000|720|608|0|0|0|0|0|1:1|45:38|yuv422p|5|tv|unknown|unknown|unknown|topleft|tb|1|N/A|25/1|25/1|1/25|0|0.000000|N/A|N/A|30000000|N/A|N/A|N/A|N/A|35|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
CPB properties|30000000|0|0|1212416|-1
1|pcm_s16le|unknown|audio|[0][0][0][0]|0x0000|s16|48000|2|unknown|16|N/A|0/0|0/0|1/48000|0|0.000000|N/A|N/A|1536000|N/A|N/A|N/A|N/A|35|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001300000000000000000000000000000000000001
1 change: 1 addition & 0 deletions tests/ref/fate/concat-demuxer-simple2-lavf-ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,4 @@ video|1|175582|1.950911|171982|1.910911|3600|0.040000|15019|224848|__MPEGTS Stre

0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0
1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 1
CPB properties|0|0|0|49152|-1

0 comments on commit 18ad360

Please sign in to comment.