Exporting as FFV1: Change form to support lossless parameters?

I haven’t found any posting that seemed to be what I mean, so I am starting a new topic.

When exporting to FFV1 lossless format, the GUI parameters are “thinking” lossy-only. Similar for PCM uncompressed audio export.

I’m also doing FOSS workshops in the AV field, and I’m always having a hard time explaining “why these fields don’t make sense here” :wink:
When I’m exporting to uncompressed/FFV1 myself, I always feel a bit uneven in my stomach, because “I’m not sure which parameters Shotcut is using exactly… - Except for the custom arguments textfield. That’s awesome!”
Is there anything we could do to facilitate such a patch?

Thank you very much in advance :slight_smile:
And thanks for your great work!

Are you using the export presets? Or do you enter the Advanced settings? The advanced settings require some knowledge of how FFMpeg works. You can right click on an export job to view the generated MLT which includes the parameters that are passed to FFMpeg. Each parameter can be researched in the FFMpeg documentation for the respective codec.

Thanks Brian!

I’m using FFmpeg all the time, and I know FFV1 quite well.
That’s not the issue :slight_smile:

I meant that the actual GUI form fields only reflect parameters for lossy encoding formats.
I’ll attach a screenthos when I’m back on the video editing machine.

Cheers! :smile:

I’m unclear what the request is. Are you wanting to hide the lossy options when a lossless codec is chosen? Or are you wanting to add lossless options to the export screen? If the latter, what options need to be added? Most lossless codecs have very few options, and they are different between codecs.

For the most part, Shotcut does not have code that reconfigures the export screen for every possible combination of codec and parameter setting. That would be a huge and exception-prone list. “Advanced options” implies that the burden is on the user to understand which options have meaning for a given combination. Even though a bitrate field exists, FFV1 doesn’t look for that value, so in effect it will do nothing. I understand that non-applicable fields can be confusing to beginners, but it was called the “Advanced” panel for a reason.

1 Like

One export form for all formats: I thought so :smile:
Totally understand.

And I also think it’s perfectly okay to offer the “enter ffmpeg arguments here, if you know them” option. I like that.

Would it maaaaybeeee be possible to add a bit-flag for “lossless=y/n” to gray out the lossy parameters in a future version? :innocent: :cake:

Thanks for your quick replies!

Yes, it is not too big of a deal to maintain a list of lossless codecs using the output from ffmpeg -codecs. I will probably write a little awk script to keep in the repo to facilitate this (as opposed to running ffmpeg and parsing in C++ on every app launch). We can also keep a list of intra-only to disable GOP and B frames options.

1 Like

Cool. Would libx264 at 100% quality count as true lossless? For all practical purposes of UI, the lossy options could be disabled for ProRes and DNxHD/HR and other intermediate formats as well, so long as the quality parameter was forced to 100%. ProRes will use less than standard bitrate if the quality is set to less than 100%. I’m just brainstorming with you.

NO, basically, these rules will only apply for only lossless or only intra codecs. Give an inch and they ask for a mile. I knew this would be a slippery slope.

1 Like

For sure slippery. :rofl: I wasn’t asking for this feature for myself because I already know the options. My main goal was to anticipate the questions and problems that others might have, to help make a smooth and simple implementation with reasonable and known limitations. If I didn’t ask about libx264, somebody else would.

#!/bin/sh

echo Intra-only video encoders
echo -------------------------
ffmpeg -codecs -hide_banner | awk '(substr($1,2,1) == "E" && substr($1,3,1) == "V" && substr($1,4,1) == "I") {print $2}'

echo
echo Lossless-only video encoders
echo ----------------------------
ffmpeg -codecs -hide_banner | awk '(substr($1,2,1) == "E" && substr($1,3,1) == "V" && substr($1,5,2) == ".S") {print $2}'

echo
echo Lossless-only audio encoders
echo ----------------------------
ffmpeg -codecs -hide_banner | awk '(substr($1,2,1) == "E" && substr($1,3,1) == "A" && substr($1,5,2) == ".S") {print $2}'
Intra-only video encoders
-------------------------
a64_multi
a64_multi5
alias_pix
amv
asv1
asv2
avrp
avui
ayuv
bitpacked
bmp
cljr
dnxhd
dpx
dvvideo
exr
ffvhuff
fits
hdr
huffyuv
jpeg2000
jpegls
ljpeg
magicyuv
mjpeg
pam
pbm
pcx
pfm
pgm
pgmyuv
phm
ppm
prores
qoi
r10k
r210
rawvideo
sgi
speedhq
sunrast
targa
tiff
utvideo
v210
v308
v408
v410
wbmp
webp
xbm
xface
xwd
y41p
yuv4
zlib

Lossless-only video encoders
----------------------------
alias_pix
apng
avrp
avui
ayuv
bitpacked
bmp
dpx
ffv1
ffvhuff
fits
flashsv
gif
huffyuv
ljpeg
magicyuv
pam
pbm
pcx
pfm
pgm
pgmyuv
phm
png
ppm
qoi
qtrle
r10k
r210
rawvideo
sgi
sunrast
targa
tiff
utvideo
v210
v308
v408
v410
wbmp
wrapped_avframe
xbm
xwd
y41p
yuv4
zlib
zmbv

