[FFmpeg-cvslog] avformat/mov: parse multiple iTunes cover images
ffmpeg | branch: master | Timo Teräs | Thu Mar 29 15:59:33 2018 +0300| [8c980b1c92bbc98ed12b6a43269572aaacf31426] | committer: Michael Niedermayer avformat/mov: parse multiple iTunes cover images Multiple cover images are supported by having multiple data atoms inside the covr atom. AtomicParsley and mutagen amongst others support and document this construct. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c980b1c92bbc98ed12b6a43269572aaacf31426 --- libavformat/mov.c | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index cb6f3a45de..e7c32e6148 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -412,7 +412,11 @@ retry: int ret = mov_read_covr(c, pb, data_type, str_size); if (ret < 0) { av_log(c->fc, AV_LOG_ERROR, "Error parsing cover art.\n"); +return ret; } +atom.size -= str_size; +if (atom.size > 8) +goto retry; return ret; } else if (!key && c->found_hdlr_mdta && c->meta_keys) { uint32_t index = AV_RB32(&atom.type); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg: allow setting attached_pic disposition
ffmpeg | branch: master | Timo Teräs | Mon Apr 2 11:36:56 2018 +0300| [94d831f3886a7d5d207b9224cd52d11e22d0e8f1] | committer: Michael Niedermayer ffmpeg: allow setting attached_pic disposition This is used to signal that image should be stored in metadata as cover image. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94d831f3886a7d5d207b9224cd52d11e22d0e8f1 --- fftools/ffmpeg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 2f8a5ace56..4dbe72186d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3561,6 +3561,7 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) { "hearing_impaired", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED },.unit = "flags" }, { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED },.unit = "flags" }, { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS },.unit = "flags" }, +{ "attached_pic", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC },.unit = "flags" }, { "captions", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS },.unit = "flags" }, { "descriptions", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS },.unit = "flags" }, { "dependent" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT },.unit = "flags" }, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: add rtp_hinting_needed() helper function
ffmpeg | branch: master | Timo Teräs | Mon Apr 2 11:36:57 2018 +0300| [53688b62ca96ad9a3b0e7d201caca61c79a68648] | committer: Michael Niedermayer avformat/movenc: add rtp_hinting_needed() helper function This is shared test and this simplifies code a bit. Follow up commit will have additional tests for this function. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53688b62ca96ad9a3b0e7d201caca61c79a68648 --- libavformat/movenc.c | 30 -- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index ef668eccd5..bd275259ca 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -140,6 +140,13 @@ static int co64_required(const MOVTrack *track) return 0; } +static int rtp_hinting_needed(const AVStream *st) +{ +/* Add hint tracks for each audio and video stream */ +return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || + st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; +} + /* Chunk offset atom */ static int mov_write_stco_tag(AVIOContext *pb, MOVTrack *track) { @@ -5941,14 +5948,9 @@ static int mov_init(AVFormatContext *s) mov->chapter_track = mov->nb_streams++; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { -/* Add hint tracks for each audio and video stream */ -for (i = 0; i < s->nb_streams; i++) { -AVStream *st = s->streams[i]; -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || -st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { +for (i = 0; i < s->nb_streams; i++) +if (rtp_hinting_needed(s->streams[i])) mov->nb_streams++; -} -} } if ( mov->write_tmcd == -1 && (mov->mode == MODE_MOV || mov->mode == MODE_MP4) @@ -6171,15 +6173,10 @@ static int mov_write_header(AVFormatContext *s) nb_tracks++; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { -/* Add hint tracks for each audio and video stream */ hint_track = nb_tracks; -for (i = 0; i < s->nb_streams; i++) { -AVStream *st = s->streams[i]; -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || -st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { +for (i = 0; i < s->nb_streams; i++) +if (rtp_hinting_needed(s->streams[i])) nb_tracks++; -} -} } if (mov->mode == MODE_MOV || mov->mode == MODE_MP4) @@ -6257,11 +6254,8 @@ static int mov_write_header(AVFormatContext *s) return ret; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { -/* Initialize the hint tracks for each audio and video stream */ for (i = 0; i < s->nb_streams; i++) { -AVStream *st = s->streams[i]; -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || -st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { +if (rtp_hinting_needed(s->streams[i])) { if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0) return ret; hint_track++; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: use correct iTunes copyright atom
ffmpeg | branch: master | Timo Teräs | Tue Apr 3 09:05:18 2018 +0300| [62c1cfcc35a7772d9634fb9d2d1e74952843c108] | committer: Michael Niedermayer avformat/movenc: use correct iTunes copyright atom Support for writing copyright metadata was added in commit bed4fc54c9 for 3GP, MOV and iTunes metadata. 3GP and MOV cases are formally specified. However, iTunes format does not have specification, and it seems to have been assumed that it would use the same atom as MOV (both being Apple formats). However, Apple uses 'cprt' atom for iTunes metadata (do note that the iTunes 'cprt' encoding is generic iTunes ItemList atom, not the 3GP 'cprt' encoding. These are also inside different parent atoms). Most references trying to document iTunes atoms mention only the 'cprt' tag. See: - http://atomicparsley.sourceforge.net/mpeg-4files.html - http://mutagen.readthedocs.io/en/latest/api/mp4.html Same applies to other software supporting this tag. Most of them encode and decode only the 'cprt' atom. ffmpeg mov demuxer supports both atoms in this context. There are few pieces of other software that support similarly both 'cprt' and the incorrect '\251cpy' atom in this context. I believe they do it in order to read the ffmpeg encoded incorrect copyright atom. In light of the above this changes the copyright atom to 'cprt' as it seems to be supported univerally and is the correct atom to use. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62c1cfcc35a7772d9634fb9d2d1e74952843c108 --- libavformat/movenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index bd275259ca..d03d7906a1 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3439,7 +3439,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, } mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1); mov_write_string_metadata(s, pb, "\251gen", "genre", 1); -mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1); +mov_write_string_metadata(s, pb, "cprt","copyright", 1); mov_write_string_metadata(s, pb, "\251grp", "grouping" , 1); mov_write_string_metadata(s, pb, "\251lyr", "lyrics" , 1); mov_write_string_metadata(s, pb, "desc","description",1); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffprobe: report unavailable SAR correctly in stream info
ffmpeg | branch: release/4.0 | Timo Teräs | Thu Apr 12 11:07:36 2018 +0300| [de253343c151e0ba752f91088ab1aa87f50e1590] | committer: Rostislav Pehlivanov ffprobe: report unavailable SAR correctly in stream info av_guess_sample_aspect_ratio() will return undefined or missing value as {0,1}. This fixes show_stream() to check numerator to display 'N/A' when appropriate. show_frame() does this already correctly. Signed-off-by: Timo Teräs (cherry picked from commit c663dce031b3973e37c83ae1818f1484e1cf482c) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=de253343c151e0ba752f91088ab1aa87f50e1590 --- fftools/ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 82dfe4f58a..8b2a18b6b1 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2521,7 +2521,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id #endif print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); -if (sar.den) { +if (sar.num) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: support writing iTunes cover image
ffmpeg | branch: release/4.0 | Timo Teräs | Sat Apr 14 21:32:11 2018 +0300| [ca85c3cd7d645f2568ebf28d3ddf436cbeb1743e] | committer: Rostislav Pehlivanov avformat/movenc: support writing iTunes cover image Fixes https://trac.ffmpeg.org/ticket/2798 This makes movenc handle AV_DISPOSITION_ATTACHED_PIC and write the associated pictures in iTunes cover atom. This corresponds to how 'mov' demuxer parses and exposes the cover images when reading. Most of the existing track handling loops properly ignore these 'virtual streams' as MOVTrack->entry is never incremented for them. However, additional tests are added as needed to ignore them. Tested to produce valid output with: ffmpeg -i movie.mp4 -i thumb.jpg -disposition:v:1 attached_pic \ -map 0 -map 1 -c copy movie-with-cover.mp4 The cover image is also copied correctly with: ffmpeg -i movie-with-cover.mp4 -map 0 -c copy out.mp4 AtomicParseley says that the attached_pic stream is properly not visible in the main tracks of the file. Signed-off-by: Timo Teräs (cherry picked from commit 9af71b326fda1c6f32a26d465f7740110113e759) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca85c3cd7d645f2568ebf28d3ddf436cbeb1743e --- libavformat/movenc.c | 88 +--- libavformat/movenc.h | 1 + 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index dc5c842cb8..0b44fd66ea 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -142,7 +142,9 @@ static int co64_required(const MOVTrack *track) static int rtp_hinting_needed(const AVStream *st) { -/* Add hint tracks for each audio and video stream */ +/* Add hint tracks for each real audio and video stream */ +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +return 0; return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; } @@ -3420,6 +3422,51 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, return size; } +static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) +{ +MOVMuxContext *mov = s->priv_data; +int64_t pos = 0; +int i, type; + +for (i = 0; i < s->nb_streams; i++) { +MOVTrack *trk = &mov->tracks[i]; +AVStream *st = s->streams[i]; + +if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC) || +trk->cover_image.size <= 0) +continue; + +switch (st->codecpar->codec_id) { +case AV_CODEC_ID_MJPEG: +type = 0xD; +break; +case AV_CODEC_ID_PNG: +type = 0xE; +break; +case AV_CODEC_ID_BMP: +type = 0x1B; +break; +default: +av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x) for cover", + st->codecpar->codec_id); +continue; +} + +if (!pos) { +pos = avio_tell(pb); +avio_wb32(pb, 0); +ffio_wfourcc(pb, "covr"); +} +avio_wb32(pb, 16 + trk->cover_image.size); +ffio_wfourcc(pb, "data"); +avio_wb32(pb, type); +avio_wb32(pb , 0); +avio_write(pb, trk->cover_image.data, trk->cover_image.size); +} + +return pos ? update_size(pb, pos) : 0; +} + /* iTunes meta data list */ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) @@ -3454,6 +3501,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, mov_write_int8_metadata (s, pb, "hdvd","hd_video", 1); mov_write_int8_metadata (s, pb, "pgap","gapless_playback",1); mov_write_int8_metadata (s, pb, "cpil","compilation", 1); +mov_write_covr(pb, s); mov_write_trkn_tag(pb, mov, s, 0); // track number mov_write_trkn_tag(pb, mov, s, 1); // disc number mov_write_tmpo_tag(pb, s); @@ -3951,6 +3999,8 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat } else { continue; } +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +continue; props = (AVCPBProperties*)av_stream_get_side_data(track->st, AV_PKT_DATA_CPB_PROPERTIES, NULL); @@ -4564,6 +4614,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) has_video = 1; if (st->codecpar->codec_id == AV_CODEC_ID_H264) @@ -4712,6 +4764,8 @@ static int mov
[FFmpeg-cvslog] avformat/movenc: support writing iTunes cover image
ffmpeg | branch: master | Timo Teräs | Sat Apr 14 21:32:11 2018 +0300| [9af71b326fda1c6f32a26d465f7740110113e759] | committer: Rostislav Pehlivanov avformat/movenc: support writing iTunes cover image Fixes https://trac.ffmpeg.org/ticket/2798 This makes movenc handle AV_DISPOSITION_ATTACHED_PIC and write the associated pictures in iTunes cover atom. This corresponds to how 'mov' demuxer parses and exposes the cover images when reading. Most of the existing track handling loops properly ignore these 'virtual streams' as MOVTrack->entry is never incremented for them. However, additional tests are added as needed to ignore them. Tested to produce valid output with: ffmpeg -i movie.mp4 -i thumb.jpg -disposition:v:1 attached_pic \ -map 0 -map 1 -c copy movie-with-cover.mp4 The cover image is also copied correctly with: ffmpeg -i movie-with-cover.mp4 -map 0 -c copy out.mp4 AtomicParseley says that the attached_pic stream is properly not visible in the main tracks of the file. Signed-off-by: Timo Teräs > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9af71b326fda1c6f32a26d465f7740110113e759 --- libavformat/movenc.c | 88 +--- libavformat/movenc.h | 1 + 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index dc5c842cb8..0b44fd66ea 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -142,7 +142,9 @@ static int co64_required(const MOVTrack *track) static int rtp_hinting_needed(const AVStream *st) { -/* Add hint tracks for each audio and video stream */ +/* Add hint tracks for each real audio and video stream */ +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +return 0; return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; } @@ -3420,6 +3422,51 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb, return size; } +static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) +{ +MOVMuxContext *mov = s->priv_data; +int64_t pos = 0; +int i, type; + +for (i = 0; i < s->nb_streams; i++) { +MOVTrack *trk = &mov->tracks[i]; +AVStream *st = s->streams[i]; + +if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC) || +trk->cover_image.size <= 0) +continue; + +switch (st->codecpar->codec_id) { +case AV_CODEC_ID_MJPEG: +type = 0xD; +break; +case AV_CODEC_ID_PNG: +type = 0xE; +break; +case AV_CODEC_ID_BMP: +type = 0x1B; +break; +default: +av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x) for cover", + st->codecpar->codec_id); +continue; +} + +if (!pos) { +pos = avio_tell(pb); +avio_wb32(pb, 0); +ffio_wfourcc(pb, "covr"); +} +avio_wb32(pb, 16 + trk->cover_image.size); +ffio_wfourcc(pb, "data"); +avio_wb32(pb, type); +avio_wb32(pb , 0); +avio_write(pb, trk->cover_image.data, trk->cover_image.size); +} + +return pos ? update_size(pb, pos) : 0; +} + /* iTunes meta data list */ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) @@ -3454,6 +3501,7 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, mov_write_int8_metadata (s, pb, "hdvd","hd_video", 1); mov_write_int8_metadata (s, pb, "pgap","gapless_playback",1); mov_write_int8_metadata (s, pb, "cpil","compilation", 1); +mov_write_covr(pb, s); mov_write_trkn_tag(pb, mov, s, 0); // track number mov_write_trkn_tag(pb, mov, s, 1); // disc number mov_write_tmpo_tag(pb, s); @@ -3951,6 +3999,8 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat } else { continue; } +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +continue; props = (AVCPBProperties*)av_stream_get_side_data(track->st, AV_PKT_DATA_CPB_PROPERTIES, NULL); @@ -4564,6 +4614,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; +if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) has_video = 1; if (st->codecpar->codec_id == AV_CODEC_ID_H264) @@ -4712,6 +4764,8 @@ static int mov_write_identification(AVIOContext *pb, AVFormatContext *s)
[FFmpeg-cvslog] ffprobe: report unavailable SAR correctly in stream info
ffmpeg | branch: master | Timo Teräs | Thu Apr 12 11:07:36 2018 +0300| [c663dce031b3973e37c83ae1818f1484e1cf482c] | committer: Rostislav Pehlivanov ffprobe: report unavailable SAR correctly in stream info av_guess_sample_aspect_ratio() will return undefined or missing value as {0,1}. This fixes show_stream() to check numerator to display 'N/A' when appropriate. show_frame() does this already correctly. Signed-off-by: Timo Teräs > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c663dce031b3973e37c83ae1818f1484e1cf482c --- fftools/ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 82dfe4f58a..8b2a18b6b1 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2521,7 +2521,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id #endif print_int("has_b_frames", par->video_delay); sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); -if (sar.den) { +if (sar.num) { print_q("sample_aspect_ratio", sar, ':'); av_reduce(&dar.num, &dar.den, par->width * sar.num, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: fix recognization of cover image streams
ffmpeg | branch: master | Timo Teräs | Mon Jun 4 17:36:19 2018 +0300| [2223811b015926fec68473a08016d40cea0989b2] | committer: Michael Niedermayer avformat/movenc: fix recognization of cover image streams For chapter images, the mov demux produces streams with disposition set to attached_pic+timed_thumbnails. This patch fixes to properly recognize streams that should be encoded as cover image (ones with only and only attached_pic disposition set). Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2223811b015926fec68473a08016d40cea0989b2 --- libavformat/movenc.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 4ba90135df..db266b7765 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -143,10 +143,17 @@ static int co64_required(const MOVTrack *track) return 0; } +static int is_cover_image(const AVStream *st) +{ +/* Eg. AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS + * is encoded as sparse video track */ +return st && st->disposition == AV_DISPOSITION_ATTACHED_PIC; +} + static int rtp_hinting_needed(const AVStream *st) { /* Add hint tracks for each real audio and video stream */ -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) return 0; return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; @@ -1568,7 +1575,7 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) { int tag; -if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(track->st)) return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id); if (track->mode == MODE_MP4 || track->mode == MODE_PSP) @@ -3443,10 +3450,8 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { MOVTrack *trk = &mov->tracks[i]; -AVStream *st = s->streams[i]; -if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC) || -trk->cover_image.size <= 0) +if (!is_cover_image(trk->st) || trk->cover_image.size <= 0) continue; if (!pos) { @@ -3989,15 +3994,13 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat AVStream *st = track->st; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); -if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) { +if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && !is_cover_image(st)) { type = "video"; } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) { type = "audio"; } else { continue; } -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) -continue; props = (AVCPBProperties*)av_stream_get_side_data(track->st, AV_PKT_DATA_CPB_PROPERTIES, NULL); @@ -4657,7 +4660,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) has_video = 1; @@ -4807,7 +4810,7 @@ static int mov_write_identification(AVIOContext *pb, AVFormatContext *s) int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) video_streams_nb++; @@ -4998,8 +5001,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force) int buf_size, moov_size; for (i = 0; i < mov->nb_streams; i++) -if (!mov->tracks[i].entry && -(i >= s->nb_streams || !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))) +if (!mov->tracks[i].entry && !is_cover_image(mov->tracks[i].st)) break; /* Don't write the initial moov unless all tracks have data */ if (i < mov->nb_streams && !force) @@ -5581,21 +5583,19 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; MOVTrack *trk; -AVStream *st; if (!pkt) { mov_f
[FFmpeg-cvslog] avformat/movenc: properly handle cover image codecs
ffmpeg | branch: master | Timo Teräs | Fri Jun 1 02:24:39 2018 +0300| [12205d2c896b7edbc929d4886e7bfda4b53538e5] | committer: Michael Niedermayer avformat/movenc: properly handle cover image codecs Find codec tag for attached images using appropriate list of supported image formats. This fixes writing the cover image to m4v/m4a and other container formats that do not allow these codecs as a track. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12205d2c896b7edbc929d4886e7bfda4b53538e5 --- libavformat/movenc.c | 30 -- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7e616e866f..4ba90135df 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1557,10 +1557,20 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) return tag; } +static const AVCodecTag codec_cover_image_tags[] = { +{ AV_CODEC_ID_MJPEG, 0xD }, +{ AV_CODEC_ID_PNG,0xE }, +{ AV_CODEC_ID_BMP,0x1B }, +{ AV_CODEC_ID_NONE, 0 }, +}; + static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) { int tag; +if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC) +return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id); + if (track->mode == MODE_MP4 || track->mode == MODE_PSP) tag = track->par->codec_tag; else if (track->mode == MODE_ISM) @@ -3429,7 +3439,7 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; int64_t pos = 0; -int i, type; +int i; for (i = 0; i < s->nb_streams; i++) { MOVTrack *trk = &mov->tracks[i]; @@ -3439,22 +3449,6 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) trk->cover_image.size <= 0) continue; -switch (st->codecpar->codec_id) { -case AV_CODEC_ID_MJPEG: -type = 0xD; -break; -case AV_CODEC_ID_PNG: -type = 0xE; -break; -case AV_CODEC_ID_BMP: -type = 0x1B; -break; -default: -av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x) for cover", - st->codecpar->codec_id); -continue; -} - if (!pos) { pos = avio_tell(pb); avio_wb32(pb, 0); @@ -3462,7 +3456,7 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) } avio_wb32(pb, 16 + trk->cover_image.size); ffio_wfourcc(pb, "data"); -avio_wb32(pb, type); +avio_wb32(pb, trk->tag); avio_wb32(pb , 0); avio_write(pb, trk->cover_image.data, trk->cover_image.size); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/movenc: fix recognization of cover image streams
ffmpeg | branch: release/4.0 | Timo Teräs | Mon Jun 4 17:36:19 2018 +0300| [f0e4bc61e31d9d766920837422fdca95e82f771b] | committer: Michael Niedermayer avformat/movenc: fix recognization of cover image streams For chapter images, the mov demux produces streams with disposition set to attached_pic+timed_thumbnails. This patch fixes to properly recognize streams that should be encoded as cover image (ones with only and only attached_pic disposition set). Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 2223811b015926fec68473a08016d40cea0989b2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0e4bc61e31d9d766920837422fdca95e82f771b --- libavformat/movenc.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9beb1e2395..44f468d19f 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -140,10 +140,17 @@ static int co64_required(const MOVTrack *track) return 0; } +static int is_cover_image(const AVStream *st) +{ +/* Eg. AV_DISPOSITION_ATTACHED_PIC | AV_DISPOSITION_TIMED_THUMBNAILS + * is encoded as sparse video track */ +return st && st->disposition == AV_DISPOSITION_ATTACHED_PIC; +} + static int rtp_hinting_needed(const AVStream *st) { /* Add hint tracks for each real audio and video stream */ -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) return 0; return st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; @@ -1565,7 +1572,7 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) { int tag; -if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(track->st)) return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id); if (track->mode == MODE_MP4 || track->mode == MODE_PSP) @@ -3440,10 +3447,8 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { MOVTrack *trk = &mov->tracks[i]; -AVStream *st = s->streams[i]; -if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC) || -trk->cover_image.size <= 0) +if (!is_cover_image(trk->st) || trk->cover_image.size <= 0) continue; if (!pos) { @@ -3986,15 +3991,13 @@ static int mov_write_isml_manifest(AVIOContext *pb, MOVMuxContext *mov, AVFormat AVStream *st = track->st; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); -if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) { +if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && !is_cover_image(st)) { type = "video"; } else if (track->par->codec_type == AVMEDIA_TYPE_AUDIO) { type = "audio"; } else { continue; } -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) -continue; props = (AVCPBProperties*)av_stream_get_side_data(track->st, AV_PKT_DATA_CPB_PROPERTIES, NULL); @@ -4608,7 +4611,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) has_video = 1; @@ -4758,7 +4761,7 @@ static int mov_write_identification(AVIOContext *pb, AVFormatContext *s) int video_streams_nb = 0, audio_streams_nb = 0, other_streams_nb = 0; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) +if (is_cover_image(st)) continue; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) video_streams_nb++; @@ -4949,8 +4952,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force) int buf_size, moov_size; for (i = 0; i < mov->nb_streams; i++) -if (!mov->tracks[i].entry && -(i >= s->nb_streams || !(s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC))) +if (!mov->tracks[i].entry && !is_cover_image(mov->tracks[i].st)) break; /* Don't write the initial moov unless all tracks have data */ if (i < mov->nb_streams && !force) @@ -5531,21 +5533,19 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pk
[FFmpeg-cvslog] avformat/movenc: properly handle cover image codecs
ffmpeg | branch: release/4.0 | Timo Teräs | Fri Jun 1 02:24:39 2018 +0300| [36628bd215699afaeec732f54fc08287e3f76b56] | committer: Michael Niedermayer avformat/movenc: properly handle cover image codecs Find codec tag for attached images using appropriate list of supported image formats. This fixes writing the cover image to m4v/m4a and other container formats that do not allow these codecs as a track. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 12205d2c896b7edbc929d4886e7bfda4b53538e5) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=36628bd215699afaeec732f54fc08287e3f76b56 --- libavformat/movenc.c | 30 -- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0b44fd66ea..9beb1e2395 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1554,10 +1554,20 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) return tag; } +static const AVCodecTag codec_cover_image_tags[] = { +{ AV_CODEC_ID_MJPEG, 0xD }, +{ AV_CODEC_ID_PNG,0xE }, +{ AV_CODEC_ID_BMP,0x1B }, +{ AV_CODEC_ID_NONE, 0 }, +}; + static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) { int tag; +if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC) +return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id); + if (track->mode == MODE_MP4 || track->mode == MODE_PSP) tag = track->par->codec_tag; else if (track->mode == MODE_ISM) @@ -3426,7 +3436,7 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) { MOVMuxContext *mov = s->priv_data; int64_t pos = 0; -int i, type; +int i; for (i = 0; i < s->nb_streams; i++) { MOVTrack *trk = &mov->tracks[i]; @@ -3436,22 +3446,6 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) trk->cover_image.size <= 0) continue; -switch (st->codecpar->codec_id) { -case AV_CODEC_ID_MJPEG: -type = 0xD; -break; -case AV_CODEC_ID_PNG: -type = 0xE; -break; -case AV_CODEC_ID_BMP: -type = 0x1B; -break; -default: -av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x) for cover", - st->codecpar->codec_id); -continue; -} - if (!pos) { pos = avio_tell(pb); avio_wb32(pb, 0); @@ -3459,7 +3453,7 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) } avio_wb32(pb, 16 + trk->cover_image.size); ffio_wfourcc(pb, "data"); -avio_wb32(pb, type); +avio_wb32(pb, trk->tag); avio_wb32(pb , 0); avio_write(pb, trk->cover_image.data, trk->cover_image.size); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: master | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [64f7db554ee83846f207e82a08946a6a5a6acfe2] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64f7db554ee83846f207e82a08946a6a5a6acfe2 --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 468bad4..8591e8c 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -852,11 +852,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: release/2.5 | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [cfd1bc581099d403b4a70981f508252f3a2e3e31] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 64f7db554ee83846f207e82a08946a6a5a6acfe2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cfd1bc581099d403b4a70981f508252f3a2e3e31 --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index a32c6d6..fd23430 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -739,11 +739,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: release/2.8 | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [aa9ac199b8c7bf28bcd4d4ff1fc7f68e3fff5123] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 64f7db554ee83846f207e82a08946a6a5a6acfe2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa9ac199b8c7bf28bcd4d4ff1fc7f68e3fff5123 --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 45bab1c..9b5864d 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -756,11 +756,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: release/2.4 | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [ec94195b80d9927ebb169f9cebacd7c8834a587b] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 64f7db554ee83846f207e82a08946a6a5a6acfe2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec94195b80d9927ebb169f9cebacd7c8834a587b --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 0184d87..f58b3d3 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -738,11 +738,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: release/2.7 | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [76cb34f7f5b8608670d1998b587ef9e12856ab99] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 64f7db554ee83846f207e82a08946a6a5a6acfe2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=76cb34f7f5b8608670d1998b587ef9e12856ab99 --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 9efa9fc..043a80f 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -751,11 +751,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] mpegencts: Fix overflow in cbr mode period calculations
ffmpeg | branch: release/2.6 | Timo Teräs | Sat Nov 28 08:27:39 2015 +0200| [e8fa0e3ec633f716a53ba78aa5ebe37dd69694cb] | committer: Michael Niedermayer mpegencts: Fix overflow in cbr mode period calculations ts->mux_rate is int (signed 32-bit) type. The period calculations will start to overflow when mux_rate > 5mbps. This fixes overflows by converting first to 64-bit type. Fixes #5044. Signed-off-by: Timo Teräs Signed-off-by: Michael Niedermayer (cherry picked from commit 64f7db554ee83846f207e82a08946a6a5a6acfe2) Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e8fa0e3ec633f716a53ba78aa5ebe37dd69694cb --- libavformat/mpegtsenc.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index cc650bb..4440932 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -751,11 +751,11 @@ static int mpegts_write_header(AVFormatContext *s) ts_st = pcr_st->priv_data; if (ts->mux_rate > 1) { -service->pcr_packet_period = (ts->mux_rate * ts->pcr_period) / +service->pcr_packet_period = (int64_t)ts->mux_rate * ts->pcr_period / (TS_PACKET_SIZE * 8 * 1000); -ts->sdt_packet_period = (ts->mux_rate * SDT_RETRANS_TIME) / +ts->sdt_packet_period = (int64_t)ts->mux_rate * SDT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); -ts->pat_packet_period = (ts->mux_rate * PAT_RETRANS_TIME) / +ts->pat_packet_period = (int64_t)ts->mux_rate * PAT_RETRANS_TIME / (TS_PACKET_SIZE * 8 * 1000); if (ts->copyts < 1) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog