Opened 11 years ago
Closed 11 years ago
#26825 closed enhancement (fixed)
Add ability to generate metadata for audio / video files on-demand
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
If you uploaded audio/video files before 3.6, they do not have attachment metadata. There is currently no way to generate this on the fly. On the Edit Media screen, if we know there is no metadata for a media attachment, perhaps we show a button or whatnot that will generate the metadata (scan the item's ID3 tags) when pressed. This is especially important for video, so that we know the proper dimensions before rendering.
Attachments (5)
Change History (23)
#2
@
11 years ago
Nice. Instead of adding UI for this, is there any reason it shouldn't be generated automatically if the metadata key doesn't exist? It could be generated just by visiting the attachment edit screen and in wp_prepare_attachment_for_js()
.
The only thing that might be an issue is if the data can't be generated for some reason, doing it this way might cause wp_generate_attachment_metadata()
to be run more than necessary, so maybe a flag would need to be set if automatically generating the metadata fails?
#3
@
11 years ago
I agree with bradyvercher 100%. He kinds of hints at a race condition (of multiple processes trying to update metadata at once), just something else to think about.
This really something we should try as hard as possible to handle without involving the user.
#4
@
11 years ago
Perhaps the postmeta key can be set to an empty value, so the only check will be if the key exists or not. For files that were previously uploaded before there was meta generated, there was no key at all
#5
follow-up:
↓ 7
@
11 years ago
26825-prepare.diff does the regeneration in wp_prepare_attachment_for_js()
- but I think this is a bad idea. If your library has 300 videos in it, all uploaded before 3.6 - the first time you kick open the media modal, it will attempt the parse all 300 videos
#6
@
11 years ago
Can we regenerate on loading the edit media screen? Only generating if missing the key entirely seems smart. A race condition could happen, but seems pretty edge if specifically on that screen.
#7
in reply to:
↑ 5
;
follow-up:
↓ 8
@
11 years ago
Replying to wonderboymusic:
Perhaps the postmeta key can be set to an empty value, so the only check will be if the key exists or not.
Using the meta key itself for the flag sounds like a good idea. I wasn't sure if the key could exist with an empty value yet.
Replying to wonderboymusic:
If your library has 300 videos in it, all uploaded before 3.6 - the first time you kick open the media modal, it will attempt the parse all 300 videos
When does core ever load 300 attachments at a time? It seems like 40 would be the most and it'd be a one-time thing.
Replying to helen:
Can we regenerate on loading the edit media screen?
I figured both places might be beneficial, but in the scenario where there are 300 videos without metadata, that'd require visiting each of those edit screens.
As far as race conditions, what's the worst that could happen aside from a file being processed twice? Once the metadata key exists, the file wouldn't be processed again. Is there a more extreme side effect?
#8
in reply to:
↑ 7
@
11 years ago
Replying to bradyvercher:
When does core ever load 300 attachments at a time? It seems like 40 would be the most and it'd be a one-time thing.
The media modal makes an unbounded query for EVERY attachment when it is popped open the first time
#9
@
11 years ago
26825.2.diff does this on the loading of the Edit Media page and implements locking via transient - a semaphore
, as it were. So, no race condition.
This is the very least that needs to happen, might need to happen other places. Going to drop this in soon.
#12
@
11 years ago
[27127] looks great.
maybe_regenerate_attachment_metadata() seems like something that could be suited as a default action. I don't think it works at the moment or for these particular contexts, but just wanted to mention as a potential off-the-wall idea.
#13
@
11 years ago
Replying to wonderboymusic:
The media modal makes an unbounded query for EVERY attachment when it is popped open the first time
If I'm reading the code right, it should only load 40 at a time and continue fetching with an infinite scroll technique. Here is the default posts per page arg. Inspecting the AJAX request seems to confirm the same.
In any case, I like the new method.
#15
@
11 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 27397:
#16
@
11 years ago
- Keywords dev-feedback removed
- Resolution fixed deleted
- Status changed from closed to reopened
In media.php we're still referencing maybe_regenerate_attachment_metadata
causing fatal errors, see 26825.4.diff.
26825.diff is first pass at making this happen. Would like someone to review it.
To test: