Skip to content

Store Filtered video in video formated file (like .mp4) #7

Open

Description

@KamdarV

First of all, I would like to thank you for giving us a great library similar to GPUImage framework of iOS.

While viewing Library, I could find VideoToImageExample filtering sample. But it storing output as image in .jpg format in JPGFileEndpoint.java class.
I wanted to filter video and store filtered video in video formate file (like .mp4). That means VideoToVideoExample. Please help me for the same.

Thanks in advance.

Activity

  1. chrisbatt commented on Jan 6, 2014

    @chrisbatt
    Owner

    This was one of my goals for the original project. The issue is that Android does not provide any easy way (as far as I know) to create videos from a group of images. I managed to get something working on Android 2.2 using the FFMpeg library. The problem was that it was crashing on all of the Android 4+ devices I tested on making it relatively useless. I believe it the video output code and sample were committed to the project in one of the earlier commits, if you wanted to take a look at it. If not, it is still on my todo list, but I fear it will be a while before I actually get anything working properly.

  2. KamdarV commented on Jan 7, 2014

    @KamdarV
    Author

    Thanks for reply. I also checked out many libraries like openCV, FFMpeg, Mp4Parser, etc. but couldn't reach to the solution yet. Waiting for your updated project with video filter output.

  3. KamdarV commented on Jan 24, 2014

    @KamdarV
    Author

    Hello chrisbatt, can I add filter image ( e.g. watereffect.jpg) with video in android. Please let me know if you have any idea about this. Need sample code if possible.
    Thank u so much.

  4. chrisbatt commented on Jan 29, 2014

    @chrisbatt
    Owner

    I am a little bit confused about what you are asking. If you are asking if you can use a JPGFileEndpoint with a video input then the answer is yes. I believe there is an example of this in the examples folder called VideoToImage. If you are asking about something else, would it be possible to clarify what you mean by a filter image with video?

  5. KamdarV commented on Jan 31, 2014

    @KamdarV
    Author

    My question is, as in FastImageProcessing library you are creating filter classes (e.g. SepiaFilter.java, HueFilter.java,..etc.). I have an image like
    toastermetal
    for filter effect. So I think i need to add this image with every frames of videos. I found this project https://github.com/guardianproject/SSCVideoProto and tried following changes :

    String[] ffmpegCommand = {ffmpegBin, "-v", "10", "-y", "-i", inputFile.getPath(),
    "-vcodec", "libx264", "-b", "3000k", "-vpre", "baseline", "-s", "720x480", "-r", "30",
    //"-vf", "drawbox=10:20:200:60:[email protected]",
    "-i" , Environment.getExternalStorageDirectory().getPath() + "/toasterMetal.png", "-filter_complex", "[0:v][1:v]overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]" , "-map", "[out]", "-map", "0:a",
    "-acodec", "copy",
    "-f", "mp4", Environment.getExternalStorageDirectory().getPath() + "/output.mp4"};

    But it didnt work. Please help me if you have any idea how to implement this or have any other way to do this.
    Thanks.

  6. leeicmobile commented on Feb 17, 2014

    @leeicmobile

    Was going to create a new issue but this seems like a sensible place to put it.
    I attempted to integrate a new Output for video into the library using chris suggestion of JavaCV on his blog. I've forked the latest Here:
    https://github.com/icmobilelab/AndroidFastImageProcessing

    This seems to work fine in Android 4.0.3+ although I have only tested on KitKat so far.

    main code is in VideoFileEndpoint.java and VideoFileEndpointListener.java

    comments aren't all updated apologies.

  7. KamdarV commented on Feb 17, 2014

    @KamdarV
    Author

    Thank you very much for all your efforts. Can you please also add VideoToVideoExample as well..?

  8. leeicmobile commented on Feb 17, 2014

    @leeicmobile

    Can't do all the work kamdar :) You just need to hook it up like you would
    the screen endpoint and call start and stop recording. Plus the class which
    owns the videofile end point should implement the videofile endpoint
    listener.

    You should also review the javacv setup requirements if the bundled lib.so
    files aren't working. You'll need to download javacv.jar and javacpp.jar
    (part of the javacv setup)
    On Feb 17, 2014 6:44 AM, "KamdarV" [email protected] wrote:

    Thank you very much for all your efforts. Can you please also add
    VideoToVideoExample as well..

    Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-35232215
    .

  9. KamdarV commented on Feb 18, 2014

    @KamdarV
    Author

    OK..Thank you.

  10. stofanakmartin commented on Mar 15, 2014

    @stofanakmartin

    leeicmobile i have tried what you posted here. I hooked videoFileEndpoint just like screenEndPoint included javaCv to my project and recording works but its very slow. Record speed is one frame in half a second so the result video has 2fps.
    When i attach the screen as endpoint the video is fluid.
    My device is SGSII, do you have some tips how to enhance performace of recording?

  11. leeicmobile commented on Mar 15, 2014

    @leeicmobile

    Hi Stofo89,

    unfortunately I've also found that performance differs considerably from
    device to device.

    This is dues to the glreadpixels call which can be upto 100ms per call on
    some GPU architectures.

    All I could suggest is perhaps do post-processing of the video, if you are
    using camera input for instance record just the camera frames to a video
    then apply the filters and record the output without also displaying to the
    screen.

    Lee

    On 15 March 2014 15:12, stofo89 [email protected] wrote:

    leeicmobile i have tried what you posted here. I hooked videoFileEndpoint
    just like screenEndPoint included javaCv to my project and recording works
    but its very slow. Record speed is one frame in half a second so the result
    video has 2fps.
    When i attach the screen as endpoint the video is fluid.
    My device is SGSII, do you have some tips how to enhance performace of
    recording?

    Reply to this email directly or view it on GitHubhttps://github.com//issues/7#issuecomment-37728179
    .

  12. ompemi commented on Oct 9, 2014

    @ompemi

    Hey @leeicmobile ,

    Your VideoFileInput was a great starting point, thank you. I managed to record the video but as @stofo89 points out it is too slow. After some tests the only acceptable preview size that could work with most devices is lower than 800 pixels width (there seems to be a solution for 4.3)

    I noticed that the VideoFileInput does not output the video as the ScreenEndpoint while recording. Do you have any quick hint here?

    I will post updates if I manage to get the filtered video out while recording, so that I can push to your repo an example of VideoToVideoExample.

    Thanks,
    Omar

  13. justin0814 commented on Oct 31, 2014

    @justin0814

    Hi Lee, @leeicmobile
    I am very interested in your idea to use this library to do post-processing of a given video without displaying it to the screen. I have tried your VideoFileEndpoint and found the only to get an output video file is to call startRecord() and stopRecord(). That means for a video of 20 seconds, I need to wait for 20 seconds to play it in the background and in the meantime record it to a video file.

    I need to only filter it and get the output file. is there a way to get the video file through background post-processing in a shorter period of time?

    Waiting for your reply. Thanks for your works.

    Justin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions