Code Monkey home page Code Monkey logo

Comments (24)

xibr avatar xibr commented on May 20, 2024 1

@vdstogel @yausername

request.setOption("--write-thumbnail"); request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");

These commands work with me.

Here's the link: https://www.youtube.com/watch?v=cwgOVslrtn8

Screenshot_٢٠٢٠٠٣١٠-٢٣٥٠٤٧_FX

tested on android 10 and 9.

from youtubedl-android.

xibr avatar xibr commented on May 20, 2024

What is the error code or error message that appears.

also use getApplication() instead of "this".

replace

YoutubeDL.getInstance().init(this);
FFmpeg.getInstance().init(this);

with

YoutubeDL.getInstance().init(getApplication());
FFmpeg.getInstance().init(getApplication());

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

I'm testing on a real device so I don't have any error message and getApplication() doesn't work either

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

What options are you setting on the YoutubeDLRequest object?
Can you share the link for which the download fails?

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

It's litterally your stable release 0.7.0 and in the "app/src/main/java/com/yausername/youtubedl_android_example/App.java" I have added this line FFmpeg.getInstance().init(this); at line 55 above YoutubeDL.getInstance().init(this); that's all.
The link I have used to test is just a random link from youtube : https://www.youtube.com/watch?v=VDB65S6rCC0

from youtubedl-android.

vdst avatar vdst commented on May 20, 2024

Shouldn't it be handled by the command given to youtube-dl?
Rather than downloading the video then extracting the audio, you could directly download the audio and output it to an mp3 file
It would use a lot of bandwidth especially on large playlists for nothing

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

It's litterally your stable release 0.7.0 and in the "app/src/main/java/com/yausername/youtubedl_android_example/App.java" I have added this line FFmpeg.getInstance().init(this); at line 55 above YoutubeDL.getInstance().init(this); that's all.
The link I have used to test is just a random link from youtube : https://www.youtube.com/watch?v=VDB65S6rCC0

I am not able to reproduce this on my device. What android version are you on?
You need to look at logcat to figure out what the error is.

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

Shouldn't it be handled by the command given to youtube-dl?
Rather than downloading the video then extracting the audio, you could directly download the audio and output it to an mp3 file
It would use a lot of bandwidth especially on large playlists for nothing

Yes, it will be handled by youtube-dl. youtube-dl will not download the video when only audio is requested but will still need ffmpeg for converting the audio to mp3.

from youtubedl-android.

vdst avatar vdst commented on May 20, 2024

Yes, it will be handled by youtube-dl. youtube-dl will not download the video when only audio is requested but will still need ffmpeg for converting the audio to mp3.

I tried to modify the line:
"request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");"
(line 104 in the DownloadingExampleActivity.java) to download a thumbnail with no success though (and I doubt it needs ffmpeg to get an image).

Reading the documentation of youtube-dl didn't help much in this regard.

Another common error is python missing on Android emulators, but it shouldn't be affecting tests on a real device.

I am not able to reproduce this on my device. What android version are you on?
You need to look at logcat to figure out what the error is.

Android version 8.0

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

I got this

failed to download : com.yausername.youtubedl_android.YoutubeDLException: java.io.IOException: Cannot run program "/data/user/0/com.yausername.youtubedl_android_example/files/youtubedl-android/packages/usr/bin/python": error=2, No such file or directory
 	at com.yausername.youtubedl_android.YoutubeDL.execute(YoutubeDL.java:157)
	at com.yausername.youtubedl_android_example.DownloadingExampleActivity.lambda$startDownload$0$DownloadingExampleActivity(DownloadingExampleActivity.java:115)
	at com.yausername.youtubedl_android_example.-$$Lambda$DownloadingExampleActivity$DIqcJ_vtApVhyONpHFiA5nyofXo.call(Unknown Source:4)
 	at io.reactivex.internal.operators.observable.ObservableFromCallable.subscribeActual(ObservableFromCallable.java:42)
 	at io.reactivex.Observable.subscribe(Observable.java:12030)
	at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
 	at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:579)
 	at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
	at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
	at java.lang.Thread.run(Thread.java:764)
Caused by: java.io.IOException: Cannot run program "/data/user/0/com.yausername.youtubedl_android_example/files/youtubedl-android/packages/usr/bin/python": error=2, No such file or directory
 	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
 	at com.yausername.youtubedl_android.YoutubeDL.execute(YoutubeDL.java:155)
 	... 13 more
 Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
 	at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
	at java.lang.ProcessImpl.start(ProcessImpl.java:128)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
 	... 14 more

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

I got this

Does it error without ffmpeg also?
Does it print any error at init time?
Can you do force stop, clear data, reopen app and see if any error happens at init?

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

no error at init time.
Yes, the error is the same with or without ffmpeg but without ffmpeg I can download on real device. On emulator I've never been able to download.

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

On emulator I've never been able to download.

On emulator it is not expected to work since emulators use x86 images which are not supported. I should have mentioned this in the readme. You can try with arm images on the emulator if you have to.

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

Yes, I've already tested it on arm and it works but arm is so slow that I can't even start the emulator. Nonetheless, that's not working with ffmpeg.

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

Nonetheless, that's not working with ffmpeg.

Can you do uninstall and reinstall on real device and see logcat for errors at init and at the time on download? You can also try to run on debug mode using android studio and put break points in L58 of App.java

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

I tried to modify the line:
"request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");"
(line 104 in the DownloadingExampleActivity.java) to download a thumbnail with no success though (and I doubt it needs ffmpeg to get an image).

This works for me. The thumbnail is also downloaded.

request.setOption("--write-thumbnail");
request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");

from youtubedl-android.

vdst avatar vdst commented on May 20, 2024

This works for me. The thumbnail is also downloaded.

request.setOption("--write-thumbnail");
request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");

I have been trying to apply your solution with no luck unfortunately.
I reckon the thumbnail would be generated in the same folder as the video, but it didn't. Looking around in the phone gave no result.
Adding the parameter youtubeDLDir.getAbsolutePath() did not work either. The video is successfully downloaded each time though.

request.setOption("--write-thumbnail", youtubeDLDir.getAbsolutePath());

Just in case, I tested it with --write-description as well, again without any good result.
Tested on an Android 8.0 device as the download on emulator is broken.

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

request.setOption("--write-thumbnail", youtubeDLDir.getAbsolutePath());

This option does not accept a second parameter. So this won't work.

If you set both the options like below, the thumbnail should be downloaded just next to where the video is. Also share link of the vid that you are trying.

request.setOption("--write-thumbnail");
request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

@vdstogel Can you share an apk for me to test?

from youtubedl-android.

vdst avatar vdst commented on May 20, 2024

Here's the link: https://www.youtube.com/watch?v=cwgOVslrtn8

To be absolutely sure, I copy-pasted your lines. As expected, the video is downloaded flawlessly, but no thumbnail whatsoever.

This is a slightly modified version of your code where we are currently implementing an activity with databases to constantly keep playlists updated. The .apk had to be zipped because GitHub doesn't allow the apk extension.

app-debug.zip

from youtubedl-android.

vdst avatar vdst commented on May 20, 2024

Alright, so @Marinos33 tried on his phone and got the thumbnail as well as the video.
The .apk is the same so it's an issue on my device. We both use the version 8.0.

Also, -x worked on his device.
So he is able to get audio extracted from the video.

from youtubedl-android.

Marinos33 avatar Marinos33 commented on May 20, 2024

I don't know why but now FFmpeg works, It's magic !!!
Anyway, thanks for your help.

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

The apk provided by you doesn't download thumbnails on my device too.
I think this might be an issue with your build system/android studio. Close android studio and run ./gradlew clean assembleDebug. This will generate an apk in ./app/build/outputs/apk/debug/app-debug.apk

from youtubedl-android.

yausername avatar yausername commented on May 20, 2024

Should work on emulators also with 0.8.0, although I haven't tested because my slow machine can't run emulators.

from youtubedl-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.