Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video not loading on Apple Devices #547

Closed
baltermia opened this issue Nov 12, 2024 · 4 comments
Closed

Video not loading on Apple Devices #547

baltermia opened this issue Nov 12, 2024 · 4 comments

Comments

@baltermia
Copy link

I'm generating a video file (with no sound) out of multiple GIFs. The GIFs are loaded from files but the final video is sent somewhere else using a MemoryStream. The ffmpeg saving logic looks like this:

IEnumerable <IVideoFrame> frames = CreateFrames();

MemoryStream outStream = new();

RawVideoPipeSource video = new(frames)
{
    FrameRate = _options.FPS,
};

await FFMpegArguments
    .FromPipeInput(video, options => options
        .WithFramerate(_options.FPS))
    .OutputToPipe(new StreamPipeSink(outStream), options => options
        .WithVideoCodec("vp9")
        .ForceFormat("webm")
        .UsingMultithreading(true))
    .ProcessAsynchronously();

The GIFs are loaded into memory using SkiaSharp and the frames are also generated using that library.

Now, on Windows (when I save the MemoryStream to a file using FileStream), I can view the video. Even when sending the stream over to a messenger API, it's viewable on Android devices.
But for Apple Devices nothing happens. I was tested on my iPhone and MacBook.

On Windows, it's also not perfectly working. For example, the video has no length for some reason. So I can only start/stop and go to start. And for some other people to whom I sent the video (over the messenger), they told me the video was 420 hours long.

I tried using different codecs and formats but that either tells me that the arguments are invalid or that the pipe is broken.

Any help would be greatly appreciated.

@steve3p0
Copy link

Did you get this to work? I am willing assist with this.

@baltermia
Copy link
Author

Hi @steve3p0, thanks for reaching out. I did get it to work by just saving it to a file instead of into an output stream, then later read it into memory again using a FileStream.

await FFMpegArguments
    .FromPipeInput(video, options => options
        .WithFramerate(_options.FPS))
    .OutputToFile(filepath, true, options => options
        .ForceFormat(VideoType.Mp4)
        .WithCustomArgument("-an")
        .WithFramerate(_options.FPS)
        .WithFastStart())
    .ProcessAsynchronously();

Not the solution I was looking for but I didn't want to waste any more time. Closing this.

@steve3p0
Copy link

steve3p0 commented Jan 18, 2025

Hi baltermia!

I'm trying to use FFMpeg in a .NET MAUI Hybrid Blazor app on Windows, Android, and iOS to preprocess audio files.

I got my app to work on Android using this library:
https://github.com/drasticactions/Drastic.FFMpegKit

Will FFMpegCore work on all three operating systems? Did you get yours to work on iPhone by chance? I would love to see more of your sample code, if you are willing to share it.

Thanks!!
Steve

@baltermia
Copy link
Author

Hey @steve3p0!

It seems you are running FFMpeg directly on the Android and iOS clients while I create the videos server-sided. The issue that I had was that the created video that was sent using Telegram (or any messaging service) was not viewable on iOS devices. Even when directly loading the video into my iCloud Files, the video was not viewable on my iPhone, so it was probably an issue with the format I chose in the first example.

I don't know whether there is any connection between my issue and yours running FFMpeg on iOS directly. The code above is all I've written for FFMpeg, so I unfortunately can't supply you with any more sample code. I'm sorry I can't help you any further, but best of luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants