Files transcoded but not added to filefiled

szczym - June 9, 2009 - 11:32
Project:Media Mover
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Issue tags:cck filefield, media mover
Description

Media mover is transcoding files from node attachments into flv but not submitting them to filefiled. Similar configuration for image thumbnails works OK. Any idea of reason ?

Im attaching exports of my media mover configurations, example node and content type

AttachmentSize
mm_config-transcode_store_cck.txt2.72 KB
mm_config-make_jpg_store_cck.txt2.25 KB
example_problematic_node.txt4.13 KB
content-type-video.txt9.91 KB

#1

szczym - August 17, 2009 - 10:32

i just recreated that bug on other, plain drupal instalation.

if its need i can supply ssh access to that sandbox

#2

lancelot - June 16, 2009 - 10:42

Try to test your FFMpeg-Wrapper module:
- go to admin/settings/ffmpeg_wrapper/test
- place some file into test direcotry
- refresh page
- choose 'use' in file list
- choose output format
- transcode

In my case there was an error while audio transcoding from avi to flv. I checked 'use advanced settings' and set sample rate to 44 (there was an ffmpeg error about audio sample rate). And now it works!

#3

szczym - June 16, 2009 - 15:46
Category:support request» bug report

ffmpeg works, actually any setup works fine when i make it first.

Problem is: any media mover config, that was made after the first one is not submitting results into cck filefiled (but processing works, its in logs and files are made ok).

#4

szczym - July 28, 2009 - 15:44
Priority:normal» critical

the issue is similar (but not identical) to #368956: Error saving to filefield in cron

Im changing it to critical, as its serous stopper for many websites.

#5

szczym - July 29, 2009 - 15:36
Title:Files transoded but not added fo filefiled » Files transoded but not added to filefiled

#6

jzornig - July 31, 2009 - 04:30

I have the same issue. I have two MM configs. One creates a thumb, the other transcodes the video. Both place the created files into CCK filefields. If only one config is enabled, it works. Either thumb or transcode succeeds. If both are enabled I only get the thumb attached. The transcoded video is created but not added to the CCK field.

#7

venkiparam - August 7, 2009 - 10:39

Any updates, I am having the same issue, Transcoded files are not getting saved to cck filefield.

#8

venkiparam - August 7, 2009 - 13:59

Ok, I took some time to probe through the code and found a spot where i think the problem is.

Its in the mm_cck.module on line number 57 - 59 in function mm_cck_media_mover, source looks like this

case 'complete':
case 'storage':
return mm_cck_node_save($action, $configuration, $file);

The problem is whenever you run a configuration, the function called for storage & complete (verbs) is the same. The problem occurs because the " storage " routine properly stores the data in the cck filefield but the " complete " routine overwrites the previous entry and hence the filefield association is completely lost.

To get a successful result (That is, the converted file gets properly attached to the cck field), try setting " bypass this operation " in the complete step or use some other operation other than the cck provided one and all works well.

Hope i am sufficiently clear for the maintainer to understand.Pardon me, this is the first time i have probed a drupal module and may be my language is not proper too.

Venkiparam

#9

szczym - August 7, 2009 - 18:05

venkiparam: im having in 2 configs the "complete" set on "Media Mover defaults: Bypass this operation" and its still not adding icons into cck, plus its running the configs any time i run cron...

:/

could you post your working configs ?

#10

venkiparam - August 8, 2009 - 05:27

Attached an export of the working config file. This config does nothing more than Transcoding the input file using ffmpeg and attaching it to cck field. And for the Cron issue, Make sure u have unchecked the option "Run Media Mover on cron runs" under the "Run Control" section on the settings screen (admin/build/media_mover/settings).

AttachmentSize
MMWorking.txt 2.24 KB

#11

szczym - August 8, 2009 - 10:53

The issue concerns 2 mm configs: for example first for encoding and second for generating thumbnails. Problem is one of mm configs is not adding effects into the cck file filed.

The "Run Media Mover on cron runs" setting is essential for any production site.

#12

venkiparam - August 10, 2009 - 11:30

Hi you were right, This is happening to me too. But i feel this is very similar #8 which i have posted above, but the issue is not with using "mm_cck_node_save()" for both storage & complete. The issue is with the mm_cck_node_save() function itself.

If you go down the call hirearchy, The function " mm_cck_field_filefield() " gets called when the field type is filefield. I tried putting a debug statement just before node_save($node) inside " mm_cck_field_filefield() " and found few interesting thing. I have attached the output to this reply. For clarity purpose, I have also attached the two configurations i used for this test.

My Observations.

The debug text has two blocks of output seprated by "------------------" . The first block is the output when the Transcoding configuration is run and the second block is the output when the thumbnail configuration is run.

It is clear that at the Transcoding phase the thumbnail array is empty, which is ok

[field_mm_thumb_file] => Array
(
[0] =>
)

But at the thumbnail generation phase the transcoded file array is empty which is not desirable.

[field_mm_result_file] => Array
(
[0] =>
)

This is the reason why the transcoded file is not shown at the node view page. Can any one post a solution to this

AttachmentSize
Debug.txt 15.22 KB
transcoding.txt 2.31 KB
thumbnail.txt 1.83 KB

#13

mani.atico - August 11, 2009 - 20:32

subscribing

#14

zaczek - August 17, 2009 - 21:06

Hi,

I think I might have found a solution: http://drupal.org/node/368956#comment-1935600

Could you please test it on your site? It worked for Szczym's site.

Cheers,
Jakub Gawlikowski

#15

zaczek - August 18, 2009 - 08:28

This issue is related with a change made in the CCK module: http://drupal.org/node/227677

The fix reverts to the default behaviour (not setting NULLs on fields that are not provided).

Jakub

#16

zaczek - August 18, 2009 - 08:54

Here is a patch for this problem meant for the CCK module (content.module).

It is meant for CCK-6.x-2.5.

It only works on non-multiple fields (i.e. if the number of values for the destination filefield to be used is set to 1 in the field definition for your content type).

Please let me know if you encounter any issues. Maybe somebody knows if it's possible to fix it in the Media Mover module?

Cheers,
Jakub

AttachmentSize
nullupdate-fix.patch 614 bytes

#17

szczym - August 18, 2009 - 10:21
Status:active» reviewed & tested by the community

I confirm, the patch solves the problem!

We still need permanent solution (and we dont know if it brakes any other functions cck module)

#18

venkiparam - August 18, 2009 - 11:14

I have not applied the patch yet, But i believe that what Damien Tournoud says here http://drupal.org/node/227677#comment-1937658 is true. CCK is inserting NULL into the columns because we are passing NULL (see #12 debug.txt). We need to find a solution inside Media mover.

#19

zaczek - August 19, 2009 - 08:46

OK, I have looked into this again and found a way to update the Media Mover API with no changes necessary in CCK.

The problem was related with the node_load function that can only load data from core tables. This was causing the Media_Mover module to update the record with NULL data it got trying to query the nodes.

The solution is was to use the content_node_load function written by alonpeer and described here: http://drupal.org/node/360541

This function is able to load the full node including CCK fields. I have added this function to the Media Mover API, as it might be useful in other situations.

So now, instead of using node_load($nid); we are using content_node_load(array('nid' => $nid));

The new patch for media_mover_api.module is attached. It also handles the situation for multiple fields.

Cheers,
Jakub

AttachmentSize
nullupdate-0.2.patch 5.38 KB

#20

zaczek - August 19, 2009 - 10:00

In this patch version, I have made a small change to follow naming conventions and changed the function name to media_mover_content_node_load.

AttachmentSize
media_mover_api-nullupdate-0.3.patch 4.88 KB

#21

szczym - August 19, 2009 - 10:06

