Closed rickycodes closed 6 years ago
My immediate guess is something like, "how big is the resulting gif?" Twitter does some extra processing of gifs and videos, which UploadFuture waits on before returning. It could be that the image is taking a long time to upload and process.
To make sure i didn't include any accidental deadlocks, i wrote up some demo code with the released egg-mode to make a demo tweet with a gif i knew worked in the past. (This is all the code used to upload it, minus the tokens and the image file - i did include a link to where i got it, though.)
What i would recommend is to tweak the settings in your mkvToGif.sh
to compress it more. Twitter has some guidelines for what they'll process, so you may need to adjust your conversion. (Notably, videos tend to be much smaller than their gif counterparts, so you may have more luck just stripping the audio from your video file, converting it to mp4, and uploading that instead, as a silent video.)
Also, i'm glad you were able to use egg-mode to learn rust! That was one of the things i wanted to enable with my library, so i'm glad it's paying off! :grin:
My immediate guess is something like, "how big is the resulting gif?"
the resulting gif in this case is ~3.2mb, which seems fine (I am actually porting from a previous project written in nodejs, which used the same .sh
script and it worked fine there, so it should work here too?)
I'm gonna review your example and tweak my code a bit and see if it makes a difference...
Notably, videos tend to be much smaller than their gif counterparts, so you may have more luck just stripping the audio from your video file, converting it to mp4, and uploading that instead, as a silent video.
honestly, that's a good point... might even yield better results 🤔
(I am actually porting from a previous project written in nodejs, which used the same .sh script and it worked fine there, so it should work here too?)
Oh, huh, that makes sense. In that case, i doubt it's the image file at fault here.
I poked through the js version of the project, and something that struck me is that the media upload there doesn't seem to specify a content type. In fact, it seems to use the basic POST media/upload
endpoint, which doesn't even officially support gifs. >_>
That seems to be the main difference between the old and new code - egg-mode doesn't even expose the basic endpoint! Now that it's hitting the chunked-upload endpoint, it may be hitting some other limitations.
here's an example gif: https://i.imgur.com/fbufdmy.gif
I'm curious if you're able to upload it to twitter using your demo code, if so we can discount the file itself and start looking at what I am doing with the code? maybe the way I'm loading the image into the buffer vector is janked? really stumped by this...
@QuietMisdreavus I've actually gone ahead and tested the example gif you provided, along with your demo and I still hit the same wall... I'm curious now if it's something to do with my setup?
Are you running/compiling this application on Linux, or OSX? It's odd that image_png()
works fine for me, but no joy when it comes to gifs 🤔
That's so strange! I'm running this on Linux. (Arch Linux, if that's important.) It shouldn't make any difference within egg-mode if you switch between the file formats, so i wonder what's going on with your system when you have to upload the bigger file.
I tried your sample gif, and though it took an extra few seconds of processing, it uploaded and posted just fine.
The only thing that i can imagine would be different between our setups, if we're running the exact same code, is the version of OpenSSL it's using. (Or if you're on not-Linux, the difference between my OpenSSL and the system library you're using.) openssl-sys
(via native-tls
on Linux) may be linking to a different OpenSSL version on your system versus mine. The version i should be linking against is 1.0.2.n-1
, according to my package manager. Otherwise, i'm complete out of ideas. ðŸ˜
I'm running everything on raspian Linux (on a pi3). I might try compiling the demo on OSX and see what's up. It's possible I'm missing a package, I'll compare OpenSSL as well.
thanks a bunch for investigating!
@QuietMisdreavus okay, weird... I forked the demo over to my mac and I get the same behavior :(
https://github.com/rickycodes/retrorecord/blob/master/src/main.rs#L35-L38
it prints the "boop", but then nothing else :(, it just hangs and I never see sending tweet...
get printed... I thought maybe there was something up with the way the token is getting created, but that doesn't really make sense since the image_png()
still works here too...
I really don't get what's up with this at all :(
Update: After some fiddling with @rickycodes's code and mine, i learned that when the upload task went into the tokio Core in the original version, it stopped being polled after a moment, and never woke up to continue the Future. On a lark, i ran a cargo update
to see if there was an update in the tokio libraries that would have helped this. After doing this, it worked! This explains why my code worked, because it was pulling a fresher set of Tokio libraries. I'm not totally sure what's going on, but if @rickycodes can confirm that the rest of their code works now, we can probably color this solved?
@QuietMisdreavus S U C C E S S https://twitter.com/whatmeplaying/status/962055306279763968
thank you so so so much!
@QuietMisdreavus apparently quite a few things were out-of-date :/
Updating hyper v0.11.16 -> v0.11.18
Updating mio v0.6.12 -> v0.6.13
Updating num v0.1.41 -> v0.1.42
Updating num-integer v0.1.35 -> v0.1.36
Updating num-iter v0.1.34 -> v0.1.35
Updating num-traits v0.1.42 -> v0.2.0
Updating rand v0.3.20 -> v0.3.22
Updating tokio-io v0.1.4 -> v0.1.5
Updating walkdir v2.0.1 -> v2.1.3
here is the mod i wrote: https://github.com/rickycodes/retrorecord/blob/master/src/tweet/mod.rs
this works fine when the media type is
image_png
, but when I try to use gif it hangs around here: https://github.com/rickycodes/retrorecord/blob/master/src/tweet/mod.rs#L47I am calling the mod's
tweet
function here: https://github.com/rickycodes/retrorecord/blob/master/src/main.rs#L80again, this works fine when called from here: https://github.com/rickycodes/retrorecord/blob/master/src/main.rs#L38
perhaps I am missing something super obvious?
here's my terminal's output (so you can see where it hangs):
lastly, thanks for creating this crate! it's been fun using this project to learn rust!