sr229/animegrep

Unsafe filename when merging

daniel-Jones opened this issue · 10 comments

c398ded introduced a regression, merging no longer works.

daniel_j@cirno[~/programming/bash/animegrep-1]$ ./animegrep.sh -m
merging mkv's..
ffmpeg version n4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[concat @ 0x559227e62e00] Unsafe file name '"clip_100.mkv"'
video_files.txt: Operation not permitted

Can you show the contents of video_files.txt?

...
file "clip_8.mkv"
file "clip_90.mkv"
file "clip_91.mkv"
file "clip_92.mkv"
file "clip_93.mkv"
file "clip_94.mkv"
file "clip_95.mkv"
file "clip_96.mkv"
file "clip_97.mkv"
file "clip_98.mkv"
file "clip_99.mkv"
file "clip_9.mkv"

sr229 commented

@daniel-Jones give 80cac6e a go and see if that fixes it

sr229 commented

I'll assume the bug is fixed but we'll wait for OP to see if it doesn't fix it.

daniel_j@cirno[~/programming/bash/animegrep-1]$ ./animegrep.sh -m
./animegrep.sh: option requires an argument -- m
./animegrep.sh [-d <directory> | -f <file> ] -t <track> -w <WORD> -m -h

animegrep is a bash script that extracts the subtitles from an mkv video file, greps them for a specified word, parses them and extracts only that time frame from the source video file

-d <directory> sets a directory as your source media
-f <file> sets a file as your source media. You cannot set directory and files at the same time.
-t <track> Not Documented.
-w <word> track number for your source media.
-m to merge multiple output files as one. Useful if you have -d set.

has the merging behavior changed or is it broken now?

I tried adding -safe 0 to a previous version earlier today that worked, however it then complained about the file missing (it needs out/ prepended to it)

daniel_j@cirno[~/programming/bash/animegrep-1]$ ./animegrep.sh -m broken_merge
./animegrep.sh: line 34: [: -m: binary operator expected
merging mkv's..
ffmpeg version n4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[concat @ 0x5561d62a9e80] Impossible to open '"clip_100.mkv"'
video_files.txt: No such file or directory

Files are also out of order in this file. they need to be in order for merging (assuming ffmpeg doesn't order them internally). see https://gnupluslinux.com/video_files.txt

sr229 commented

9d1795e should fix the sorting issue. Now for prepending, I don't know exactly how to do it via sed.

Modifying my sed command: sed 's/^"/file "out\/clips\//' should work, needs testing

sr229 commented

Modifying my sed command: sed 's/^"/file "out\/clips\//' should work, needs testing

@Martmists give it a test then PR it if it works.