diff mbox series

[FFmpeg-devel] libavformat/movenc: add support for HEVC in .3gp

Message ID HK0PR06MB304496A91D4C2B30164F98C4C1CC0@HK0PR06MB3044.apcprd06.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel] libavformat/movenc: add support for HEVC in .3gp | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

sunzhenliang Dec. 9, 2020, 5:36 a.m. UTC
From: SunZhenliang <hisunzhenliang@outlook.com>

Just add HEVC's tag in 3gp tag list and it works to support HEVC in
3gp files.

Signed-off-by: SunZhenliang <hisunzhenliang@outlook.com>
---
 libavformat/movenc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Gyan Doshi Dec. 9, 2020, 10:04 a.m. UTC | #1
On 09-12-2020 11:06 am, hisunzhenliang@outlook.com wrote:
> From: SunZhenliang <hisunzhenliang@outlook.com>
>
> Just add HEVC's tag in 3gp tag list and it works to support HEVC in
> 3gp files.

1) Is there official documentation for this support?
2) Any constraints on codec parameters?

Regards,
Gyan
Jan Ekström Dec. 9, 2020, 3:02 p.m. UTC | #2
On Wed, Dec 9, 2020 at 4:34 PM Sun Zhenliang <hisunzhenliang@outlook.com> wrote:
>
> 1) 3GPP TS 26.244 V16.1.0 (2020-09)  and ISO/IEC 14496-15: "Information technology – Coding of audio-visual objects – Part 15: Carriage of NAL unit structured video in the ISO base media file format"   states HEVC's sample entry in 3GPP file format. I think these documentations says we can store hevc in 3gp files.
>

The document seems to be available at:
https://www.etsi.org/deliver/etsi_ts/126200_126299/126244/16.01.00_60/ts_126244v160100p.pdf

And seems to just refer to the "H.265 (HEVC) file format", which is
effectively what's under 14496-15 now.

Thus I would say that it'd be fine to just add both 'hev1' and 'hvc1'
there, as both are specifically mentioned at multiple points in the
specification

Best regards,
Jan
sunzhenliang Dec. 9, 2020, 3:30 p.m. UTC | #3
I agree that it'd be fine to add those two tags of hevc there.

Thanks for your review.

Regards,
SunZhenliang
Gyan Doshi Dec. 9, 2020, 4:06 p.m. UTC | #4
On 09-12-2020 07:33 pm, Sun Zhenliang wrote:
> 1) 3GPP TS 26.244 V16.1.0 (2020-09)  and ISO/IEC 14496-15: "Information technology – Coding of audio-visual objects – Part 15: Carriage of NAL unit structured video in the ISO base media file format"   states HEVC's sample entry in 3GPP file format. I think these documentations says we can store hevc in 3gp files.

Ok. How should the major and minor brands be set? See the function 
mov_write_ftyp_tag_internal(), starting lines 4933. There might be some 
modifications for HEVC as well.


> 2) I just found that I could encode hevc into 3gp files by adding tags to 3GP tag list. By just adding one line, ffmpeg could make 3gp file with hevc and ffplay can also play it correctly. That's enough for me.  Because I don't set parameters very much, I didn't find any parameter restrictions.

ffplay / libavformat is not very picky and won't be the common player 
consuming these files once this is merged.


Regards,
Gyan
Gyan Doshi Dec. 10, 2020, 6:31 a.m. UTC | #5
Patchwork hasn't picked it up. Send without non-Latin characters, and as 
plaintext encoding, same as your original patch.

Regards,
Gyan

