numandev1 / react-native-compressor

🗜️Compress Image, Video, and Audio same like Whatsapp 🚀✨
MIT License
939 stars 87 forks source link

Video compression breaks video stream compatibility #251

Open serolgames opened 11 months ago

serolgames commented 11 months ago

Hello ! I hope you're doing well.

Sorry to be back with bad news 😅

Maybe there is a workaround but I have the following issue :

In my app I can upload videos to a s3 bucket. And then the videos can be streamed by users in my app. In the concept there is nothing complicated or difficult to set. I put manually a video in my s3 bucket and stream it perfectly in my app. BUT if I use the app to upload videos, then the stream doesn't work and the video needs to be fully loaded before being playable. And that's because of the compression. I tried with compression ❌ no streaming. I tried without compressing the video with your package ✅ streaming !

So, maybe you use an encoding or format that leads the stream to fail ?

Thank you !

Platform

React Native Version

0.72.5

React Native Compressor Version

1.8.16

numandev1 commented 11 months ago

@serolgames now a days, i am very busy, hopefully i will check it after 6 to 7 days

serolgames commented 10 months ago

Hello ! Hope your doing well

Any news about this problem ?

a396901990 commented 9 months ago

same here, looks like only happened for android

ghost commented 9 months ago

Hello,,,,,same here ! Is there any fix to this issue ?

noelsp commented 9 months ago

Maybe I´m experimenting this same issue: https://github.com/numandev1/react-native-compressor/issues/268

a396901990 commented 9 months ago

any update for this issue?

noelsp commented 8 months ago

Can someone upload a demo of the issue? I have one video with this error, but I can't upload because is private from our customer.

a396901990 commented 8 months ago

the issue for me is after the client uploads the compression video to the backend, the backend will use ffmpeg with the command line to generate base64 placeholder cmd := exec.Command("ffmpeg", "-i", "pipe:0", "-vframes", "1", "-q:v", "1", "-f", "singlejpeg", "pipe:1"). the error with pipe is [mov,mp4,m4a,3gp,3g2,mj2 @ 0x151f04950] stream 0, offset 0x2c: partial file [mov,mp4,m4a,3gp,3g2,mj2 @ 0x151f04950] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 640x360, 1676 kb/s): unspecified pixel format Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

somehow the file stream is broken when uploaded by Android with this library (ios is fine)

serolgames commented 8 months ago

@numandev1 Hello, any update for this issue ?

quoctruongkt commented 6 months ago

Have there been any updates here? I'm having trouble too

korungg commented 5 months ago

For those who are suffering from this issue until now:

I found that this issue is because the result file actually not for faststart (moov flags should be placed before mdat, but this isn't). It can simply fixed by using ffmpeg to the result like this

ffmpeg -i result.mp4 -c copy -movflags faststart result_streamable.mp4

But this is not the happiest solution since it needs extra dependency(ffmpeg) which is quite heavy. But then, I figured out this library already have the logic for making result streamable, but it is disabled intentionally.

After enable the logic, fix some bug, I can finally get the file that may be streamable. Every probe tools said that the moov of the file is before mdat, and video is playable via player. But in browser, it is still unstreamable. I guess there is some other logical error in "convert" function in Streamable.kt

Since I'm not the media expert nor kotlin developer, I can't help but stop here. I hope this helps someone

mittalkamal29 commented 5 months ago

I am facing same issue. Is there any solution to resolve it

serolgames commented 5 months ago

For those who are suffering from this issue until now:

I found that this issue is because the result file actually not for faststart (moov flags should be placed before mdat, but this isn't). It can simply fixed by using ffmpeg to the result like this

ffmpeg -i result.mp4 -c copy -movflags faststart result_streamable.mp4

But this is not the happiest solution since it needs extra dependency(ffmpeg) which is quite heavy. But then, I figured out this library already have the logic for making result streamable, but it is disabled intentionally.

After enable the logic, fix some bug, I can finally get the file that may be streamable. Every probe tools said that the moov of the file is before mdat, and video is playable via player. But in browser, it is still unstreamable. I guess there is some other logical error in "convert" function in Streamable.kt

Since I'm not the media expert nor kotlin developer, I can't help but stop here. I hope this helps someone

@numandev1 Look like it's a possible fix. Do you still work on the library ?

serolgames commented 4 months ago

The issue is still there. Any news ?

commbits commented 2 months ago

Same here. Are there any plans for a fix to this annoying bug?

commbits commented 1 month ago

Does 1.9.0 with the new isoParser fix this issue?

commbits commented 1 month ago

1.9.0 does not fix this issue for me: Video taken on Android still presents problems when viewing on iOS: No audio, and no autostart. Video plays fine on Android. iOS->Android, iOS->iOS are also correct.