a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

Add ffmpeg

Open prabirshrestha opened this issue 6 years ago • 24 comments

Would like to use this in conjunction with Siri Shortcuts to convert my gopro videos to smaller size on iPad given that iPad itself is pretty powerful.

prabirshrestha avatar Nov 06 '19 00:11 prabirshrestha

+1

suliveevil avatar May 16 '20 01:05 suliveevil

+1

dbellingroth avatar May 21 '20 12:05 dbellingroth

Hi, ffmpeg is now available as a binary to download. From here: https://github.com/holzschu/a-Shell-commands , download ffmpeg.wasm, place it in ~/Documents/bin and type ffmpeg on the command line.

It takes a lot of memory, so it might crash on smaller iPhones. Also it can take a long time to process a large video.

holzschu avatar Jun 12 '20 18:06 holzschu

Great Package!

suliveevil avatar Jun 12 '20 18:06 suliveevil

Thank you!

ghost avatar Jun 12 '20 18:06 ghost

ffmpeg crashes my iPad Pro (9.7-inch) and my iPhone 7.

ifuchs avatar Jun 13 '20 00:06 ifuchs

Yes, ffmpeg is a bit memory intensive (the binary itself is 87 MB), so just loading it in memory requires a powerful iPad, with few other memory-intensive apps running. After that, it can take a long time to complete the task, too.

holzschu avatar Jun 13 '20 07:06 holzschu

When I ‘ls’ into ~/Documents/bin I get a no such document/directory error and when I try to mv the ffmpeg.wasm file into that directory I also get an error. Any ideas what I’m doing wrong? Thanks.

ghost avatar Jun 13 '20 18:06 ghost

You might need to create the directory first if it doesn't exist, with mkdir.

holzschu avatar Jun 13 '20 18:06 holzschu

mkdir -p ~/Documents/bin
cd ~
mv *.wasm ~/Documents/bin/

suliveevil avatar Jun 13 '20 19:06 suliveevil

Thanks! Got it working (didn’t need the “cd ~”). Unfortunately though, like one of the above posts, ffmpeg crashes when running it on my iPad and iPhone 7. Haven’t tried it with youtube-dl yet, which is mainly what I want it for.

Edit: Nice! ffmpeg works when youtube-dl calls it in the case that formats need to be merged.

ghost avatar Jun 13 '20 22:06 ghost

I don't know what went wrong, but ffmpeg.wasm is 88 MB. If the file that was dowloaded is only 624 bytes, then something went wrong during the download. cat ~/Documents/bin/ffmpeg.wasm will probably tell you what.

holzschu avatar Jul 28 '20 15:07 holzschu

Given that ffmpeg seems to be a popular use case for A-Shell, and is performance critical, is it possible to compile it natively as part of A-Shell itself, rather than a wasm binary?

lukefor avatar Oct 26 '20 02:10 lukefor

Is it possible for ffmpeg.wasm to include encoders for h264 and h265? So far it's helpful for changing the file format, but it would be nice to re-encode videos to make them smaller.

faraixyz avatar Feb 10 '21 08:02 faraixyz

Hi, the latest release of a-Shell has native ffmpeg, with hardware-accelerated h264 encoding. You will have to remove the webAssembly version in order to access the native version.

holzschu avatar Aug 30 '21 09:08 holzschu

I installed latest version a-Shell on my iPad . How to remove FFmpeg web assembly version . I am a novice . Thanks in advance.

shyam1312 avatar Sep 21 '21 00:09 shyam1312

rm ~/Documents/bin/ffmpeg* should do it.

holzschu avatar Sep 21 '21 05:09 holzschu

thanks . but it returned no file or directory .. need more clarification . i was in correct directory. home folder .

need clarification . does latest version by default come with two version of ffmpeg . ( native and wasm ) . i thought i should delete wasm version to access native . or have to delete wasm version only if i explicitly installed it in first place .

shyam1312 avatar Sep 21 '21 09:09 shyam1312

Latest version comes with only native ffmpeg. If you previously installed WebAssembly version of ffmpeg, it is in your homedirectory and has priority over the native App version. If you never installed it, you have nothing to do.

To check: type ffmpeg --help. If it takes several seconds to reply, it is the WebAssembly version. If it is very fast, it is the native version.

If you have the WebAssembly version, it has to be in the $PATH, so: ~/Library/bin or ~/Documents/bin.

holzschu avatar Sep 21 '21 09:09 holzschu

ok thanks . so i tried executing this command .

$ ffmpeg -i q.mp4 -vcodec libx264 -acodec aac output.mp4

it says unknown encoder 'libx264' . but same thing worked in windows . ipad screen shot attached .

[](url IMG_0005 )

shyam1312 avatar Sep 21 '21 10:09 shyam1312

So, if it says --enable-videotoolbox, then it is the native version. I'm glad we settled this one.

Next, libx264 is a GPL library, so it is incompatible with AppStore distribution according to the FSF. You have to use the h264 codec, which also encodes to H264 format, but using native iOS libraries (also, ffmpeg is pretty good now at guessing the codec from file extensions, so you could just type ffmpeg -i q.mp4 output.mp4).

holzschu avatar Sep 21 '21 10:09 holzschu

Latest version comes with only native ffmpeg. If you previously installed WebAssembly version of ffmpeg, it is in your homedirectory and has priority over the native App version. If you never installed it, you have nothing to do.

Where is the native ffmpeg location? I’m trying to use it with yt-dlp --ffmpeg-location option.

Tama47 avatar Aug 14 '23 05:08 Tama47

I don't understand why you would need to specifify the location of ffmpeg, since it is in the PATH, but it's in $APPDIR/bin/ffmpeg.

holzschu avatar Aug 14 '23 08:08 holzschu

I was getting error with yt-dlp --embed-thumbnail, works perfectly now. Thanks!

Tama47 avatar Aug 14 '23 09:08 Tama47