FileConverter icon indicating copy to clipboard operation
FileConverter copied to clipboard

Add Commands Before Input File in Advanced Mode

Open locuturus opened this issue 6 months ago • 1 comments

Is your feature request related to a problem? Please describe. I'm trying to use the advanced options to force av1_qsv on my intel Arc system. From what I see this should be supported by the ffmpeg build, but all qsv encoders appear to default to the iGPU on my system. So h264_qsv works fine, example: -c:v h264_qsv -global_quality 18 -rdo 1 -preset:v slow

But the iGPU doesn't support av1 so it fails. I attempted to select the discrete A770 with -init_hw_device and so on but these commands are placed after the -i command and it complains of trailing options and doesn't generate an output file (although it appears to succeed at first).

Example advanced options: -v verbose -init_hw_device qsv=arc:0 -filter_hw_device arc -vf format=nv12,hwupload=extra_hw_frames=64 -c:v av1_qsv -q:v 32 -c:a libopus -b:a 128k -vbr

Which is passed to ffmpeg as: ffmpeg.exe -n -stats -i "D:\dir\Video.mp4" -v verbose -init_hw_device qsv=arc:0 -filter_hw_device arc -vf format=nv12,hwupload=extra_hw_frames=64 -c:v av1_qsv -q:v 32 -c:a libopus -b:a 128k -vbr "D:\dir\Video.webm"

And the log:

ffmpeg output: ffmpeg version 7.1-essentials_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
ffmpeg output:   built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
ffmpeg output:   configuration: (long list)
ffmpeg output:   libavutil      59. 39.100 / 59. 39.100
ffmpeg output:   libavcodec     61. 19.100 / 61. 19.100
ffmpeg output:   libavformat    61.  7.100 / 61.  7.100
ffmpeg output:   libavdevice    61.  3.100 / 61.  3.100
ffmpeg output:   libavfilter    10.  4.100 / 10.  4.100
ffmpeg output:   libswscale      8.  3.100 /  8.  3.100
ffmpeg output:   libswresample   5.  3.100 /  5.  3.100
ffmpeg output:   libpostproc    58.  3.100 / 58.  3.100
ffmpeg output: Trailing option(s) found in the command: may be ignored.
ffmpeg output: [AVHWDeviceContext @ 000001d90552f140] Defaulting child_device_type to AV_HWDEVICE_TYPE_D3D11VA for oneVPL.Please explicitly set child device type via "-init_hw_device" option if needed.
ffmpeg output: [AVHWDeviceContext @ 000001d905531200] Selecting d3d11va adapter 0
ffmpeg output: [AVHWDeviceContext @ 000001d905531200] Using device 8086:46a6 (Intel(R) Iris(R) Xe Graphics).
ffmpeg output: [AVHWDeviceContext @ 000001d90552f140] Use Intel(R) oneVPL to create MFX session, API version is 2.13, the required implementation version is 1.3
ffmpeg output: [AVHWDeviceContext @ 000001d90552f140] Initialize MFX session: implementation version is 2.15
ffmpeg output: [h264 @ 000001d90555a600] Reinit context to 3840x2160, pix_fmt: yuv420p
ffmpeg output: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\dir\Video.mp4':
ffmpeg output:   Metadata:
ffmpeg output:     major_brand     : mp42
ffmpeg output:     minor_version   : 0
ffmpeg output:     compatible_brands: isommp42
ffmpeg output:     creation_time   : 2024-10-05T07:48:47.000000Z
ffmpeg output:     location        : +47.6141-122.3233/
ffmpeg output:     location-eng    : +47.6141-122.3233/
ffmpeg output:     com.android.version: 14
ffmpeg output:   Duration: 00:00:10.24, start: 0.000000, bitrate: 60357 kb/s
ffmpeg output:   Stream #0:0[0x1](eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default)
ffmpeg output:       Metadata:
ffmpeg output:         creation_time   : 2024-10-05T07:48:47.000000Z
ffmpeg output:         handler_name    : SoundHandle
ffmpeg output:         vendor_id       : [0][0][0][0]
ffmpeg output:   Stream #0:1[0x2](eng): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, progressive, left), 3840x2160, 60195 kb/s, 29.97 fps, 29.97 tbr, 90k tbn (default)
ffmpeg output:       Metadata:
ffmpeg output:         creation_time   : 2024-10-05T07:48:47.000000Z
ffmpeg output:         handler_name    : VideoHandle
ffmpeg output:         vendor_id       : [0][0][0][0]
ffmpeg output:       Side data:
ffmpeg output:         displaymatrix: rotation of -90.00 degrees
ffmpeg output: At least one output file must be specified
ffmpeg output: [AVIOContext @ 000001d90554c7c0] Statistics: 5045844 bytes read, 2 seeks

Conversion Succeed!

Note the lack of encoder logs and the missing output file. From what I can tell this approach cannot work if the input file comes before the hardware selection.

Describe the solution you'd like I don't know if a separate field for commands that should occur before the input file would be best, or a way to explicitly place the input file within the existing text field ala (i) or somesuch approach.

Thanks for your consideration!

locuturus avatar Aug 14 '25 08:08 locuturus

Update - after some (a lot) of testing I've realized that init_hw_device is not needed for my use case. The A770 is simply not available to ffmpeg in any straightforward way unless I connect a monitor to that GPU. After doing that I don't even need to explicitly call the discrete GPU and the av1_qsv encode works as expected.

A minimal example command that works - if a monitor is connected to the A770 - is: -c:v av1_qsv -c:a libopus

For anyone curious the full command I am testing at the moment is: -hide_banner -v verbose -movflags use_metadata_tags -map_metadata 0 -c:v av1_qsv -global_quality:v 32 -pix_fmt p010le -c:a libopus -b:a 128k -vbr on

I still wonder if a feature allowing commands to be placed before the input file is worth looking at, for example if anyone wants to use video filters with the hardware qsv pipeline they would need to be able to set global parameters, but technically my issue above is not a limitation of this software.

locuturus avatar Aug 16 '25 21:08 locuturus