Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

FFmpeg for Unity

Discussion in 'Assets and Asset Store' started by Max-Bot, Jul 13, 2017.

  1. mchangxe

    mchangxe

    Joined:
    Jun 16, 2019
    Posts:
    69
    Hi, I am trying to add audio to a video by executing the following command:
    -y -i C:\Users\NOWHERE\Desktop\2019BackupJDI\NikeJDIKids\Captures\MovieCapture_2021-09-17_18-40-03_1920x1080.mp4 -i C:/Users/NOWHERE/Desktop/2019BackupJDI/NikeJDIKids/Assets/Michael/Sounds/FinalGameSound.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 C:/Users/NOWHERE/Desktop/2019BackupJDI/NikeJDIKids/Assetsugc_9171840.mp4

    but I get the error:

    InvalidOperationException: Cannot start process because a file name has not been provided. System.Diagnostics.Process.start() at <...........>
     
  2. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    Please inspect what is the code behind "Add Sound" demo.
    And do the same.

    Good luck with a project!
    Cheers!
     
  3. ElAsmar

    ElAsmar

    Joined:
    Nov 21, 2020
    Posts:
    5
    hello, i am trying to mix Video with Audio by using
    Code (CSharp):
    1. -y -i test.mov -i test.wav -filter_complex [0][1]amix=inputs=2[a] -map 0:v -map [a] -c:v copy  -result
    it is working fine, im getting the expected result however i want to know when does the command end to call another function how is that possible?
     
    Max-Bot likes this.
  4. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    Good job!
    You can path callbacks to main interface method:
    Code (CSharp):
    1. public static FFmpegProcess Execute(string command, List<IFFmpegCallbacksHandler> callbacksHandlers)
    So when your job is done - you can start next one from the beginning.
    Good luck with a project!
     
  5. ElAsmar

    ElAsmar

    Joined:
    Nov 21, 2020
    Posts:
    5
    Not sure how to use that :(
    im currently in a script where i call the FFmpegCommand.cs to run the command
    Code (CSharp):
    1. FFmpegCommand.StartFfmpeg(command);
    2.  
    after that i need to delete old video and keep the Merged one, however i cant really tell when the command is done, because merging bigger video with audio would take more time.
     
  6. ElAsmar

    ElAsmar

    Joined:
    Nov 21, 2020
    Posts:
    5
    Another question, what is best approach regarding the command used

    1. Code (CSharp):
      1. -y -i test.mov -i test.wav -filter_complex [0][1]amix=inputs=2[a] -map 0:v -map [a] -c:v copy  -result

    1. is there a better command ? i am trying to take first input as video and 2nd as audio then merge and get video output of both but i need to keep the output duration equal to first input
     
  7. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    Are you sure you use FFmpeg Bind 2 from here?
    https://assetstore.unity.com/packages/tools/video/ffmpeg-bind-2-187458
     
  8. ElAsmar

    ElAsmar

    Joined:
    Nov 21, 2020
    Posts:
    5
  9. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
  10. yangyueyue

    yangyueyue

    Joined:
    Aug 1, 2018
    Posts:
    21
    Why is set 1920×1080, the picture is still very vague
    upload_2022-7-26_20-27-46.png
     
  11. yangyueyue

    yangyueyue

    Joined:
    Aug 1, 2018
    Posts:
    21
    How to close rtsp stream? I tried to use stopfmpeg function, but it didn't work
     
  12. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    May depend on your backend.
    You can also try own encoding as an option.
    Good luck with a project!
     
  13. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    If you have any problems with this in your app - killing of thread can be the option to try.
    Good luck with a project!
     
  14. Max-Bot

    Max-Bot

    Joined:
    Sep 25, 2013
    Posts:
    83
    a5thKYC likes this.
  15. wayfarergames

    wayfarergames

    Joined:
    Sep 7, 2013
    Posts:
    25
    I can't get this to build for iOS at all, should I assume support has ended for this now it's open source? I don't really know where to start with trying to get a build up and running, the errors are:

    In __threading_support:
    Variable has incomplete type '__libcpp_timespec_t' (aka 'timespec')
    Calling '__convert_to_timespec<timespec>' with incomplete return type 'timespec'

    in system_clock
    Reference to unresolved using declaration twice.


    Screenshot 2023-05-09 at 11.04.24.png
     
  16. afonsooliveira

    afonsooliveira

    Joined:
    Jan 14, 2014
    Posts:
    1
    Hi wayfarergames i just deleted folder libavutil and a get the build
    but, i use just for convert video and works great!

    hope this can't help
     
    neon_matt likes this.