I want to migrate my drupal 6 video field to drupal 7 using the migrate module (and so #1266660: Migrate content from D6 video field to D7 doesn't apply, since that's for doing a drupal 6 to 7 upgrade).
The video module INSTALL.txt says "MIGRATE INSTRUCTIONS TO VIDEO.MODULE - See : http://drupal.org/node/713482" but that node is about migrating from Video 6.x-2 to Video 6.x-3, and has nothing to do with the migrate module.
There is no mention in the migrate issue queue about video migration.
The migrate_extras module has a way to migrate media_youtube urls to d7, but nothing in there about the Video module.
Is there somewhere else I can look?
Comment | File | Size | Author |
---|---|---|---|
#19 | video-migrate_field_handler-1835478-19.patch | 3.35 KB | JvE |
#17 | video-migrate_field_handler-1835478-17.patch | 3.37 KB | JvE |
#15 | video-migrate_field_handler-1835478-15.patch | 3.49 KB | JvE |
#13 | video-migrate_field_handler-1835478-13.patch | 3.37 KB | burningdog |
#11 | video-migrate_field_handler-1835478-11.patch | 5.82 KB | burningdog |
Comments
Comment #1
burningdog CreditAttribution: burningdog commentedI haven't found anything on this, so here's how I'm thinking of solving this.
I've created a video field - field_video - on my d7 site. I could migrate just one video file to it, but turns out I have more useful files that need to end up as part of field_video.
Here's a crude mapping showing what I'm trying to do:
* field_source is my source video, on Amazon S3.
* field_playablefile is the transcoded (via Zencoder) source file, on Amazon S3.
* field_thumbnail is a thumbnail for the video.
I could get Zencoder to generate the latter 2 fields again, but I have hundreds of videos, and the thumbnails have been painstakingly done manually over many years, and look better than any auto-generated thumbnail. So that's not an option.
I wrote a class for handling the d6 S3 textfield url to d7 file entity: MigrateExtrasFileS3. I'll contribute it to the Migrate Extras module, since it already has the MigrateExtrasFileYoutube class.
To handle the 3 migrates files at once, I'd need to extend the file field handler. I don't know how to do that, so I'm thinking of migrating just field_source to field_video, then in complete() handle the other two files, and figure out how to add them to field_video in the entity, and re-save the entity.
I will take a look at writing a Video field handler, too.
Is this the right place to have this discussion? Would it be better in the Migrate issue queue, or the Migrate Extras issue queue?
Comment #2
Jorrit CreditAttribution: Jorrit commentedThere is no code to support migrating from Drupal 6 to Drupal 7, unfortunately. I also have no experience with the Migrate module. If you can solve this problem and contribute tthe code to the Migrate Extras module, that would be great. As you noted, there doesn't seem to be much need for this feature at this moment. But as the life cycle of Drupal 6 is nearing its end, interest may only now be growing.
Comment #3
burningdog CreditAttribution: burningdog commentedThanks Jorrit. I think Migrate Extras have recently changed their policy - they want support for contrib module migrations to be in the contrib module itself. From the project page:
The Date Migrate module is a good example. It exists as a module within Date and can then be enabled specifically for a migration, and disabled afterwards. I've started writing VideoMigrateFieldHandler to handle video field migrations - let's see if it works.
Comment #4
kennywyland CreditAttribution: kennywyland commentedHi burningdog,
Did you ever get your VideoMigrateFieldHandler working? I need to import a bunch of videos into my drupal site and that would be very helpful.
Comment #5
burningdog CreditAttribution: burningdog commented@kennywyland, yes I did - I just need to do a bit more work on it to get it a bit more stable, and then I'll contribute a patch. In the meantime you can do some preparation for using it. Basically the VideoMigrateFieldHandler doesn't migrate an individual source video directly to the video field - that must be done first and created as a file entity. Once the file entity exists in d7, VideoMigrateFieldHandler then links that field entity to the video field.
In my case, my source video (on d6) is a youtube url stored in field_embedvideo_embed. I migrate it like so:
A
drush mi MediaVideoYoutube
migrates all youtube videos.The magic comes when doing the main content migration. Let's say your content type is called "Video" and your destination video field is called "field_video" - then for the Video migration you'll add the following field mapping:
Then in
prepareRow()
(or your migration class database query) you make sure that the value ofvideo
is one of the YouTube videos already migrated. The Migrate module sees that the source migration isMediaVideoYoutube
and looks there to find the fid of the file entity.Obviously this last part will only work once the VideoMigrateFieldHandler is working.
Comment #6
burningdog CreditAttribution: burningdog commentedThe Video field uses a number of files, in the following structure:
*
field_video['und'][0]['fid']
is the source video file. If no playable files exist, this one is played.*
field_video['und'][0]['thumbnailfile']
is a file object - the thumbnail chosen for the video.*
field_video['und'][0]['playablefiles']
is an array of file objects. Each one is a potentially playable video file, each created by a transcoding process (such as Zencoder or ffmpeg).I have values for all of the above which I need to migrate to d7 from d6.
So far I've managed to get the Migrate module to link
field_video['und'][0]['fid']
to an already migrated file entity (migrated by class MediaVideoYoutube), by using the following field mapping:But now how can I get Migrate to look in other migrations for the thumbnail file and the playable files? Here's one solution - define some additional arguments to VideoMigrateFieldHandler, like so:
...and then create migrations for MediaImageThumbnail and MediaVideoPlayablefiles, and run those before the above migration.
That would mean writing some
db_select
s in the VideoMigrateFieldHandler. I don't know if there's a way of defining additional sourceMigrations so that thedb_select
s aren't necessary?Comment #7
burningdog CreditAttribution: burningdog commentedFind attached a patch for the VideoMigrateFieldHandler. It still needs work, but I figured if anyone is going to be looking at #6 and giving input, it would be helpful to see how I'm approaching this.
Comment #8
burningdog CreditAttribution: burningdog commentedComment #9
burningdog CreditAttribution: burningdog commentedThe Video field does not allow for the direct saving of playable files. It links the playablefiles to the video field on a node load by checking if there are any jobs in the transcoding queue which are finished. So the way to migrate playable files is to pretend that we've added a transcoding job and that the job has already run. The playablefiles will be assigned to the field the next time that the node is loaded.
This is how the Video module links a transcoded playable file to the node:
So, we need access to $video->entity_type and $video->entity_id - which we don't have in function prepare() in VideoMigrateFieldHandler. So let's handle this in prepareRow() - which I'm hoping field handlers support...
Comment #10
mikeryanMaking migrations arguments to the field handler is unnecessary, you can reference them directly for the target subfields:
Comment #11
burningdog CreditAttribution: burningdog commentedGreat, thanks mikeryan - I was hoping it would be as easy as that! I've reworked VideoMigrateFieldHandler so that the thumbnail migration now works - see attached.
The next thing to solve is linking the playable files to the video field. These aren't directly created by giving some fid's to the Video field handler, unfortunately. The video module links the playablefiles to the video field on a node load by checking if there are any jobs in the transcoding queue which are finished. So the way to migrate playable files is to pretend that we've added a transcoding job and that the job has already run. The playablefiles will be assigned to the field the next time that the node is loaded.
But...where to add a transcoding job? We can only add it once we know the entity id, which we don't have access to in VideoMigrateFieldHandler (and I've tried running a prepareRow() in that handler, but that doesn't run). So I don't think there's any way of getting VideoMigrateFieldHandler to add a (fake) transcoding job.
The only thing I can think of is to add the transcoding job through a database query in prepareRow() of the Video node migration. Is there a better way?
Comment #12
burningdog CreditAttribution: burningdog commentedHere is the specific code (from Transcoder.inc) which links playable files to the video file:
Comment #13
burningdog CreditAttribution: burningdog commentedI've given up trying to migrate the playable files as part of VideoMigrateFieldHandler. I'm rather going to give it a go in complete() of my main migration.
In the meantime, here's the (working) VideoMigrateFieldHandler patch. To use it, call it like so from your migration:
If you're passing multiple values of
video
andthumbnail
then just pass those values as an array (I assign those values in prepareRow).If you get the following error, you're not using a source migration which contains the already migrated file entity:
WD node: MigrateException: array_flip(): Can only flip STRING and INTEGER values!
Comment #14
manu manuMany thanks for working on this issue, @burningdog
It help me to migrate video files.
About the patch in #13:
files[] = video.migrate.inc
thanks
Comment #15
JvE CreditAttribution: JvE commentedSince this way of migrating does not use the FileField functionality at all I've rolled a simplified version, including @manu manu's suggestions.
So as before,
1. create a Migration for the video files using MigrateDestinationFile
2. optionally create a Migration for the thumbnail files using MigrateDestinationFile
3. migrate
Comment #17
JvE CreditAttribution: JvE commentedI wish the testbot would be a bit more specific in what it deems an invalid about a patch.
Comment #19
JvE CreditAttribution: JvE commentedSorry for the issue-spam. I'm still getting used to a new toolchain.
Comment #20
manu manuThanks for the work @JvE, testing the new patch from #19...
Comment #21
havran CreditAttribution: havran commentedThanks for work on this. For my migration i use this code, based by latest patch:
I think extends from MigrateFileFieldBaseHandler is better way because now i can preserve files (files not deleted with rollback node). This code is bit smaller and seems work great for me. There is still no support for thumbnails but i want make some way for this.
Comment #22
havran CreditAttribution: havran commentedAbout video thumbnails. I try this approach (without success):
Comment #23
burningdog CreditAttribution: burningdog commentedThumbnails may be not viewable if storing the images on a CDN and using the Video thumbnail image formatter on drupal 7.20 or later - for more details see #2011674: Video Thumbnail formatter breaks with images stored on S3 due to security fix in Drupal core update 7.20
Comment #24
havran CreditAttribution: havran commentedThis code work for me (complete method from main migration class):
Code create frames after video is attached to migrated article, take first frame and attach them to video field.
Comment #25
havran CreditAttribution: havran commentedThanks, i store thumbnails as public, only video files are stored in private filesystem. For correct video streaming i use XSendfile module (with this patch) which work great.
Comment #26
vladimir-m CreditAttribution: vladimir-m commentedHi @havran,
Thank you very much. You made my day! (#24)
Comment #27
estoyausenteComment #28
heshanlkComment #29
heshanlk