Encode H265 to hvc1 codec

前端 未结 3 981
醉酒成梦
醉酒成梦 2021-02-04 19:34

Here is the info of my source file:

I want to keep audio quality and just encode the video track so I use this command:

ffmpeg -i INPUT -c:a copy -c:v l         


        
相关标签:
3条回答
  • 2021-02-04 20:03

    Using the latest ffmpeg (N-87630-ge9f9175-tessus or building from HEAD) you can encode to the MP4 version that macOS High Sierra Quicktime requires by using using -tag:v hvc1.

    If you have a hev1-based mp4 and you need the container to be hvc1 and you do not want to re-encode it:

    ffmpeg -i input-hev1.mp4 -c:v copy -tag:v hvc1 -c:a copy output-hvc1.mp4
    

    Use ffprobe to confirm the change:

    From:

    ~~~~
    Stream #0:0(eng): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv, progressive), 720x404, 164 kb/s, 29.97 fps,
    ~~~~
    

    To:

    ~~~~
    Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, progressive), 720x404, 164 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 29.97 tbc (default)
    ~~~~
    

    If you have an older avc1 based mp4, you will need to re-encode it.

    ffprobe example (avc1):

    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x540 [SAR 1:1 DAR 16:9], 2778 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
    

    Encoding Example:

    ffmpeg 
        -i input.mp4 \
        -c:v libx265 \
        -preset slow \
        -vf scale="720:trunc(ow/a/2)*2" \
        -crf 28 \
        -tag:v hvc1 \
        -c:a aac -b:a 44100 \
        output-hvc1.mp4
    

    The key is the -tag:v hvc1, without that you will end up with an hev1-based container that Quicktime 10.4+ (High Sierra) will not open.

    0 讨论(0)
  • 2021-02-04 20:19

    Add -tag:v hvc1 as @SushiHangover's answer and -bsf:v hevc_mp4toannexb to ffmpeg command(version 3.4 and later). That will create a QuickTime-compatible mov file.

    ffmpeg -i input-hev1.mp4 -c:v copy -tag:v hvc1 -bsf:v hevc_mp4toannexb
    -c:a copy output-hvc1.mov
    
    0 讨论(0)
  • 2021-02-04 20:20

    'hev1'/'hvc1' are code points used to signal different packaging of the stream in the container mp4 file. There is no change in the coding itself. It is possible to round trip between the two modes. Try with mp4box :

    mp4box -raw 1 file.mp4 
    

    This will extract the stream into a raw HEVC file.

    mp4box -add file_track1.hvc output.mp4
    

    This will reimport the stream using hvc1 if it can.

    0 讨论(0)
提交回复
热议问题