On 10-12-2020 11:41 am, Sun Zhenliang wrote:
>    In 3GPP TS 26.244 V16.1.0 (2020-09) 5.3 and 5.4, there was no clear explanation of HEVC bands. But I think it's fine to use h264 bands, due to 5.5 in  3GPP TS 26.244.
>
> these modifications should be enough.
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 8715cb6e5c..2dd8c8789d 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -4923,7 +4923,7 @@ static int mov_write_mdat_tag(AVIOContext *pb, MOVMuxContext *mov)
> }
>
> static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s,
> -                                        int has_h264, int has_video, int write_minor)
> +                                        int has_h26_, int has_video, int write_minor)
> {
>      MOVMuxContext *mov = s->priv_data;
>      int minor = 0x200;
> @@ -4931,11 +4931,11 @@ static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s,
>      if (mov->major_brand && strlen(mov->major_brand) >= 4)
>          ffio_wfourcc(pb, mov->major_brand);
>      else if (mov->mode == MODE_3GP) {
> -        ffio_wfourcc(pb, has_h264 ? "3gp6"  : "3gp4");
> -        minor =     has_h264 ?   0x100 :   0x200;
> +        ffio_wfourcc(pb, has_h26_ ? "3gp6"  : "3gp4");
> +        minor =     has_h26_ ?   0x100 :   0x200;
>      } else if (mov->mode & MODE_3G2) {
> -        ffio_wfourcc(pb, has_h264 ? "3g2b"  : "3g2a");
> -        minor =     has_h264 ? 0x20000 : 0x10000;
> +        ffio_wfourcc(pb, has_h26_ ? "3g2b"  : "3g2a");
> +        minor =     has_h26_ ? 0x20000 : 0x10000;
>      } else if (mov->mode == MODE_PSP)
>          ffio_wfourcc(pb, "MSNV");
>      else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_FRAGMENT &&
> @@ -4964,7 +4964,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
> {
>      MOVMuxContext *mov = s->priv_data;
>      int64_t pos = avio_tell(pb);
> -    int has_h264 = 0, has_av1 = 0, has_video = 0;
> +    int has_h264 = 0, has_h265 = 0, has_av1 = 0, has_video = 0;
>      int i;
>
>      for (i = 0; i < s->nb_streams; i++) {
> @@ -4975,6 +4975,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>              has_video = 1;
>          if (st->codecpar->codec_id == AV_CODEC_ID_H264)
>              has_h264 = 1;
> +        if (st->codecpar->codec_id == AV_CODEC_ID_H265)
> +            has_h265 = 1;
>          if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
>              has_av1 = 1;
>      }
> @@ -4983,9 +4985,9 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>      ffio_wfourcc(pb, "ftyp");
>
>      // Write major brand
> -    mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 1);
> +    mov_write_ftyp_tag_internal(pb, s, has_h264 || has_h265 , has_video, 1);
>      // Write the major brand as the first compatible brand as well
> -    mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0);
> +    mov_write_ftyp_tag_internal(pb, s, has_h264 || has_h265, has_video, 0);
>
>      // Write compatible brands, ensuring that we don't write the major brand as a
>      // compatible brand a second time.
> @@ -5018,6 +5020,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>              ffio_wfourcc(pb, "iso2");
>              if (has_h264)
>                  ffio_wfourcc(pb, "avc1");
> +            if (has_h265)
> +                ffio_wfourcc(pb, "hev1");
>          }
>      }
>
>
>
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 18fa3f9b5e..8715cb6e5c 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -7103,6 +7103,7 @@ static int mov_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
> static const AVCodecTag codec_3gp_tags[] = {
>      { AV_CODEC_ID_H263,     MKTAG('s','2','6','3') },
>      { AV_CODEC_ID_H264,     MKTAG('a','v','c','1') },
> +    { AV_CODEC_ID_HEVC,     MKTAG('h','e','v','1') },
>      { AV_CODEC_ID_MPEG4,    MKTAG('m','p','4','v') },
>      { AV_CODEC_ID_AAC,      MKTAG('m','p','4','a') },
>      { AV_CODEC_ID_AMR_NB,   MKTAG('s','a','m','r') },
>
> Regards,
> SunZhenliang
>
> ________________________________
> 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 Gyan Doshi <ffmpeg@gyani.pro>
> 发送时间: 2020年12月10日 00:06
> 收件人: ffmpeg-devel@ffmpeg.org <ffmpeg-devel@ffmpeg.org>
> 主题: Re: [FFmpeg-devel] 回复: [PATCH] libavformat/movenc: add support for HEVC in .3gp
>
>
>
> On 09-12-2020 07:33 pm, Sun Zhenliang wrote:
>> 1) 3GPP TS 26.244 V16.1.0 (2020-09)  and ISO/IEC 14496-15: "Information technology – Coding of audio-visual objects – Part 15: Carriage of NAL unit structured video in the ISO base media file format"   states HEVC's sample entry in 3GPP file format. I think these documentations says we can store hevc in 3gp files.
> Ok. How should the major and minor brands be set? See the function
> mov_write_ftyp_tag_internal(), starting lines 4933. There might be some
> modifications for HEVC as well.
>
>
>> 2) I just found that I could encode hevc into 3gp files by adding tags to 3GP tag list. By just adding one line, ffmpeg could make 3gp file with hevc and ffplay can also play it correctly. That's enough for me.  Because I don't set parameters very much, I didn't find any parameter restrictions.
> ffplay / libavformat is not very picky and won't be the common player
> consuming these files once this is merged.
>
>
> Regards,
> Gyan
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 18fa3f9b5e..8715cb6e5c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7103,6 +7103,7 @@  static int mov_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
 static const AVCodecTag codec_3gp_tags[] = {
     { AV_CODEC_ID_H263,     MKTAG('s','2','6','3') },
     { AV_CODEC_ID_H264,     MKTAG('a','v','c','1') },
+    { AV_CODEC_ID_HEVC,     MKTAG('h','e','v','1') },
     { AV_CODEC_ID_MPEG4,    MKTAG('m','p','4','v') },
     { AV_CODEC_ID_AAC,      MKTAG('m','p','4','a') },
     { AV_CODEC_ID_AMR_NB,   MKTAG('s','a','m','r') },