Git Product home page Git Product logo

ffmpeg-script-generator's Introduction

Github page

https://romander.github.io/ffmpeg-script-generator/

Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

ffmpeg-script-generator's People

Contributors

romander avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

union-gcyjh

ffmpeg-script-generator's Issues

Video offset gets rounded up

Recently I discovered your website which help auto generating command for video fade and audio crossfade, it was a lifesaver for me.
But, theres one critical problem, the video offset. I was joining multiple videos like 4 videos at once and I used your script to fade and acrossfade the videos. Yes it is indeed taking a lot of time to join for almost a week long video, only to find out the audio is not syncing with the video.

I used 1 duration fade for the setting, and found out it can delay for like 3 seconds for 4 video.
Then i spent a lot of time figuring out why does this happen. I tried spliting the video and the audio to find out the output duration, did a lot of discoveries on the internet and lots of math, only to find out that the offset had to be -1 second.

Example, I had this script generated from your website:
name:
2024-04-09_11-08-02.mp4
duration:
10.273177
(seconds, float)

name:
2024-04-09_11-08-14.mp4
duration:
35.673177
(seconds, float)

name:
2024-04-09_11-08-51.mp4
duration:
37.639844
(seconds, float)

name:
2024-04-09_11-09-29.mp4
duration:
26.10651
(seconds, float)

name:
2024-04-09_11-09-57.mp4
duration:
30.373177
(seconds, float)

name:
2024-04-09_11-10-29.mp4
duration:
21.839844
(seconds, float)

Total video duration will be 161.905729 with no fade transition.
Since it has 6 videos, it will be -6s, means it supposed to be 155.905729 long.

ffmpeg -vsync 0 -c:v hevc_cuvid -i 2024-04-09_11-08-02.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-14.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-51.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-29.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-57.mp4 -c:v hevc_cuvid -i 2024-04-09_11-10-29.mp4 -filter_complex "[0]settb=AVTB[0:v];[1]settb=AVTB[1:v];[2]settb=AVTB[2:v];[3]settb=AVTB[3:v];[4]settb=AVTB[4:v];[5]settb=AVTB[5:v];[0]atrim=0:10.273177[0:a];[1]atrim=0:35.673177[1:a];[2]atrim=0:37.639844[2:a];[3]atrim=0:26.10651[3:a];[4]atrim=0:30.373177[4:a];[5]atrim=0:21.839844[5:a];[0:v][1:v]xfade=transition=fade:duration=0.5:offset=9.773[v1];[v1][2:v]xfade=transition=fade:duration=0.5:offset=44.946[v2];[v2][3:v]xfade=transition=fade:duration=0.5:offset=82.086[v3];[v3][4:v]xfade=transition=fade:duration=0.5:offset=107.693[v4];[v4][5:v]xfade=transition=fade:duration=0.5:offset=137.566,format=yuv420p[video];[0:a][1:a]acrossfade=d=0.5:c1=tri:c2=tri[a1];[a1][2:a]acrossfade=d=0.5:c1=tri:c2=tri[a2];[a2][3:a]acrossfade=d=0.5:c1=tri:c2=tri[a3];[a3][4:a]acrossfade=d=0.5:c1=tri:c2=tri[a4];[a4][5:a]acrossfade=d=0.5:c1=tri:c2=tri[audio]" -c:v hevc_nvenc -rc vbr -cq 30 -qmin 30 -qmax 30 -profile:v main -pix_fmt yuv420p -b:v 0K -b_ref_mode 0 -movflags faststart -c:a libopus -ar 48000 -b:a 96k -map "[audio]" -map "[video]" a.mp4

the video and audio were out of sync,
then i split the video and audio command, found out that:

  1. The video was 00:02:39.43 long
  2. The audio was 00:02:31.34 long

