Skip to content

Commit

Permalink
fix: clean up and add --rm back for video downloading
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Wang <[email protected]>
  • Loading branch information
jim-wang-intel committed Jan 12, 2024
1 parent 7e7fc6c commit 8a8d001
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions benchmark-scripts/format_avc_mp4.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (C) 2023 Intel Corporation.
# Copyright (C) 2024 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down Expand Up @@ -68,7 +68,6 @@ fi

if [ ! -f ../sample-media/$1 ] && [ ! -f ../sample-media/$result ]
then
echo "before wget $1 $2"
wget -O ../sample-media/$1 $2
ls -alR ../sample-media/
fi
Expand All @@ -85,44 +84,12 @@ fi
echo "$WIDTH $HEIGHT $FPS"
SAMPLE_MEDIA_DIR="$PWD"/../sample-media
echo "SAMPLE_MEDIA_DIR:$SAMPLE_MEDIA_DIR"
echo docker run --privileged --user root -e VIDEO_FILE="$1" -e DISPLAY=:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$SAMPLE_MEDIA_DIR"/:/vids \
-w /vids -t intel/dlstreamer:2023.0.0-ubuntu22-gpu682-dpcpp \
bash -c "if [ -f /vids/$result ]; then echo 'error for '$result; exit 1; else ls -al /vids/; gst-launch-1.0 filesrc location=/vids/$1 ! qtdemux ! h264parse ! vaapih264dec ! vaapipostproc width=$WIDTH height=$HEIGHT ! videorate ! 'video/x-raw, framerate=$FPS/1' ! vaapih264enc ! h264parse ! mp4mux ! filesink location=/vids/$result; fi"

docker run --privileged --user root -e VIDEO_FILE="$1" -e DISPLAY=:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$SAMPLE_MEDIA_DIR"/:/vids \
-w /vids -t intel/dlstreamer:2023.0.0-ubuntu22-gpu682-dpcpp \
-w /vids -t --rm intel/dlstreamer:2023.0.0-ubuntu22-gpu682-dpcpp \
bash -c "if [ -f /vids/$result ]; then echo 'error for '$result; exit 1; else ls -al /vids/; gst-launch-1.0 filesrc location=/vids/$1 ! qtdemux ! h264parse ! vaapih264dec ! vaapipostproc width=$WIDTH height=$HEIGHT ! videorate ! 'video/x-raw, framerate=$FPS/1' ! vaapih264enc ! h264parse ! mp4mux ! filesink location=/vids/$result; fi"

echo "Result will be created in ../sample-media/$result"

# clean up the original one with waiting logic as now the docker from format_avc_mp4.sh is running on a separate thread
max_retries=50
retry=0
foundConverted=0
while [ $foundConverted -eq 0 ]
do
if [ $retry -ge $max_retries ]
then
echo "ERROR: cannot find all converted video files after retries, docker conversion may have been failed..."
exit 1
fi

echo "checking presence of all the converted video files..."

foundConverted=0

if [ -f "$SAMPLE_MEDIA_DIR/$result" ]
then
echo "found converted video file"
foundConverted=1
else
echo "could not find converted video file yet, will retry it again"
fi
retry=$(( retry + 1 ))
sleep 1
done
rm ../sample-media/"$1"

0 comments on commit 8a8d001

Please sign in to comment.