sigal icon indicating copy to clipboard operation
sigal copied to clipboard

Videos with folders / filenames containing spaces

Open leplatrem opened this issue 7 years ago • 6 comments

The video conversion seems to fail when the folder/filename contains spaces.

I tried to add shell=True here: https://github.com/saimn/sigal/blob/7e35d1fa4076c3d18a9404eded123d5fc50e2182/sigal/utils.py#L103

It worked for obtaining video size, but wasn't enough for the other operations apparently...

If you have ideas, I'd glad to contribute a patch!

Oh, and congrats for this super handy software, I love it :)

leplatrem avatar Nov 14 '17 14:11 leplatrem

Hi Mathieu, I guess one solution would be to escape the file name with double quotes, i.e. replace source with '"{}"'.format(source), if you want to try it's great !

saimn avatar Nov 14 '17 15:11 saimn

Actually the video currently used in the unit tests already have a space in its name: https://github.com/saimn/sigal/blob/master/tests/sample/pictures/video/stallman%20software-freedom-day-low.ogv Do you more detail on your failure (like a traceback) ? The error may be due to a space in the path (directory name) or in a missing escaping ?

saimn avatar Nov 14 '17 18:11 saimn

The only output I have is:

INFO: DSC_5903.JPG exists - skipping
Traceback (most recent call last):
  File "/var/www/pix.org/.env/bin/sigal", line 11, in <module>
    sys.exit(main())
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/sigal/__init__.py", line 142, in build
    gal.build(force=force)
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/sigal/gallery.py", line 638, in build
    for res in self.pool.imap_unordered(worker, media_list):
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next
    raise value
OSError: [Errno 2] No such file or directory

If I run the right ffmpeg command by hand to convert the video, it fails further with the thumbnail:

DEBUG: Generating thumbnail for <Video>('Ba/Annee 2/Ba 2 ans.webm')
DEBUG: Create thumbnail for video: ffmpeg -i /var/www/pix.org/html/n/Ba/Annee 2/Ba 2 ans.webm -an -r 1 -ss 0 -vframes 1 -y /var/www/pix.org/html/n/Ba/Annee 2/thumbnails/Ba 2 ans.jpg.tmp.jpg
ERROR: Failed to generate thumbnail: [Errno 2] No such file or directory

The errors were not very insightful...

leplatrem avatar Nov 15 '17 08:11 leplatrem

Yes multiprocessing make it harder to debug, but can you run sigal with -n 1 to avoid using the pool of processes ?

saimn avatar Nov 15 '17 09:11 saimn

Thanks!

Surrounding with quotes does not change much...

  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/sigal/video.py", line 67, in video_size
    ret, stdout, stderr = call_subprocess(['ffmpeg', '-i', '"%s"' % source])
  File "/var/www/pix.org/.env/local/lib/python2.7/site-packages/sigal/utils.py", line 103, in call_subprocess
    p = Popen(cmd, stdout=PIPE, stderr=PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I get better results with shell=True (and still surrounding with double quotes). But still a weird error:

DEBUG: Video size: 0, 0 -> 9999, 7777
DEBUG: Processing video: ffmpeg -i "/var/www/pix.org/albums/Annee 2/Armand 2 ans.mp4" -y -crf 10 -b:v 1.6M -qmin 4 -qmax 63 "/var/www/pix.org/html/Annee 2/Armand 2 ans.webm"
DEBUG: STDOUT:
 
DEBUG: STDERR:
 -i: 1: -i: ffmpeg: not found

leplatrem avatar Nov 16 '17 22:11 leplatrem

Hmm, -i: 1: -i: ffmpeg: not found: could it be due to some difference in arguments handling between avconv and ffmep ?

saimn avatar Nov 20 '17 12:11 saimn