then I messed with the offset on the xfade filter based on how many videos to join and then offset -1.1s on the first transition, -2.2s on the second transition and so on:
ffmpeg -vsync 0 -c:v hevc_cuvid -i 2024-04-09_11-08-02.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-14.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-51.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-29.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-57.mp4 -c:v hevc_cuvid -i 2024-04-09_11-10-29.mp4 -filter_complex "[0]settb=AVTB[0:v];[1]settb=AVTB[1:v];[2]settb=AVTB[2:v];[3]settb=AVTB[3:v];[4]settb=AVTB[4:v];[5]settb=AVTB[5:v];[0]atrim=0:10.273177[0:a];[1]atrim=0:35.673177[1:a];[2]atrim=0:37.639844[2:a];[3]atrim=0:26.10651[3:a];[4]atrim=0:30.373177[4:a];[5]atrim=0:21.839844[5:a];[0:v][1:v]xfade=transition=fade:duration=1:offset=9.273[v1];[v1][2:v]xfade=transition=fade:duration=1:offset=43.946[v2];[v2][3:v]xfade=transition=fade:duration=1:offset=80.586[v3];[v3][4:v]xfade=transition=fade:duration=1:offset=105.693[v4];[v4][5:v]xfade=transition=fade:duration=1:offset=135.066,format=yuv420p[video];[0:a][1:a]acrossfade=d=1:c1=tri:c2=tri[a1];[a1][2:a]acrossfade=d=1:c1=tri:c2=tri[a2];[a2][3:a]acrossfade=d=1:c1=tri:c2=tri[a3];[a3][4:a]acrossfade=d=1:c1=tri:c2=tri[a4];[a4][5:a]acrossfade=d=1:c1=tri:c2=tri[audio]" -c:v h264_nvenc -rc vbr -cq 30 -qmin 30 -qmax 30 -profile:v main -pix_fmt yuv420p -b:v 0K -b_ref_mode 0 -movflags faststart -c:a libopus -ar 48000 -b:a 96k -map "[audio]" -map "[video]" a.mp4,
i got nearly the duration with the audio, 00:02:31.33
same with the audio:
ffmpeg -vsync 0 -c:v hevc_cuvid -i 2024-04-09_11-08-02.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-14.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-51.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-29.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-57.mp4 -c:v hevc_cuvid -i 2024-04-09_11-10-29.mp4 -filter_complex "[0]atrim=0:10.273177[0:a];[1]atrim=0:35.673177[1:a];[2]atrim=0:37.639844[2:a];[3]atrim=0:26.10651[3:a];[4]atrim=0:30.373177[4:a];[5]atrim=0:21.839844[5:a];[0:a][1:a]acrossfade=d=1:c1=tri:c2=tri[a1];[a1][2:a]acrossfade=d=1:c1=tri:c2=tri[a2];[a2][3:a]acrossfade=d=1:c1=tri:c2=tri[a3];[a3][4:a]acrossfade=d=1:c1=tri:c2=tri[a4];[a4][5:a]acrossfade=d=1:c1=tri:c2=tri[audio]" -c:v h264_nvenc -b:v 10M -map "[audio]" temp.wav
ofc I got 00:02:31.34

BUT, the audio still end up not syncing with the video

then i try the -1s offset on the video again:
ffmpeg -vsync 0 -c:v hevc_cuvid -i 2024-04-09_11-08-02.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-14.mp4 -c:v hevc_cuvid -i 2024-04-09_11-08-51.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-29.mp4 -c:v hevc_cuvid -i 2024-04-09_11-09-57.mp4 -c:v hevc_cuvid -i 2024-04-09_11-10-29.mp4 -filter_complex "[0]settb=AVTB[0:v];[1]settb=AVTB[1:v];[2]settb=AVTB[2:v];[3]settb=AVTB[3:v];[4]settb=AVTB[4:v];[5]settb=AVTB[5:v];[0:v][1:v]xfade=transition=fade:duration=1:offset=8.273[v1];[v1][2:v]xfade=transition=fade:duration=1:offset=41.946[v2];[v2][3:v]xfade=transition=fade:duration=1:offset=77.586[v3];[v3][4:v]xfade=transition=fade:duration=1:offset=101.693[v4];[v4][5:v]xfade=transition=fade:duration=1:offset=130.066,format=yuv420p[video]" -c:v h264_nvenc -rc vbr -cq 30 -qmin 30 -qmax 30 -profile:v main -pix_fmt yuv420p -b:v 0K -b_ref_mode 0 -movflags faststart -c:a libopus -ar 48000 -b:a 96k -map "[video]" temp.mp4
and i got 00:02:31.83

AND this is how it managed to sync with the audio somehow.
Update on this part:
After removing the atrim, I realised the duration of the video and the audio is not the same, that's why atrim is still needed.

Conclusion:
WHAT THE HECK is even going on lol. Been driving my mind crazy for the whole day.
I still can't confirm whether is my video's duration problem or the generative script -1s offset bug. I remember I did managed to work on first try but maybe I didn't even notice about the audio whether is sync or not, that was just 2 videos together so is not obvious, only when there's more videos to join. But in the end, I still managed to have a work around on this issue.
Please confirm this issue, Thanks!

Update 1: I did a lot of edits on this post since I keep experimenting with the values I go right now. I originally had this issue using 0.5 for the duration settings, but I think 1s duration could explain the issue better, does that mean 0.5s duration transition = -0.5s offset? i don't even know anymore lol.

-filter_complex missing end quotes

I have generated a test script using F1.AVI, F2.AVI and F3.AVI, but I notice that the last filter-complex shows ;\ instead of "

i.e.
ffmpeg \ -vsync 0 \ -i "F2.AVI" \ -i "F3.AVI" \ -filter_complex \ "[0]settb=AVTB[0:v]; \ [1]settb=AVTB[1:v]; \ [0:v][1:v]xfade=transition=fade:duration=1:offset=9,format=yuv420p[video];\ -b:v 10M \ -map "[video]" "out.mp4" \

instead of

ffmpeg \ -vsync 0 \ -i "F2.AVI" \ -i "F3.AVI" \ -filter_complex \ "[0]settb=AVTB[0:v]; \ [1]settb=AVTB[1:v]; \ [0:v][1:v]xfade=transition=fade:duration=1:offset=9,format=yuv420p[video]" -b:v 10M \ -map "[video]" "out.mp4" \
image

++ ALSO : .... Why are there only 2 inputs to the video and audio commands - this does not seem right to me (it is missing F1.AVI)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.