Hi,

I want to upload multiple sources of my video files manually.

What is the correct way to do this through video module, so that my html5 player picks only the one file, that suits the current browser? If I upload two files via video module (1x mp4 and 1x ogg) both appear when the node is shown...

This is possible to do via file field, you set the options to unlimited files and set the Manage display options to show the file in a video player. Then ONLY ONE file appears.

Thanks for any help.

CommentFileSizeAuthor
#1 Clipboard01.jpg96.89 KBdrupov

Comments

drupov’s picture

StatusFileSize
new96.89 KB

Here's a snapshot of what my node looks like at the moment, when two different video formats have been added to a video field.

dp_warren’s picture

Hi

I had a similar scenario but ended up adjusting my workflow to use Zencoder to create the HTML5 variants (ogv and webm formats) from a single source file.

Using this approach meant the video module will return all zen(encoded) files back in a 'playablefiles' array by default which means less coding providing you are happy to use zencoder. Here is what the returned array looks like for my custom field 'field_video_source':

[field_video_source] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [fid] => 146
                            [thumbnail] => 151
                            [uid] => 1
                            [filename] => 37-sintel.mp4video.mp4
                            [uri] => rcf://37-sintel.mp4video.mp4
                            [filemime] => video/mp4
                            [filesize] => 7826687
                            [status] => 1
                            [timestamp] => 1348653644
                            [origname] => 37-sintel.mp4video.mp4
                            [type] => video
                            [rdf_mapping] => Array
                                (
                                )

                            [autoconversion] => 1
                            [conversioncompleted] => 1
                            [conversionstatus] => 10
                            [playablefiles] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [fid] => 147
                                            [uid] => 1
                                            [filename] => 37-sintel.mp4video_mp4_1348653654.mp4
                                            [uri] => rcf://146/37-sintel.mp4video_mp4_1348653654.mp4
                                            [filemime] => video/mp4
                                            [filesize] => 346128
                                            [status] => 1
                                            [timestamp] => 1348653656
                                            [origname] => 37-sintel.mp4video_mp4_1348653654.mp4
                                            [type] => video
                                            [rdf_mapping] => Array
                                                (
                                                )

                                            [vid] => 7
                                            [original_fid] => 146
                                            [output_fid] => 147
                                            [job_id] => 27384315
                                        )

                                    [1] => stdClass Object
                                        (
                                            [fid] => 148
                                            [uid] => 1
                                            [filename] => 37-sintel.mp4video_ogv_1348653656.ogv
                                            [uri] => rcf://146/37-sintel.mp4video_ogv_1348653656.ogv
                                            [filemime] => video/ogg
                                            [filesize] => 321192
                                            [status] => 1
                                            [timestamp] => 1348653657
                                            [origname] => 37-sintel.mp4video_ogv_1348653656.ogv
                                            [type] => video
                                            [rdf_mapping] => Array
                                                (
                                                )

                                            [vid] => 7
                                            [original_fid] => 146
                                            [output_fid] => 148
                                            [job_id] => 27384317
                                        )

                                    [2] => stdClass Object
                                        (
                                            [fid] => 149
                                            [uid] => 1
                                            [filename] => 37-sintel.mp4video_webm_1348653657.webm
                                            [uri] => rcf://146/37-sintel.mp4video_webm_1348653657.webm
                                            [filemime] => video/webm
                                            [filesize] => 236309
                                            [status] => 1
                                            [timestamp] => 1348653658
                                            [origname] => 37-sintel.mp4video_webm_1348653657.webm
                                            [type] => video
                                            [rdf_mapping] => Array
                                                (
                                                )

                                            [vid] => 7
                                            [original_fid] => 146
                                            [output_fid] => 149
                                            [job_id] => 27384318
                                        )

                                )

                            [thumbnailfile] => stdClass Object
                                (
                                    [fid] => 151
                                    [uid] => 1
                                    [filename] => thumbnail-146_0001.jpg
                                    [uri] => rcf://videos/thumbnails/146/thumbnail-146_0001.jpg
                                    [filemime] => image/jpeg
                                    [filesize] => 4680
                                    [status] => 1
                                    [timestamp] => 1348653832
                                    [origname] => thumbnail-146_0001.jpg
                                    [type] => image
                                    [rdf_mapping] => Array
                                        (
                                        )

                                    [image_dimensions] => Array
                                        (
                                            [width] => 320
                                            [height] => 180
                                        )

                                )

                        )

                )

        )
drupov’s picture

Thanks!

So such a thing cannot be achieved without Zencoder?

I see that the service is not free so there is no helper function to do that manually?

Thanks

dp_warren’s picture

I'm sure it probably can be achieved without but I haven't looked at it as an option.

The function video_field_load in video.field.inc in the video module should provide an insight of how it's currently done if you are thinking of writing your own function to override

xqbzzr’s picture

Any progress on this yet? I am interested in exactly this solution but am not able to code this.

ben.denham’s picture

I also needed this functionality, so I created a custom field formatter that renders each video in a multiple-value field as a separate source.

I've uploaded a sandbox module with the field formatter, which you can download here: Multi-source Video.

jamesrward’s picture

Needed this for a client site and your code is working beautifully. Thanks so much! This allows me to use a free service like online-convert.com to convert the files myself and upload the variants manually. For a lot of folks without ffmpeg on their servers this provides a good free fallback option. Would love to see this included in the main module but for now ben.denham's solution is great.

RedTop’s picture

Thanks, great addition. Would be great for this to be included with the Video module!

I did have to change line 58 from:
for ($i = 1; $i < count($items); $i++) {
to
for ($i = 1; $i <= count($items); $i++) {

to have all files included in the video tag when adding more than two versions (m4v, webm, ogv).

I do have an issue remaining when using this in conjuction with flexslider:

    Notice: Undefined offset: 1 in multi_source_video_field_formatter_view() (line 58 of multi_source_video.module).
    Warning: Invalid argument supplied for foreach() in multi_source_video_field_formatter_view() (line 58 of multi_source_video.module).

However, not your problem. :)

haysuess’s picture

Thanks so much for this module, I have it working great. Makes it so much easier than transcoding with Zencoder.

Do you know a way to manually upload 3 different resolutions (480p, 720p, 1080p) and have the user be able to choose which one to see? Just like YouTube...

haysuess’s picture

This seems to be working fine, but I'm seeing these errors in Watchdog, after applying the chance listed in #8. Should I change the code back?

Notice: Undefined offset: 1 in multi_source_video_field_formatter_view() (line 58 of /home/psvideo/public_html/sites/all/modules/multi_source_video/multi_source_video.module).
Warning: Invalid argument supplied for foreach() in multi_source_video_field_formatter_view() (line 58 of /home/psvideo/public_html/sites/all/modules/multi_source_video/multi_source_video.module).
hypertext200’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)