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

Sun Zhenliang hisunzhenliang at outlook.com
Thu Dec 10 10:12:59 EET 2020


add a new patch.

https://patchwork.ffmpeg.org/project/ffmpeg/patch/SL2PR06MB3052EDB34939522D15655AFFC1CB0@SL2PR06MB3052.apcprd06.prod.outlook.com/

Thanks and regards,
SunZhenliang

________________________________
·¢¼þÈË: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> ´ú±í Gyan Doshi <ffmpeg at gyani.pro>
·¢ËÍʱ¼ä: 2020Äê12ÔÂ10ÈÕ 14:31
ÊÕ¼þÈË: ffmpeg-devel at ffmpeg.org <ffmpeg-devel at ffmpeg.org>
Ö÷Ìâ: Re: [FFmpeg-devel] »Ø¸´: »Ø¸´: [PATCH] libavformat/movenc: add support for HEVC in .3gp

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 at ffmpeg.org> ´ú±í Gyan Doshi <ffmpeg at gyani.pro>
> ·¢ËÍʱ¼ä: 2020Äê12ÔÂ10ÈÕ 00:06
> ÊÕ¼þÈË: ffmpeg-devel at ffmpeg.org <ffmpeg-devel at 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 ¨C Coding of audio-visual objects ¨C 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 at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


More information about the ffmpeg-devel mailing list