veliovgroup / Meteor-Files

🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.
https://packosphere.com/ostrio/files
BSD 3-Clause "New" or "Revised" License
1.11k stars 167 forks source link

HTML5 H264 MP4 links generated via link() cannot be played in the video tag #802

Closed myuid closed 2 years ago

myuid commented 3 years ago

The H264 MP4 video file I generated by FFMPEG can not play properly if I write() the file, I use addFile() to write relevant data in the collection, and the link generated by link() can not play normally in Chrome, I don't know why?

dr-dimitru commented 3 years ago

@myuid

  1. Can you play generated videos file directly opening it in Chrome?
  2. Do you get any errors/exceptions?
  3. What do you mean can not play normally? Do you see artifacts or issues with "seek" on timeline? Or video doesn't plays at all?
myuid commented 3 years ago

Drag the video directly into Chrome and play it without any problems, and write the file successfully using the following methods import fs from 'fs'; import { FilesCollection } from 'meteor/ostrio:files';

const Images = new FilesCollection({collectionName: 'Images'});

fs.readFile('/data/imgs/sample.png', (error, data) => { if (error) { throw error; } else { Images.write(data, { fileName: 'sample.png', fileId: 'abc123myId', //optional type: 'image/png' }, (writeError, fileRef) => { if (writeError) { throw writeError; } else { console.log(${fileRef.name} is successfully saved to FS. _id: ${fileRef._id}); } }); } }); But the file cannot be played (VLC and Chrome), then add the following file to FileCollection import { FilesCollection } from 'meteor/ostrio:files';

const Images = new FilesCollection({collectionName: 'Images'});

Images.addFile('/var/www/files/sample.png', { fileName: 'sample.png', type: 'image/png', fileId: 'abc123AwesomeId', meta: {} });

The URL generated using the following method cannot be played back const fileRef = Images.collection.findOne({}); Images.link(fileRef);

The operation of the pictures is normal

dr-dimitru commented 3 years ago

@myuid I recommend you trying to add ?play=true get query at the end of file's URL. Let me know if it helps

dr-dimitru commented 2 years ago

Feel free to reopen it in case if the issue is still persists on your end.