thekid / dialog

Dialog photoblog
2 stars 1 forks source link

Video support #8

Closed thekid closed 1 year ago

thekid commented 1 year ago

This pull request adds support for uploading video in content using FFMPeg

Screenshot
thekid commented 1 year ago

There are problems when uploading the media takes too long - resulting in an exception after ~30 seconds:

Console output

We might be able to fix this using https://github.com/xp-forge/web/pull/92

thekid commented 1 year ago

There are problems when uploading the media takes too long - resulting in an exception after ~30 seconds:

Moving Expect: 100-continue handling to the REST API library fixes the upload problem for curl, see https://github.com/xp-forge/rest-api/pull/16

thekid commented 1 year ago

Good question why the PHP upload doesn't work:

$transfer= ['video' => new File('Albums/.../video-20191017_122438000_iOS.MOV.mp4')];

$upload= new RestUpload($this->api, $this->api
  ->resource('entries/{0}/images/{1}', [$item['slug'], $entry->name()])
  ->request('PUT')
  ->waiting(read: 3600)
);
foreach ($transfer as $kind => $file) {
   $upload->transfer($kind, $file->in(), $file->filename);
}
$r= $upload->finish();

...but this does:

$ curl -v \
  -X PUT \
  -F 'video=@Albums/.../video-20191017_122438000_iOS.MOV.mp4' \
  'https://...@dialog.sloppy.zone/api/entries/.../images/20191017_122438000_iOS.MOV'
# ...
thekid commented 1 year ago

We also need to make uploads work asynchronously to not block the server while images are being uploaded, see https://github.com/xp-forge/web/pull/92

thekid commented 1 year ago

Four things we can improve upon in the future:

As stated in other pull requests, as long as we're pre-1.0, we can live with this imperfection for the moment 🙃

thekid commented 1 year ago

The screenshot quality looks a bit rough, if I manually pause the video and make a screenshot it looks better. How can the ffmpeg command line copy this?

My observation was that the WebP file ffmpeg was producing was way inferior in quality compared to the JPEG. By removing the -vf scale=xxx:-1 argument and converting to JPEG first, then resizing and converting that we can achieve quite a bit of an improvement

Example

Before After
Before After