Add FATE tests exercising the -json_cmd, -json_cmd_print, and -json_cmd_gen features introduced in previous patches.
Tests cover: - json_cmd execution with filter_complex and lavfi inputs - json_cmd_print output for simple options, array values (repeated -map), and mixed value types (boolean true as flag, false/null skipped, numbers converted to strings) - json_cmd_gen CLI-to-JSON conversion - Full roundtrip: json_cmd_gen -> json_cmd execution Signed-off-by: Tom Vaughan [email protected]<mailto:[email protected]> --- tests/Makefile | 7 ++- tests/fate/json_cmd.mak | 54 +++++++++++++++++++++++ tests/json_cmd/filter_complex | 20 +++++++++ tests/json_cmd/lavfi | 20 +++++++++ tests/json_cmd/print_arrays | 21 +++++++++ tests/json_cmd/print_simple | 23 ++++++++++ tests/json_cmd/value_types | 30 +++++++++++++ tests/ref/fate/json_cmd-filter_complex | 10 +++++ tests/ref/fate/json_cmd-gen-simple | 14 ++++++ tests/ref/fate/json_cmd-lavfi | 10 +++++ tests/ref/fate/json_cmd-print-arrays | 1 + tests/ref/fate/json_cmd-print-simple | 1 + tests/ref/fate/json_cmd-print-value_types | 1 + tests/ref/fate/json_cmd-roundtrip | 10 +++++ 14 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 tests/fate/json_cmd.mak create mode 100644 tests/json_cmd/filter_complex create mode 100644 tests/json_cmd/lavfi create mode 100644 tests/json_cmd/print_arrays create mode 100644 tests/json_cmd/print_simple create mode 100644 tests/json_cmd/value_types create mode 100644 tests/ref/fate/json_cmd-filter_complex create mode 100644 tests/ref/fate/json_cmd-gen-simple create mode 100644 tests/ref/fate/json_cmd-lavfi create mode 100644 tests/ref/fate/json_cmd-print-arrays create mode 100644 tests/ref/fate/json_cmd-print-simple create mode 100644 tests/ref/fate/json_cmd-print-value_types create mode 100644 tests/ref/fate/json_cmd-roundtrip diff --git a/tests/Makefile b/tests/Makefile index 4b3fa6a54a..75ef12da1d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -23,7 +23,7 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF) $(AREF): CMP= APITESTSDIR := tests/api -FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs tests/data/maps tests/data/streamgroups tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 $(APITESTSDIR) +FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs tests/data/json_cmd tests/data/maps tests/data/streamgroups tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 $(APITESTSDIR) OUTDIRS += $(FATE_OUTDIRS) $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1 @@ -57,6 +57,10 @@ tests/data/filtergraphs/%: TAG = COPY tests/data/filtergraphs/%: $(SRC_PATH)/tests/filtergraphs/% | tests/data/filtergraphs $(M)cp $< $@ +tests/data/json_cmd/%: TAG = COPY +tests/data/json_cmd/%: $(SRC_PATH)/tests/json_cmd/% | tests/data/json_cmd + $(M)cp $< $@ + tests/data/maps/%: TAG = COPY tests/data/maps/%: $(SRC_PATH)/tests/maps/% | tests/data/maps $(M)cp $< $@ @@ -207,6 +211,7 @@ include $(SRC_PATH)/tests/fate/image.mak include $(SRC_PATH)/tests/fate/imf.mak include $(SRC_PATH)/tests/fate/indeo.mak include $(SRC_PATH)/tests/fate/jpeg2000.mak +include $(SRC_PATH)/tests/fate/json_cmd.mak include $(SRC_PATH)/tests/fate/jxl.mak include $(SRC_PATH)/tests/fate/libavcodec.mak include $(SRC_PATH)/tests/fate/libavdevice.mak diff --git a/tests/fate/json_cmd.mak b/tests/fate/json_cmd.mak new file mode 100644 index 0000000000..5dde92a66a --- /dev/null +++ b/tests/fate/json_cmd.mak @@ -0,0 +1,54 @@ +# JSON command file tests +# +# These tests exercise the -json_cmd, -json_cmd_print, and -json_cmd_gen +# features of ffmpeg, which allow specifying command-line options via a +# JSON file. + +FFMPEG_JSON_CMD = ffmpeg$(PROGSSUF)$(EXESUF) + +# -json_cmd execution tests: parse JSON and run ffmpeg +# The JSON fixtures include all flags (nostdin, bitexact, etc.) since +# -json_cmd bypasses the normal option-injection path. + +FATE_JSON_CMD-$(call FILTERFRAMECRC, COLOR) += fate-json_cmd-filter_complex +fate-json_cmd-filter_complex: tests/data/json_cmd/filter_complex +fate-json_cmd-filter_complex: CMD = run $(FFMPEG_JSON_CMD) -json_cmd $(TARGET_PATH)/tests/data/json_cmd/filter_complex + +FATE_JSON_CMD-$(call FILTERFRAMECRC, COLOR) += fate-json_cmd-lavfi +fate-json_cmd-lavfi: tests/data/json_cmd/lavfi +fate-json_cmd-lavfi: CMD = run $(FFMPEG_JSON_CMD) -json_cmd $(TARGET_PATH)/tests/data/json_cmd/lavfi + +# -json_cmd_print tests: parse JSON and print the equivalent shell command + +FATE_JSON_CMD-yes += fate-json_cmd-print-simple +fate-json_cmd-print-simple: tests/data/json_cmd/print_simple +fate-json_cmd-print-simple: CMD = run $(FFMPEG_JSON_CMD) -json_cmd_print $(TARGET_PATH)/tests/data/json_cmd/print_simple + +FATE_JSON_CMD-yes += fate-json_cmd-print-arrays +fate-json_cmd-print-arrays: tests/data/json_cmd/print_arrays +fate-json_cmd-print-arrays: CMD = run $(FFMPEG_JSON_CMD) -json_cmd_print $(TARGET_PATH)/tests/data/json_cmd/print_arrays + +FATE_JSON_CMD-yes += fate-json_cmd-print-value_types +fate-json_cmd-print-value_types: tests/data/json_cmd/value_types +fate-json_cmd-print-value_types: CMD = run $(FFMPEG_JSON_CMD) -json_cmd_print $(TARGET_PATH)/tests/data/json_cmd/value_types + +# -json_cmd_gen test: convert CLI options to JSON + +FATE_JSON_CMD-yes += fate-json_cmd-gen-simple +fate-json_cmd-gen-simple: CMD = run $(FFMPEG_JSON_CMD) -json_cmd_gen -filter_complex color=d=1:r=5 -fflags +bitexact -f framecrc - + +# Roundtrip test: json_cmd_gen -> json_cmd (execution) +# Generate JSON from CLI args, write to temp file, then execute via -json_cmd +# and compare framecrc output to the known reference. + +FATE_JSON_CMD-$(call FILTERFRAMECRC, COLOR) += fate-json_cmd-roundtrip +fate-json_cmd-roundtrip: CMD = run $(FFMPEG_JSON_CMD) \ + -json_cmd_gen -nostdin -nostats -noauto_conversion_filters -cpuflags all \ + -filter_complex color=d=1:r=5 -fflags +bitexact -bitexact -f framecrc - \ + >$(TARGET_PATH)/tests/data/fate/json_cmd-roundtrip.json ; \ + run $(FFMPEG_JSON_CMD) -json_cmd $(TARGET_PATH)/tests/data/fate/json_cmd-roundtrip.json + +FATE_JSON_CMD += $(FATE_JSON_CMD-yes) +FATE_FFMPEG += $(FATE_JSON_CMD) + +fate-json_cmd: $(FATE_JSON_CMD) diff --git a/tests/json_cmd/filter_complex b/tests/json_cmd/filter_complex new file mode 100644 index 0000000000..50557ebcc6 --- /dev/null +++ b/tests/json_cmd/filter_complex @@ -0,0 +1,20 @@ +{ + "global_options": { + "nostdin": true, + "nostats": true, + "noauto_conversion_filters": true, + "cpuflags": "all", + "filter_complex": "color=d=1:r=5", + "fflags": "+bitexact", + "bitexact": true + }, + "inputs": [], + "outputs": [ + { + "url": "-", + "options": { + "f": "framecrc" + } + } + ] +} diff --git a/tests/json_cmd/lavfi b/tests/json_cmd/lavfi new file mode 100644 index 0000000000..9852adac13 --- /dev/null +++ b/tests/json_cmd/lavfi @@ -0,0 +1,20 @@ +{ + "global_options": { + "nostdin": true, + "nostats": true, + "noauto_conversion_filters": true, + "cpuflags": "all", + "lavfi": "color=d=1:r=5", + "fflags": "+bitexact", + "bitexact": true + }, + "inputs": [], + "outputs": [ + { + "url": "-", + "options": { + "f": "framecrc" + } + } + ] +} diff --git a/tests/json_cmd/print_arrays b/tests/json_cmd/print_arrays new file mode 100644 index 0000000000..b382de6bba --- /dev/null +++ b/tests/json_cmd/print_arrays @@ -0,0 +1,21 @@ +{ + "global_options": { + "y": true + }, + "inputs": [ + { + "url": "input.mp4", + "options": {} + } + ], + "outputs": [ + { + "url": "output.mp4", + "options": { + "map": ["0:v", "0:a"], + "c:v": "copy", + "c:a": "copy" + } + } + ] +} diff --git a/tests/json_cmd/print_simple b/tests/json_cmd/print_simple new file mode 100644 index 0000000000..7231956c09 --- /dev/null +++ b/tests/json_cmd/print_simple @@ -0,0 +1,23 @@ +{ + "global_options": { + "y": true, + "loglevel": "error" + }, + "inputs": [ + { + "url": "input.mp4", + "options": { + "ss": "10" + } + } + ], + "outputs": [ + { + "url": "output.mkv", + "options": { + "c:v": "libx264", + "t": "30" + } + } + ] +} diff --git a/tests/json_cmd/value_types b/tests/json_cmd/value_types new file mode 100644 index 0000000000..0399395483 --- /dev/null +++ b/tests/json_cmd/value_types @@ -0,0 +1,30 @@ +{ + "global_options": { + "y": true, + "nostdin": true, + "loglevel": "error", + "nostats": true + }, + "inputs": [ + { + "url": "input.mp4", + "options": { + "t": 30, + "accurate_seek": true, + "noautorotate": true, + "skip_option": false, + "null_option": null + } + } + ], + "outputs": [ + { + "url": "output.mp4", + "options": { + "c:v": "libx264", + "crf": 23, + "movflags": "+faststart" + } + } + ] +} diff --git a/tests/ref/fate/json_cmd-filter_complex b/tests/ref/fate/json_cmd-filter_complex new file mode 100644 index 0000000000..d85a4aa52f --- /dev/null +++ b/tests/ref/fate/json_cmd-filter_complex @@ -0,0 +1,10 @@ +#tb 0: 1/5 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x375ec573 +0, 1, 1, 1, 115200, 0x375ec573 +0, 2, 2, 1, 115200, 0x375ec573 +0, 3, 3, 1, 115200, 0x375ec573 +0, 4, 4, 1, 115200, 0x375ec573 diff --git a/tests/ref/fate/json_cmd-gen-simple b/tests/ref/fate/json_cmd-gen-simple new file mode 100644 index 0000000000..425f74293e --- /dev/null +++ b/tests/ref/fate/json_cmd-gen-simple @@ -0,0 +1,14 @@ +{ + "global_options": { + "filter_complex": "color=d=1:r=5", + "fflags": "+bitexact", + "f": "framecrc" + }, + "inputs": [], + "outputs": [ + { + "url": "-", + "options": {} + } + ] +} diff --git a/tests/ref/fate/json_cmd-lavfi b/tests/ref/fate/json_cmd-lavfi new file mode 100644 index 0000000000..d85a4aa52f --- /dev/null +++ b/tests/ref/fate/json_cmd-lavfi @@ -0,0 +1,10 @@ +#tb 0: 1/5 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x375ec573 +0, 1, 1, 1, 115200, 0x375ec573 +0, 2, 2, 1, 115200, 0x375ec573 +0, 3, 3, 1, 115200, 0x375ec573 +0, 4, 4, 1, 115200, 0x375ec573 diff --git a/tests/ref/fate/json_cmd-print-arrays b/tests/ref/fate/json_cmd-print-arrays new file mode 100644 index 0000000000..adc8012460 --- /dev/null +++ b/tests/ref/fate/json_cmd-print-arrays @@ -0,0 +1 @@ +ffmpeg -y -i input.mp4 -map 0:v -map 0:a -c:v copy -c:a copy output.mp4 diff --git a/tests/ref/fate/json_cmd-print-simple b/tests/ref/fate/json_cmd-print-simple new file mode 100644 index 0000000000..1876f42192 --- /dev/null +++ b/tests/ref/fate/json_cmd-print-simple @@ -0,0 +1 @@ +ffmpeg -y -loglevel error -ss 10 -i input.mp4 -c:v libx264 -t 30 output.mkv diff --git a/tests/ref/fate/json_cmd-print-value_types b/tests/ref/fate/json_cmd-print-value_types new file mode 100644 index 0000000000..923d6a4089 --- /dev/null +++ b/tests/ref/fate/json_cmd-print-value_types @@ -0,0 +1 @@ +ffmpeg -y -nostdin -loglevel error -nostats -t 30 -accurate_seek -noautorotate -i input.mp4 -c:v libx264 -crf 23 -movflags +faststart output.mp4 diff --git a/tests/ref/fate/json_cmd-roundtrip b/tests/ref/fate/json_cmd-roundtrip new file mode 100644 index 0000000000..d85a4aa52f --- /dev/null +++ b/tests/ref/fate/json_cmd-roundtrip @@ -0,0 +1,10 @@ +#tb 0: 1/5 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +0, 0, 0, 1, 115200, 0x375ec573 +0, 1, 1, 1, 115200, 0x375ec573 +0, 2, 2, 1, 115200, 0x375ec573 +0, 3, 3, 1, 115200, 0x375ec573 +0, 4, 4, 1, 115200, 0x375ec573 -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