new patch works :))) I just tested it, could any one test it also ?

cheers !

#22

venkiparam - August 19, 2009 - 10:49

Confirming, The new patch works for me , Thanks to zaczek

#23

venkiparam - August 20, 2009 - 06:06

The patch also works in the Dev version (Release Jul 19 2009).

#24

zaczek - August 20, 2009 - 07:57

Thanks, Venkiparam.

For everyone else, the patch in question is attached here.

AttachmentSize
media_mover_api-nullupdate-0.3-dev.patch 4.87 KB

#25

bekasu - August 24, 2009 - 03:01
Title:Files transoded but not added to filefiled» Files transcoded but not added to filefiled

Corrected misspelling in title per szczym's request

#26

szczym - September 8, 2009 - 17:28

Im not sure if its directly related but that issue have #532170: MM is encoding a file any time i run config arise right now. (don`t if it was before because its happening only with more than one configuration).

#27

arthurf - September 15, 2009 - 02:04

Thanks for finding this issue. Reviewing this patch, I see a few things:
* it has to conditionally load CCK- if(module_exists('content') ) if it goes into the media_mover_api module- otherwise it should live in mm_cck which depends on CCK anyway. I like the idea of having this as a core function in media_mover_api, but I'm not sure that there are any use cases beyond CCK? Not sure.
* is there a need to rewrite all of this code an not just use cck's content_load($node) function instead? If we do something like:

<?php
  $node
= node_load($nid);
 
content_load($node);
?>

Doesn't that give us all the same information and make the function less brittle?

I'd be happy to commit this, I just would like some feed back on the above first.

#28

zaczek - September 15, 2009 - 09:45

Hi Arthurf,

I have tested this code:

$node = node_load($nid);
content_load($node);
return $node;

and it seems to work. It is cleaner for sure. You are probably right that there are no use cases beyond CCK, however I don't know how to integrate it with the mm_cck module.

Best,
Jakub

#29

arthurf - September 15, 2009 - 13:37
Version:6.x-1.0-beta2» 6.x-1.x-dev
Status:reviewed & tested by the community» needs review

Thanks for testing. I committed this code to CVS last night, so I think we should be reading for testing. I did some additional refactoring to make the code cleaner. Would people mind testing this and I'll ready a new release if it passes? There are a bunch of bug fixes that would be nice to get out in the world since I've been slacking so much this summer.

#30

szczym - September 15, 2009 - 16:29

arthurf its great to have you back in moving media space ! We have all ready developed patched mm, witch consisted of over 5 various patch as far as i remember ;)

I would test the cvs code strait on but here: http://drupal.org/project/cvs/106431 i can`t see any commits regarding to #486206: Files transcoded but not added to filefiled. Am i missing some thing ?

#31

arthurf - September 16, 2009 - 16:18

Hrm, maybe I attributed these to a different ticket- see:
http://drupal.org/cvs?commit=261334
http://drupal.org/cvs?commit=263064

So these fixes should be in the dev branch now...

#32

szczym - September 17, 2009 - 02:42
Status:needs review» needs work

i just tested on fresh drupal install with mm-dev from 2009-Sep-17:

the issue still exist, i have 3 mm configs, effect of one of them is not attached to cck filefiled with configs on auto run. when i make configs run manually by pressing one by one, its working ok.

the issue also exit when i swap mm_cck.module for old version patched against old "summer" version of mm-dev

#33

arthurf - September 17, 2009 - 02:50

@szczym are you saying that the configuration is not running on cron, or that the fix for the filefield issue does not work?

#34

szczym - September 17, 2009 - 03:07

Configs are running on node creation, file is encoded, after it its on hd and in the mm log BUT not in filefiled.

btw: i have 3 configs, 2 of them are running ok, one not makes into filefiled.
btw2: im on irc

#35

arthurf - September 17, 2009 - 03:13

Are there any errors being reported by mm_cck in dblog?

#36

