Am 11.03.20 um 17:28 schrieb Ulf Zibis:

Am 11.03.20 um 13:50 schrieb Moritz Barsnick:
On Wed, Mar 11, 2020 at 13:25:45 +0100, Ulf Zibis wrote:
Anyway, does my command line have the right syntax?
ffmpeg -i MVI_1324.MOV -c:a copy -c:v h264_vaapi -profile:v
constrained_baseline -level 4.1 MVI_1324.mov
It's syntactically correct, but it won't suffice. You need some more
"trickery" in order to do HW supported encode.

I have little experience myself, so I can only point to this page,
which explains it quite nicely (AFAICT):

https://trac.ffmpeg.org/wiki/Hardware/VAAPI

Thanks for the great pointer.

From this tutorial I get:
$ ~/Projects/ffmpeg/dev_2/ffmpeg -vaapi_device /dev/dri/renderD128 -i
MVI_1324.MOV -c:a copy -vf 'format=nv12,hwupload' -c:v h264_vaapi
-profile:v constrained_baseline -level 4.1 -map_metadata 0 -movflags
+faststart MVI_1324.mov
ffmpeg version N-96935-g34d7c8d942 Copyright (c) 2000-2020 the FFmpeg
developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration:
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 75.100 / 58. 75.100
  libavformat    58. 41.100 / 58. 41.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_1324.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 537331968
    compatible_brands: qt  CAEP
    creation_time   : 2020-02-05T20:17:27.000000Z
  Duration: 00:00:29.10, start: 0.000000, bitrate: 23351 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuvj420p(pc, smpte170m/bt709/bt709), 1280x720, 23228 kb/s,
29.97 fps, 29.97 tbr, 30k tbn, 60k tbc (default)
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z
    Stream #0:1(eng): Audio: pcm_u8 (raw  / 0x20776172), 12000 Hz,
mono, u8, 96 kb/s (default)
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z
File 'MVI_1324.mov' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[swscaler @ 0x561213fdfa80] deprecated pixel format used, make sure you
did set range correctly
[h264_vaapi @ 0x561213e138c0] No usable encoding profile found.
Error initializing output stream 0:0 -- Error while opening encoder for
output stream #0:0 - maybe incorrect parameters such as bit_rate, rate,
width or height
Conversion failed!

Does anyone know, how to set the pixel format correctly?


As it seems there is no chance to make the VAAPI codec running, invested some effort in parametrizing the libx264 codec. So I was able to approximate most oft the properties to the original video from my Canon camera with:

$ ffmpeg -i MVI_1324.MOV -c:a copy -profile:v baseline -level 4.1 -colorspace smpte170m -color_primaries bt709 -color_trc bt709 -refs 1 -g 15 -map_metadata 0 -movflags +faststart MVI_1324_smpte170m_git.mov

Here are the remaining differences:

$ ffprobe MVI_1324.MOV
ffprobe version N-96935-g34d7c8d942 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --enable-libx264 --enable-gpl
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 75.100 / 58. 75.100
  libavformat    58. 41.100 / 58. 41.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_1324.MOV':
  Metadata:
    major_brand     : qt
    minor_version   : 537331968
    compatible_brands: qt  CAEP
    creation_time   : 2020-02-05T20:17:27.000000Z
  Duration: 00:00:29.10, start: 0.000000, bitrate: 23351 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt709/bt709), 1280x720, 23228 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 60k tbc (default)
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z
    Stream #0:1(eng): Audio: pcm_u8 (raw  / 0x20776172), 12000 Hz, mono, u8, 96 kb/s (default)
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z

$ ffprobe MVI_1324_smpte170m_git.mov
ffprobe version N-96935-g34d7c8d942 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --enable-libx264 --enable-gpl
  libavutil      56. 42.100 / 56. 42.100
  libavcodec     58. 75.100 / 58. 75.100
  libavformat    58. 41.100 / 58. 41.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 77.100 /  7. 77.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MVI_1324_smpte170m_git.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512        <=== difference <===
    compatible_brands: qt          <=== difference <===
    creation_time   : 2020-02-05T20:17:27.000000Z
    encoder         : Lavf58.41.100        <=== difference <===
  Duration: 00:00:29.10, start: 0.000000, bitrate: 6474 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuvj420p(pc, smpte170m/bt709/bt709), 1280x720, 6374 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) <=== little difference in tbc <===
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z
      handler_name    : VideoHandler        <=== difference <===
      encoder         : Lavc58.75.100 libx264        <=== difference <===
    Stream #0:1(eng): Audio: pcm_u8 (raw  / 0x20776172), 12000 Hz, mono, u8, 96 kb/s (default)
    Metadata:
      creation_time   : 2020-02-05T20:17:27.000000Z
      handler_name    : SoundHandler        <=== difference <===

$ mediainfo MVI_1324.MOV
General
Complete name                            : MVI_1324.MOV
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   2007.09 (qt /CAEP)
File size                                : 81.0 MiB
Duration                                 : 29 s 96 ms
Overall bit rate                         : 23.4 Mb/s
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=15
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 29 s 96 ms
Bit rate                                 : 23.2 Mb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.841
Stream size                              : 80.6 MiB (99%)
Language                                 : English
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

Audio
ID                                       : 2
Format                                   : PCM
Format settings                          : Little / Unsigned
Codec ID                                 : raw
Duration                                 : 29 s 96 ms
Bit rate mode                            : Constant
Bit rate                                 : 96.0 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 12.0 kHz
Bit depth                                : 8 bits
Stream size                              : 341 KiB (0%)
Language                                 : English
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27

$ mediainfo MVI_1324_smpte170m_git.mov
General
Complete name                            : MVI_1324_smpte170m_git.mov
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   0000.02 (qt )        <=== difference <===
File size                                : 22.5 MiB
Duration                                 : 29 s 96 ms
Overall bit rate                         : 6 474 kb/s
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27
Writing application                      : Lavf58.41.100 <=== difference <===

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : [email protected]
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=15
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 29 s 96 ms
Bit rate                                 : 6 375 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.231
Stream size                              : 22.1 MiB (98%)
Writing library                          : x264 core 152 r2854 e9a5903        <=== difference <=== Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=15 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=15 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 <=== difference <===
Language                                 : English
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.601

Audio
ID                                       : 2
Format                                   : PCM
Format settings                          : Little / Unsigned
Codec ID                                 : raw
Duration                                 : 29 s 96 ms
Bit rate mode                            : Constant
Bit rate                                 : 96.0 kb/s
Channel(s)                               : 1 channel
Channel positions                        : Front: C
Sampling rate                            : 12.0 kHz
Bit depth                                : 8 bits
Stream size                              : 341 KiB (1%)
Language                                 : English
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 2020-02-05 20:17:27
Tagged date                              : UTC 2020-02-05 20:17:27

As you can see, even I set "-profile:v baseline", the result changed to (Constrained Baseline), what is, what I wanted.

Unfortunately the resulting video is still not playable in my camera.

So I bother about:
    minor_version   : 537331968
    compatible_brands: qt  CAEP
and the addition of:
Encoding settings                        : cabac=0 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=15 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=15 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

What is CEAP, and how may I can also approximate those properties?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to