Lossless-only audio encoders
----------------------------
alac
flac
mlp
pcm_bluray
pcm_dvd
pcm_f32be
pcm_f32le
pcm_f64be
pcm_f64le
pcm_s16be
pcm_s16be_planar
pcm_s16le
pcm_s16le_planar
pcm_s24be
pcm_s24daud
pcm_s24le
pcm_s24le_planar
pcm_s32be
pcm_s32le
pcm_s32le_planar
pcm_s64be
pcm_s64le
pcm_s8
pcm_s8_planar
pcm_u16be
pcm_u16le
pcm_u24be
pcm_u24le
pcm_u32be
pcm_u32le
pcm_u8
s302m
truehd
tta

Hi Dan!
Thank you very much for taking time to consider offering something for “lossless- and intra-only” formats.

@Austin: I would not mix “visually lossless” with “mathematically lossless”. :wink:

And I’d be very happy with Dan’s “ffmpeg|awk” switch suggestion.

I think you missed the point. The visually lossless codecs like ProRes and DNxHR do not offer bitrate control or B-frame or GOP options, so it is reasonable to disable the lossy export controls for them as well. The visually lossless codecs are detected and included by Dan’s awk script. I was not trying to make a case that they offer the same export quality.

@Austin: Indeed I have misunderstood you then. Thanks for clearing it up.

1 Like

This is added for the next version 23.11

1 Like

I tested this with the 23.11.01 artifact and it worked well for most codecs! However, there were some alternate encoders and image formats that didn’t get picked up in the scan (prores_ks being a notable one). So, I tweaked the ffmpeg-codecs.sh script and hand-reviewed the results. I can create a pull request if you want. Depending on your review, this would of course impact encodedock.cpp as well.

ffmpeg-codecs.txt (1.0 KB)

#!/bin/sh

# The first cat list is from "ffmpeg -codecs | grep ^..EVI | grep encoders:"
# The second cat list is from "ffmpeg -codecs | grep ^..EV\\.\\.S"
# A codec can be removed from the list by adding "grep -v" before awk.
ffmpeg -codecs -hide_banner | \
grep ^..EVI | \
awk '{print $2}' | \
cat <(printf "\
a64multi\n\
a64multi5\n\
libopenjpeg\n\
libjxl\n\
mjpeg_qsv\n\
mjpeg_vaapi\n\
prores_aw\n\
prores_ks\n\
libwebp_anim\n\
libwebp\n\
") - | \
cat <(printf "\
apng\n\
ffv1\n\
flashsv\n\
gif\n\
msrle\n\
png\n\
qtrle\n\
wrapped_avframe\n\
zmbv\n\
") - | \
sort -u | \
awk '{print "m_intraOnlyCodecs << \"" $1 "\";"}'

echo

# Currently no entries from "ffmpeg -codecs | grep ^..EV.\\.S | grep encoders:"
ffmpeg -codecs -hide_banner | \
awk '(/^..EV.\.S/) {print $2}' | \
sort -u | \
awk '{print "m_losslessVideoCodecs << \"" $1 "\";"}'

echo

# Currently no entries from "ffmpeg -codecs | grep ^..EA.\\.S | grep encoders:"
ffmpeg -codecs -hide_banner | \
awk '(/^..EA.\.S/) {print $2}' | \
sort -u | \
awk '{print "m_losslessAudioCodecs << \"" $1 "\";"}'

You can do everything with awk alone. No need to use grep, pipes, cat, sort, and printf. Sorry, not very interested in maintaining your changes to the script.

My primary interest was seeing if prores_ks, ffv1, png, and qtrle could be added to the current Intra-Only list since they are popular encoders and Shotcut has bundled export presets that use them. My abomination of a script was a modular attempt at being able to regenerate the codec list from scratch if needed (ie, FFmpeg major version upgrade with new codecs released), while preserving any manual overrides to the list (such as the four I mentioned). The code could be much cleaner by using temp files, but I didn’t know how this script fit into the build pipeline, so I made the script output identical to the current version. But again, I have no attachment to that script or the general method. I was mainly interested in the fate of those four codecs. After all, the title of this thread is “Exporting as FFV1” but the current Intra-disable list does not include FFV1 yet. I’m genuinely trying to help and not just be pedantic. :grin:

OK, but it is also more about lossless, and there it is covered. I do see now that ffmpeg -codecs output shows lines with “encoders:” that contains names that supersede the name of the codec in the second column. webp is a good example; there is no webp encoder, only libwebp and libwebp_anim. As for ffv1 being intra-only, it does not show in the list. This Wikipedia paragraph explains that, and this:
https://trac.ffmpeg.org/wiki/Encode/FFV1#FFV1version31
I was able to expand the awk script to extract “encoders:”. But I am not too keen to hard-codec additional ones that ffmpeg -codecs does not show as intra-only. I am also only using the Shotcut ffmpeg build and not one that includes every library possible such that might be in a distribution package.

1 Like

Understandable on all points. The awk-split code you added is pretty cool. Thanks for revisiting the topic. I don’t plan to go any further down the slippery slope!

FFV1 shows up on the lossless codec lists - but it also can do inter-frame compression, so it is not intra-frame-only :slight_smile: