Datasets:
Tasks:
Question Answering
Formats:
json
Languages:
English
Size:
< 1K
ArXiv:
Tags:
multimodal
video
howto100m
retrieval-augmented-generation
visual-question-answering
cross-video-understanding
License:
qiuchenwang commited on
Commit ·
35928b7
1
Parent(s): 097c08b
update
Browse files- README.md +8 -0
- split_video.sh +136 -0
README.md
CHANGED
|
@@ -51,6 +51,14 @@ git clone https://huggingface.co/datasets/Alibaba-NLP/XVBench
|
|
| 51 |
|
| 52 |
XVBench provides question-answer annotations and reference clip filenames. To use the benchmark with the original video evidence, please download the corresponding source videos from the [HowTo100M official website](https://www.di.ens.fr/willow/research/howto100m/) and follow the HowTo100M usage instructions. The `video_name` and `reference` fields in `xvbench.jsonl` are used to identify the source video and supporting clips.
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
## Dataset Structure
|
| 55 |
|
| 56 |
The dataset is provided as `xvbench.jsonl`. Each line is a JSON object with the following fields:
|
|
|
|
| 51 |
|
| 52 |
XVBench provides question-answer annotations and reference clip filenames. To use the benchmark with the original video evidence, please download the corresponding source videos from the [HowTo100M official website](https://www.di.ens.fr/willow/research/howto100m/) and follow the HowTo100M usage instructions. The `video_name` and `reference` fields in `xvbench.jsonl` are used to identify the source video and supporting clips.
|
| 53 |
|
| 54 |
+
## Video Preprocess
|
| 55 |
+
|
| 56 |
+
We provide `split_video.sh`, a simplified video preprocessing script following the same fixed-duration splitting strategy as the VRAG video corpus pipeline. It converts non-MP4 videos to temporary MP4 files when needed, splits each source video into 60-second clips by default, and writes filenames in the same format as the `reference` field: `video_id_____1.mp4`, `video_id_____2.mp4`, and so on.
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
./split_video.sh -i /path/to/howto100m/videos -o ./video_chunks -d 60
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
## Dataset Structure
|
| 63 |
|
| 64 |
The dataset is provided as `xvbench.jsonl`. Each line is a JSON object with the following fields:
|
split_video.sh
ADD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DURATION=2
|
| 10 |
+
|
| 11 |
+
usage() {
|
| 12 |
+
cat <<'EOF'
|
| 13 |
+
Usage: ./split_video.sh -i INPUT_DIR [-o OUTPUT_DIR] [-d CHUNK_DURATION]
|
| 14 |
+
|
| 15 |
+
Split videos into fixed-duration chunks for XVBench-style video evidence.
|
| 16 |
+
|
| 17 |
+
Options:
|
| 18 |
+
-i INPUT_DIR Directory containing source videos.
|
| 19 |
+
-o OUTPUT_DIR Directory for output clips. Default: ./video_chunks
|
| 20 |
+
-d CHUNK_DURATION Clip duration in seconds. Default: 60
|
| 21 |
+
-h Show this help message.
|
| 22 |
+
EOF
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
check_dependencies() {
|
| 26 |
+
command -v ffmpeg >/dev/null 2>&1 || { echo "ffmpeg is required." >&2; exit 1; }
|
| 27 |
+
command -v ffprobe >/dev/null 2>&1 || { echo "ffprobe is required." >&2; exit 1; }
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
duration_seconds() {
|
| 31 |
+
ffprobe -v error -show_entries format=duration \
|
| 32 |
+
-of default=noprint_wrappers=1:nokey=1 "$1" 2>/dev/null || echo "0"
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
float_lt() {
|
| 36 |
+
awk -v a="$1" -v b="$2" 'BEGIN { exit !(a < b) }'
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
float_add() {
|
| 40 |
+
awk -v a="$1" -v b="$2" 'BEGIN { printf "%.3f", a + b }'
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
parse_args() {
|
| 44 |
+
while getopts ":i:o:d:h" opt; do
|
| 45 |
+
case "$opt" in
|
| 46 |
+
i) INPUT_DIR="$OPTARG" ;;
|
| 47 |
+
o) OUTPUT_DIR="$OPTARG" ;;
|
| 48 |
+
d) CHUNK_DURATION="$OPTARG" ;;
|
| 49 |
+
h) usage; exit 0 ;;
|
| 50 |
+
*) usage; exit 1 ;;
|
| 51 |
+
esac
|
| 52 |
+
done
|
| 53 |
+
|
| 54 |
+
if [[ -z "$INPUT_DIR" || ! -d "$INPUT_DIR" ]]; then
|
| 55 |
+
echo "A valid input directory is required. Use -i INPUT_DIR." >&2
|
| 56 |
+
exit 1
|
| 57 |
+
fi
|
| 58 |
+
|
| 59 |
+
if ! [[ "$CHUNK_DURATION" =~ ^[0-9]+$ ]] || [[ "$CHUNK_DURATION" -le 0 ]]; then
|
| 60 |
+
echo "CHUNK_DURATION must be a positive integer." >&2
|
| 61 |
+
exit 1
|
| 62 |
+
fi
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
split_one_video() {
|
| 66 |
+
local input_file="$1"
|
| 67 |
+
local filename extension base_name total_duration process_file temp_mp4
|
| 68 |
+
local start_time=0
|
| 69 |
+
local chunk_index=1
|
| 70 |
+
|
| 71 |
+
filename=$(basename "$input_file")
|
| 72 |
+
extension="${filename##*.}"
|
| 73 |
+
extension=$(echo "$extension" | tr '[:upper:]' '[:lower:]')
|
| 74 |
+
base_name="${filename%.*}"
|
| 75 |
+
temp_mp4=""
|
| 76 |
+
|
| 77 |
+
total_duration=$(duration_seconds "$input_file")
|
| 78 |
+
if [[ -z "$total_duration" || "$total_duration" == "0" ]] || float_lt "$total_duration" "$MIN_SOURCE_DURATION"; then
|
| 79 |
+
echo "Skip invalid or too-short video: $filename" >&2
|
| 80 |
+
return 1
|
| 81 |
+
fi
|
| 82 |
+
|
| 83 |
+
if [[ "$extension" != "mp4" ]]; then
|
| 84 |
+
temp_mp4="${OUTPUT_DIR}/.tmp_${base_name}_$$.mp4"
|
| 85 |
+
if ! ffmpeg -i "$input_file" -c:v libx264 -c:a aac -strict experimental \
|
| 86 |
+
"$temp_mp4" -y -loglevel error; then
|
| 87 |
+
rm -f "$temp_mp4"
|
| 88 |
+
echo "Failed to convert video: $filename" >&2
|
| 89 |
+
return 1
|
| 90 |
+
fi
|
| 91 |
+
process_file="$temp_mp4"
|
| 92 |
+
else
|
| 93 |
+
process_file="$input_file"
|
| 94 |
+
fi
|
| 95 |
+
|
| 96 |
+
while float_lt "$start_time" "$total_duration"; do
|
| 97 |
+
local output_file chunk_duration
|
| 98 |
+
output_file="${OUTPUT_DIR}/${base_name}_____${chunk_index}.mp4"
|
| 99 |
+
|
| 100 |
+
if ffmpeg -i "$process_file" -ss "$start_time" -t "$CHUNK_DURATION" \
|
| 101 |
+
-c copy "$output_file" -y -loglevel error; then
|
| 102 |
+
chunk_duration=$(duration_seconds "$output_file")
|
| 103 |
+
if [[ -z "$chunk_duration" ]] || float_lt "$chunk_duration" "$MIN_CHUNK_DURATION"; then
|
| 104 |
+
rm -f "$output_file"
|
| 105 |
+
fi
|
| 106 |
+
else
|
| 107 |
+
rm -f "$output_file"
|
| 108 |
+
echo "Failed to create chunk: $output_file" >&2
|
| 109 |
+
fi
|
| 110 |
+
|
| 111 |
+
start_time=$(float_add "$start_time" "$CHUNK_DURATION")
|
| 112 |
+
chunk_index=$((chunk_index + 1))
|
| 113 |
+
done
|
| 114 |
+
|
| 115 |
+
[[ -n "$temp_mp4" && -f "$temp_mp4" ]] && rm -f "$temp_mp4"
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
main() {
|
| 119 |
+
parse_args "$@"
|
| 120 |
+
check_dependencies
|
| 121 |
+
mkdir -p "$OUTPUT_DIR"
|
| 122 |
+
|
| 123 |
+
while IFS= read -r -d '' input_file; do
|
| 124 |
+
local filename
|
| 125 |
+
filename=$(basename "$input_file")
|
| 126 |
+
if [[ "$filename" =~ _____[0-9]+\.mp4$ ]]; then
|
| 127 |
+
continue
|
| 128 |
+
fi
|
| 129 |
+
split_one_video "$input_file" || true
|
| 130 |
+
done < <(find "$INPUT_DIR" -maxdepth 1 -type f \( \
|
| 131 |
+
-iname "*.mp4" -o -iname "*.avi" -o -iname "*.mkv" -o \
|
| 132 |
+
-iname "*.mov" -o -iname "*.wmv" -o -iname "*.flv" -o \
|
| 133 |
+
-iname "*.webm" \) -print0)
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
main "$@"
|