szczym - September 17, 2009 - 03:24

no, all is normal, no errors. here is log entry from ffmpeg:

MM FFmpeg converted this file: sites/default/files/media_mover/ffmpeg/converted/1/output_1.flv
ffmpeg ran this command:
-i 'sites/default/files/output_1.avi' -acodec mp3 -ar 22050 -ab 64k -vcodec flv -b 250k -r 25 'sites/default/files/media_mover/ffmpeg/converted/1/output_1.flv'

But output_1.flv did not landed in filefiled.

#37

okeedoak - September 24, 2009 - 04:22

subscribing

#38

szczym - September 25, 2009 - 13:18

@arthur: what is a problem to commit zaczek patch into dev version ? as far as i see, its not in cvs but its critical for normal usage of mm ...

#39

arthurf - September 25, 2009 - 13:22

The patch: http://drupal.org/files/issues/media_mover_api-nullupdate-0.3-dev.patch is in mm_cck. I don't want to use the function that is proposed as it is an attempt to duplicate content_load() which is a API function for cck- a much more stable way to do this. Can you test against 6.1.x and let me know if that is working for you?

#40

brunodbo - October 18, 2009 - 08:38

I tested 6.x-dev and found that storing to filefield only works when there's no complete action (as reported in #8). Furthermore, when I display the file as 'Generic files' (set in CCK 'Display fields' settings), the link is constructed with a '?q=' in front, thus pointing to a non-existing location. When I change the Display field setting to 'URL to file', the correct URL is being displayed.

#41

brunodbo - October 18, 2009 - 09:01

While transcoded files are added to the right filefield (given there's no complete action), they are not shown in the 'Media Mover files' section on node/edit (= the list where Media Mover files on that node should be displayed).

#42

arthurf - November 13, 2009 - 21:43
Status:needs work» active

@brunodbo - can you confirm that this file is not in an error state? You can check by going to the admin -> build -> media_mover -> your configuration -> files

#43

delykj - November 16, 2009 - 00:05

I tried the latest Media Mover dev version (2009. nov. 14.), with latest CCK, File Field modules and file field saving not works.
I also tried zaczek patch (http://drupal.org/node/486206#comment-1946978) but still not works.

Any idea how to save a successfully processed file into a file field?

#44

brunodbo - November 16, 2009 - 14:50

@arthurf: No, no error state. Thanks for following up.

#45

delykj - November 17, 2009 - 16:21

I debugged the code and fixed the bug.

In the mm_cck_field_filefield function, please change

from:

  // Add the file on to the node
$node->{$field['field_name']}[] = $new_file;

to:

 
  // Add the file on to the node
  if ($node->{$field['field_name']}[0] == null) {
    $node->{$field['field_name']}[0] = $new_file;
  } else
    $node->{$field['field_name']}[] = $new_file;
 

When I create a new node, and the filefield is empty, the first field in the array is null. So at the cron run when you add the newly created field to the field array, Drupal not saves the new field because of the first null value.

#46

arthurf - November 17, 2009 - 19:40
Status:active» needs review

@delykj - I've committed a variation of your code suggestion. This issue was discussed on another issue- the original code used $node->{$field['field_name']}[0] which was changed to $node->{$field['field_name']}[] due to another bug report. Hopefully your suggestion fixes it in both instances.

#47

delykj - November 17, 2009 - 22:33

arthurf, your modification not works for me.
$node->{$field['field_name']} is an array, so not need to check it (at least in my case). But the first element is null.
I modified your code a little bit:

  
  // Do any files already exist on this node?
  if (! is_array($node->{$field['field_name']})) {
    $node->{$field['field_name']} = array($new_file);
  }
  elseif ($node->{$field['field_name']}[0] == null)  {
    $node->{$field['field_name']}[0] = $new_file;
  }
  else {
        $node->{$field['field_name']}[] = $new_file;
  }

 
 

Drupal is a registered trademark of Dries Buytaert.