Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Bug] MP4 videos added to cards doesn't sync with Ankiweb collection.media

Open Yoannjap opened this issue 3 years ago • 11 comments

Reproduction Steps
  1. I edit a flashcard using AnkiDroid, and add a 32KB mp4 video.
  2. I add this video using this html code: <video muted autoplay loop width="400" height="300" controls><source src="xxxx.mp4"></video>
  3. I sync my account before closing the app.
  4. I go to my PC, launch Anki, and sync my account.
  5. I open the modified card, no video launched.
  6. I open the collection.media folder: the MP4 video hasn't been added.
  7. I do the same thing (editing the card with adding the video) from my PC, then sync, then check the edited card on AnkiDroid: it works, the media is added in the AnkiDroid collection.media.
  8. So, because I use 99% of times AnkiDroid to edit my cards, I try again with another card to add another tiny MP4 video.
  9. Finally I use the option 'check the media'...
  10. ...After the process is down, the media (new MP4 video) has been removed from my AnkiDroid collection.media!
Expected Result

What I would like is there is no big with MP4 files:

When you add one editing a card, it syncs well with Ankiweb account, recognizing the video and well linking it to the card where it is referenced.

Actual Result
Debug info

Refer to the support page if you are unsure where to get the "debug info".

Research

Enter an [x] character to confirm the points below:

  • [x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
  • [x] I have checked the manual and the FAQ and could not find a solution to my issue
  • [x] I have searched for similar existing issues here and on the user forum
  • [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

By the way, I contacted you because Damien Elmes answered me in this Ankiweb topic I opened:

Unless the files are over 100MB (which is not supported), it sounds like an AnkiDroid bug.”

Yoannjap avatar Jul 11 '22 11:07 Yoannjap

Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing

welcome[bot] avatar Jul 11 '22 11:07 welcome[bot]

Yep - very well might be a bug - it would be useful to have the debug info requested in the new issue template, but I can guess you are probably using the current stable release version 2.15.6 ? You might try the current test releases on the 2.16 series to see if it is already fixed? https://github.com/ankidroid/Anki-Android/releases

mikehardy avatar Jul 11 '22 22:07 mikehardy

Hey and thanks mike hardy for your reply.

Yes I use the Google Play current publish 'beta' version: 2.15.6

Please see below the debug info after having:

  • added a card, editing it with "bonjour" in front 'Vocab' side,
  • with <video muted autoplay loop width="400" height="300" controls><source src="bonjourLSF.mp4"></video> in 'video1' field,
  • Then syncing to Ankiweb account.

Of course the bonjourLSF.mp4 had been added to my /storage/684F-2E24/Android/data/com.ichi2.anki/AnkiDroid/collection.media/ folder.

Then on my PC after syncing, I watched in the local collection.media folder... no file in it.

AnkiDroid Version = 2.15.6

Android Version = 11

Manufacturer = Sony

Model = XQ-AS72

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 11; XQ-AS72 Build/58.1.A.1.178; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.198 Mobile Safari/537.36

ACRA UUID = 9e9933ee-9ae8-4daa-bedd-ce7326b2b482

Scheduler = std2

Crash Reports Enabled = false

DatabaseV2 Enabled = true

Then I tested the same process (with bonjour2 in Vocab and <video muted autoplay loop width="400" height="300" controls><source src="bonjour2LSF.mp4"></video> after having installed the AnkiDroid 2.16alpha73 version you suggested me. Same result, please see the debug info:

AnkiDroid Version = 2.16alpha73

Android Version = 11

Manufacturer = Sony

Model = XQ-AS72

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 11; XQ-AS72 Build/58.1.A.1.178; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.198 Mobile Safari/537.36

ACRA UUID = 9e9933ee-9ae8-4daa-bedd-ce7326b2b482

Scheduler = std2

Crash Reports Enabled = false

DatabaseV2 Enabled = true

So this is very annoying...

Yoannjap avatar Jul 12 '22 07:07 Yoannjap

Oh I was really hoping the 2.16 code would have this fixed already, I am sorry it doesn't, thank you very much for trying

mikehardy avatar Jul 15 '22 02:07 mikehardy

Well, no problem. I hope it may be fixed in a future update :)

For now and for people that want to bypass this issue for now: • I edit or create cards adding the videos on AnkiDroid; • Then I sync the media added in the collection.media folder with a mirror Nextcloud folder (syncing using rclone) ; • Then on my PC I sync back from the Nextcloud to my PC Anki app collection.media folder the new media; • Then I sync my PC Anki app to my AniWeb account; • Then I sync my Ankidroid app from my Ankiweb account. • After that process, media are well synced on every platform. => However, there seems to be a global Anki and Ankidroid bug (I haven't tested myself): If you do a media check, all the MP4 files added are removed. To avoid it, topics on Anki forum recommend adding on your deck a field called 'Media' (a field you don't make appear on your CSS card profile), in which you write [sound:the_exact_name_of_the_video.mp4] Doing it would prevent Anki from removing video media after a media check ;)

Just to tell you why videos are useful is in my case because I make a deck for people learning French Sign Language.

Whatever, thanks for your answers.

Yoannjap avatar Jul 15 '22 11:07 Yoannjap

AnkiDroid doesn't keep media on <video> tags if you use Check media, but <object> tags work here.

Can you please test if Anki desktop doesn't do the same to <video> tags? IIRC, only <img>, <audio>, <object> and [sound:] are recognized as media tags there too.

BrayanDSO avatar Jul 20 '22 19:07 BrayanDSO

And as you've come from 2.15.6 and attaching videos wasn't supported on it, I may ask: how do you add the videos? Do you directly copy them on your collection.media folder?

BrayanDSO avatar Jul 20 '22 19:07 BrayanDSO

And as you've come from 2.15.6 and attaching videos wasn't supported on it, I may ask: how do you add the videos? Do you directly copy them on your collection.media folder?

Hey BrayanDSO,

As I said in my first message, I 'add' the videos:

  1. downloading the MP4 video on my Android download internal SD folder;
  2. renaming it xxxx.mp4;
  3. using Termux to move it (mv command) to my Ankidroid/collection.media/ folder;
  4. editing a special field onto the card : <video muted autoplay loop width="400" height="300" controls><source src="xxxx.mp4"></video>.

For the idea of using <object>, how can I edit it in the special field?

However using <video> works well for syncing with Ankiweb and keeping into desktop collection.media folder on Anki desktop. It doesn't from Ankidroid.

Thanks for your reply:)

Yoannjap avatar Jul 21 '22 00:07 Yoannjap

As a workaround [sound:] will work for videos.

david-allison avatar Jul 21 '22 00:07 david-allison

I'd faced an issue very similar to yours before, as once I copied the files directly to the collection.media as well. Fixing the problems I had with media importing is actually why I started contributing to the app. Moving the file directly to the collection.media folder doesn't do the process of adding it to Anki's media database . I guess (it means I haven't looked at the actual code) Anki checks it anyway if there isn't a missing media on the database, while AnkiDroid doesn't. IIRC, using check media or check database, I don't remember which, does the trick and the file can be uploaded to AnkiWeb.

About the object tag, you can use

 <object data="xxxx.mp4" width="300" height="200"></object>  

And files included on it aren't deleted by Check media. I don't know if it is as customizable as the video tag.

And as I said, can you please test if Anki desktop doesn't delete files on <video> tags if you tap Check media? (assuming the same files aren't used with the [sound:] syntax on another cards).

I'm personally in favor of not deleting files on Video tags as well. So I'd do the request here and on Anki desktop too.

BrayanDSO avatar Jul 21 '22 10:07 BrayanDSO

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Sep 19 '22 10:09 github-actions[bot]