diff --git a/builders/linux/Dockerfile b/builders/linux/Dockerfile index 6c21860..d3f15bb 100644 --- a/builders/linux/Dockerfile +++ b/builders/linux/Dockerfile @@ -27,7 +27,7 @@ RUN apt-get -y update \ libglx-mesa0 libglvnd-dev libxkbcommon-dev libxkbcommon-x11-0 libpulse-dev libxcb1 libx11-xcb1 libxcb-glx0 libxcb-cursor0 \ libxcb-icccm4 libxcb-image0 libxcb-render-util0 libxcb-keysyms1 libicu70 \ python3 python3-pip \ - curl xz-utils xvfb pkg-config \ + curl xz-utils xvfb pkg-config ffmpeg \ fontconfig fonts-liberation ARG QT_VER=6.6.0 diff --git a/src/mediafx/main.cpp b/src/mediafx/main.cpp index dc8f6e7..7573310 100644 --- a/src/mediafx/main.cpp +++ b/src/mediafx/main.cpp @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) command = parser.value(qSL("command")); if (command == "ffplay") { // XXX need to handle audio eventually - command = qSL("ffplay -autoexit -f rawvideo -video_size ${MEDIAFX_FRAMESIZE} -pixel_format rgb0 -framerate ${MEDIAFX_FRAMERATE} -i pipe:${MEDIAFX_VIDEOFD}"); + command = qSL("ffplay -autoexit -infbuf -f rawvideo -video_size ${MEDIAFX_FRAMESIZE} -pixel_format rgb0 -framerate ${MEDIAFX_FRAMERATE} -i pipe:${MEDIAFX_VIDEOFD}"); } else if (command == "ffmpeg") { if (!parser.isSet(qSL("output"))) { parser.showHelp(1); diff --git a/src/mediafx/rate_control.cpp b/src/mediafx/rate_control.cpp index 0cb1522..7df311a 100644 --- a/src/mediafx/rate_control.cpp +++ b/src/mediafx/rate_control.cpp @@ -43,9 +43,9 @@ void RateControl::onVideoFrameRequired() void RateControl::enqueue(const QVideoFrame& videoFrame) { if (videoFrame.startTime() != -1 && videoFrame.endTime() != -1) { - microseconds sourceFrameDuration(videoFrame.endTime() - videoFrame.startTime()); - rateScalar = targetFrameDuration / duration(sourceFrameDuration); - sourceFrameDuration = sourceFrameDuration; + microseconds frameDuration(videoFrame.endTime() - videoFrame.startTime()); + rateScalar = targetFrameDuration / duration(frameDuration); + sourceFrameDuration = frameDuration; } bufferedFrames.enqueue(videoFrame); } diff --git a/src/mediafx/video_clip.cpp b/src/mediafx/video_clip.cpp index e6ba64b..b3aa068 100644 --- a/src/mediafx/video_clip.cpp +++ b/src/mediafx/video_clip.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ void VideoClip::onVideoFrameChanged(const QVideoFrame& frame) } if (microseconds(frame.startTime()) >= frameTimeStart) { rateControl.enqueue(frame); + QMetaObject::invokeMethod(this, &VideoClip::onRateControl, Qt::QueuedConnection); } } diff --git a/tools/JetBrainsMono-Regular.ttf b/tools/JetBrainsMono-Regular.ttf new file mode 100644 index 0000000..dff66cc Binary files /dev/null and b/tools/JetBrainsMono-Regular.ttf differ diff --git a/tools/create-video.sh b/tools/create-video.sh new file mode 100755 index 0000000..87f6bd6 --- /dev/null +++ b/tools/create-video.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Andrew Wason +# +# This file is part of mediaFX. +# +# mediaFX is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. +# +# mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with mediaFX. +# If not, see . + +ROOT=$(dirname "${BASH_SOURCE[0]}") + +ffmpeg -f lavfi -i testsrc=duration=${DURATION:-12}:size=${SIZE:-640x360}:rate=${FRAMERATE:-30}:decimals=2,drawbox=color=${COLOR:-red}:t=ih/16,drawtext=text=f%{frame_num}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:fontcolor=yellow@0.9:fontfile=${ROOT}/JetBrainsMono-Regular.ttf -f nut -vcodec ffv1 -g 1 -level 3 -pix_fmt rgb32 -framerate ${FRAMERATE:-30} -y ${1:?specify output nut filename} \ No newline at end of file diff --git a/tools/create_mov.sh b/tools/create_mov.sh deleted file mode 100755 index 4d8d484..0000000 --- a/tools/create_mov.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -ffmpeg -f lavfi -i testsrc=duration=${DURATION:-12}:size=${SIZE:-640x360}:rate=${FRAMERATE:-30}:decimals=2,drawbox=color=${COLOR:-red}:t=ih/16,drawtext=text=f%{frame_num}:x=w/10:y=x/dar:shadowx=3:shadowy=3:fontsize=h/3.75:fontcolor=yellow@0.9 -f mov -vcodec rawvideo -pix_fmt uyvy422 -framerate ${FRAMERATE:-30} -vtag yuvs -y ${1:?specify output mov filename} \ No newline at end of file diff --git a/tools/diff-video.sh b/tools/diff-video.sh new file mode 100755 index 0000000..830d9e4 --- /dev/null +++ b/tools/diff-video.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Andrew Wason +# +# This file is part of mediaFX. +# +# mediaFX is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. +# +# mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with mediaFX. +# If not, see . +usage="$0 " + +# https://superuser.com/questions/854543/how-to-compare-the-difference-between-2-videos-color-in-ffmpeg +ffplay -autoexit -f lavfi "movie='${1:?$usage}',split[org1][org2]; movie='${2:?$usage}',split[new1][new2]; [org1][new1]blend=all_mode=grainextract[blend];[org2][new2][blend]vstack=inputs=3" \ No newline at end of file diff --git a/tools/framehash.sh b/tools/framehash.sh new file mode 100755 index 0000000..f157d8c --- /dev/null +++ b/tools/framehash.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Andrew Wason +# +# This file is part of mediaFX. +# +# mediaFX is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. +# +# mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with mediaFX. +# If not, see . + +ffmpeg -loglevel error -i ${1:?specify input video} -f framehash -hash md5 -fflags bitexact - diff --git a/tools/hash.sh b/tools/hash.sh new file mode 100755 index 0000000..8919c53 --- /dev/null +++ b/tools/hash.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Copyright (C) 2023 Andrew Wason +# +# This file is part of mediaFX. +# +# mediaFX is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. +# +# mediaFX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with mediaFX. +# If not, see . + +ffmpeg -loglevel error -i ${1:?video file required} -f hash -hash md5 -