trahay / bbb-downloader

a few scripts for downloading BBB videos
GNU General Public License v3.0
104 stars 21 forks source link

Add the possibility to select the video resolution #17

Open trahay opened 4 years ago

trahay commented 4 years ago

Thank you very much. Can I set higher resolution and h.264 main profile? After a download I have only 520 pixels like vertical resolution and I can open the file only with vlc (due to high 4:4:4 profile). I can convert them manually with commamd "ffmpeg -i input.mp4 -profile:v main -pix_fmt yuv420p out.mp4" to solve the issue, but can you do anything while downloading?

Originally posted by @gioluca2 in https://github.com/trahay/bbb-downloader/issues/16#issuecomment-719632424

trahay commented 4 years ago

For now, the script captures a 1080x720 video which is then cropped (to remove the firefox window that plays the video). You can try changing the resolution of the captured video in capture-full-replay.sh line 111:

diff --git a/capture-full-replay.sh b/capture-full-replay.sh
index c16ec7e..59a1ff3 100755
--- a/capture-full-replay.sh
+++ b/capture-full-replay.sh
@@ -108,7 +108,7 @@ function capture() {
     docker run --rm -d --name=$container_name -P --expose 24444 \
           --shm-size=2g -e VNC_PASSWORD=hola \
           -e VIDEO=true -e AUDIO=true \
-          -e SCREEN_WIDTH=1080 -e SCREEN_HEIGHT=720 \
+          -e SCREEN_WIDTH=1920 -e SCREEN_HEIGHT=1080 \
           -e FFMPEG_DRAW_MOUSE=0 \
           -e FFMPEG_FRAME_RATE=24 \
           -e FFMPEG_CODEC_ARGS="-vcodec libx264 -preset ultrafast -pix_fmt yuv420p -strict -2 -acodec aac" \

This should capture a 1920x1080 video that is then cropped (by removing the top 144 pixels, and the 56 bottom pixels). In case you want to capture only the main screen, I'm not sure how to compute its width.

gioluca2 commented 3 years ago

I have this error when launch "./capture-full-replay.sh -i test.txt":

Downloading https://davy04.edunova.it/playback/presentation/2.0/playback.html?meetingId=864259013d2f6b5cc58277044064e5ba60aff93c-1603784451720, and saving it as 2020.10.27.mp4
.
  0% |                                                                        |
 16% |############                                                            |
 33% |########################                                                |
 50% |####################################                                    |
 66% |################################################                        |
 83% |############################################################            |
100% |########################################################################|
  0% |                                                                        |
 25% |##################                                                      |
 50% |####################################                                    |
 75% |######################################################                  |
100% |########################################################################|
Downloading Videos

[1/2]  saved 'webcams' (https://davy04.edunova.it/presentation/864259013d2f6b5cc58277044064e5ba60aff93c-1603784451720/video/webcams.webm).

[2/2]  saved 'deskshare' (https://davy04.edunova.it/presentation/864259013d2f6b5cc58277044064e5ba60aff93c-1603784451720/deskshare/deskshare.webm).
Everyting was downloaded into '864259013d2f6b5cc58277044064e5ba60aff93c-1603784451720/'.
148d747da5e3b30f1926777c02a44e44b02adfe443dc21c735570677d8c084c2
Waiting for docker-selenium to be ready...
.............................
Container docker internal IP: 172.17.0.3
Selenium all done and ready for testing!

Please wait for 1011 seconds, while we capture the playback...
[...]
video-rec: stopped
Waiting for video to stop recording...
video-rec                        STOPPED   Nov 06 12:40 PM
Done waiting for video recording to stop.
Video recording stopped
--LOG 12:40:39:467731600 -- DEBUG: video-rec-stdout.log ----
frame=25517 fps= 24 q=12.0 size=  350216kB time=00:17:42.91 bitrate=2699.1kbits/s    
frame=25517 fps= 24 q=12.0 size=  350216kB time=00:17:42.91 bitrate=2699.1kbits/s    
--LOG 12:40:09:540998500 Trapped SIGTERM or SIGINT so shutting down ffmpeg gracefully...
--LOG 12:40:09:554031600 Will kill VID_TOOL_PID=618 ...
frame=25517 fps= 24 q=-1.0 Lsize=  350218kB time=00:17:43.20 bitrate=2698.4kbits/s    
video:150735kB audio:199134kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.099758%
[libx264 @ 0x1f5ddc0] frame I:103   Avg QP:11.76  size:173281
[libx264 @ 0x1f5ddc0] frame P:25414 Avg QP:14.65  size:  5371
[libx264 @ 0x1f5ddc0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x1f5ddc0] mb P  I16..4:  0.5%  0.0%  0.0%  P16..4:  7.0%  0.0%  0.0%  0.0%  0.0%    skip:92.5%
[libx264 @ 0x1f5ddc0] coded y,u,v intra: 30.5% 8.3% 8.6% inter: 4.0% 0.5% 0.7%
[libx264 @ 0x1f5ddc0] i16 v,h,dc,p: 42% 50%  5%  4%
[libx264 @ 0x1f5ddc0] kb/s:1161.41
Exiting normally, received signal 2.
--LOG 12:40:10:560648900 Tried to kill -SIGTERM VID_TOOL_PID=618
--LOG 12:40:10:564059900 Waiting up to 6s for VID_TOOL_PID=618 to end with SIGTERM...
--LOG 12:40:10:582511200 wait_pid successfully managed to SIGTERM:VID_TOOL_PID=618 within less than 6s
--LOG 12:40:10:586045700 Will try to fix the videos...
--LOG 12:40:11:122201900 Fixing perms for /home/seluser/videos/vid_chrome_25550_firefox_25551.mkv*
--LOG 12:40:11:147565800 Changing video encoding from mkv to mp4...
--LOG 12:40:31:178884000 Conversion from mkv to mp4 FAILED! in within the 20s
--LOG 12:40:31:186787800 Optimizing /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4 for HTTP streaming...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:31:823533600 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:32:831524400 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:33:842455800 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:34:852307400 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:35:872398700 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:36:881293300 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:37:889858100 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
Error opening file /home/seluser/videos/vid_chrome_25550_firefox_25551.mp4: Invalid IsoMedia File
--LOG 12:40:38:898634500 MP4Box got errors meaning the mp4 video file is corrupted, trying again...
--LOG 12:40:39:191831800 Failed! to mp4box_retry.sh within 8s
--LOG 12:40:39:195587700 ffmpeg shutdown complete.
--LOG 12:40:39:508377700 -- DEBUG: video-rec-stderr.log ----
frame= 1023 fps=185 q=15.0 size=    3787kB time=00:00:42.74 bitrate= 725.7kbits/s    
frame= 1109 fps=184 q=15.0 size=    4162kB time=00:00:46.34 bitrate= 735.6kbits/s    
frame= 1202 fps=184 q=15.0 size=    4666kB time=00:00:50.20 bitrate= 761.2kbits/s    
frame= 1294 fps=184 q=16.0 size=    5228kB time=00:00:53.98 bitrate= 793.4kbits/s    
frame= 1384 fps=184 q=17.0 size=    5690kB time=00:00:57.81 bitrate= 806.2kbits/s    
frame= 1471 fps=183 q=15.0 size=    6190kB time=00:01:01.38 bitrate= 826.1kbits/s    
frame= 1559 fps=183 q=14.0 size=    6769kB time=00:01:05.10 bitrate= 851.7kbits/s    
frame= 1648 fps=182 q=15.0 size=    7267kB time=00:01:08.79 bitrate= 865.3kbits/s    
frame= 1738 fps=182 q=15.0 size=    7732kB time=00:01:12.52 bitrate= 873.4kbits/s    
frame= 1820 fps=181 q=17.0 size=    8335kB time=00:01:15.94 bitrate= 899.1kbits/s    
frame= 1915 fps=181 q=14.0 size=    8877kB time=00:01:19.93 bitrate= 909.8kbits/s    
frame= 2009 fps=182 q=16.0 size=    9443kB time=00:01:23.80 bitrate= 923.0kbits/s    
frame= 2102 fps=182 q=13.0 size=    9923kB time=00:01:27.67 bitrate= 927.2kbits/s    
frame= 2195 fps=182 q=16.0 size=   10408kB time=00:01:31.60 bitrate= 930.8kbits/s    
frame= 2279 fps=181 q=14.0 size=   10978kB time=00:01:35.06 bitrate= 946.0kbits/s    
frame= 2365 fps=181 q=16.0 size=   11457kB time=00:01:38.70 bitrate= 950.9kbits/s    
frame= 2455 fps=181 q=18.0 size=   11990kB time=00:01:42.41 bitrate= 959.1kbits/s    
frame= 2540 fps=180 q=15.0 size=   12630kB time=00:01:45.95 bitrate= 976.5kbits/s    
frame= 2629 fps=180 q=14.0 size=   13081kB time=00:01:49.62 bitrate= 977.5kbits/s    
frame= 2720 fps=180 q=15.0 size=   13532kB time=00:01:53.44 bitrate= 977.2kbits/s    
frame= 2810 fps=180 q=16.0 size=   14063kB time=00:01:57.17 bitrate= 983.2kbits/s    
frame= 2897 fps=180 q=15.0 size=   14430kB time=00:02:00.83 bitrate= 978.2kbits/s    
frame= 2992 fps=180 q=17.0 size=   14847kB time=00:02:04.81 bitrate= 974.5kbits/s    
frame= 3084 fps=180 q=16.0 size=   15434kB time=00:02:08.57 bitrate= 983.4kbits/s    
frame= 3178 fps=181 q=14.0 size=   15984kB time=00:02:12.58 bitrate= 987.6kbits/s    
frame= 3280 fps=181 q=15.0 size=   16517kB time=00:02:16.79 bitrate= 989.1kbits/s    
frame= 3376 fps=181 q=12.0 size=   16861kB time=00:02:20.80 bitrate= 981.0kbits/s    
frame= 3484 fps=182 q=12.0 size=   17011kB time=00:02:25.24 bitrate= 959.4kbits/s    
frame= 3592 fps=183 q=12.0 size=   17300kB time=00:02:29.79 bitrate= 946.1kbits/s    
frame= 3662 fps=184 q=-1.0 Lsize=   17475kB time=00:02:32.72 bitrate= 937.3kbits/s    
video:15170kB audio:2205kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.572247%
[libx264 @ 0x1902de0] frame I:15    Avg QP:12.40  size:133176
[libx264 @ 0x1902de0] frame P:3647  Avg QP:14.82  size:  3712
[libx264 @ 0x1902de0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x1902de0] mb P  I16..4:  0.5%  0.0%  0.0%  P16..4:  5.4%  0.0%  0.0%  0.0%  0.0%    skip:94.1%
[libx264 @ 0x1902de0] coded y,uvDC,uvAC intra: 35.9% 30.6% 21.2% inter: 3.2% 1.9% 0.6%
[libx264 @ 0x1902de0] i16 v,h,dc,p: 40% 49%  5%  5%
[libx264 @ 0x1902de0] i8c dc,h,v,p: 52% 34%  8%  5%
[libx264 @ 0x1902de0] kb/s:814.43
Exiting normally, received signal 15.
grid18808
height=720, width=1280
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  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
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, matroska,webm, from '/tmp/tmp.VqwMB4udmr/vid_chrome_25550_firefox_25551.mp4':
  Metadata:
    ENCODER         : Lavf56.40.101
  Duration: 00:17:43.21, start: 0.000000, bitrate: 2698 kb/s
    Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p(progressive), 1280x720, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 1k tbn, 48 tbc (default)
    Metadata:
      ENCODER         : Lavc56.60.100 libx264
      DURATION        : 00:17:43.209000000
    Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      DURATION        : 00:17:42.865000000
[NULL @ 0x55fe9fc58b00] Unable to find a suitable output format for '2020.10.27.mp4
'
2020.10.27.mp4
: Invalid argument

DONE. Your video is ready in 2020.10.27.mp4

Download stop after only one file (inside test.txt there are 2 links) and no videos are saved. How can I solve this issue?

trahay commented 3 years ago

I notice that the output file is '2020.10.27.mp4\n' which seems to make ffmpeg unhappy. Did you insert so weird line break in test.txt ?

gioluca2 commented 3 years ago

No, maybe I write it in Windows but this is test.txt:

https://davy04.edunova.it/playback/presentation/2.0/playback.html?meetingId=864259013d2f6b5cc58277044064e5ba60aff93c-1603784451720 2020.10.27.mp4
https://davy04.edunova.it/playback/presentation/2.0/playback.html?meetingId=864259013d2f6b5cc58277044064e5ba60aff93c-1603889413340 2020.10.28.mp4

I tryed with a.mp4 and b.mp4 without success. I think there is a problem with -i option, because capture-full-replay.sh followed by the first link is working.

trahay commented 3 years ago

The problem does come from the -i option. With this option, the input file is read line by line and two variables are set: url and output_file. In your case, output_file contains a newline caracter, which should not happen since read removes it.

Can you send me your test.txt file (the plain file, not a copy-paste of its content) to francois.trahay@telecom-sudparis.eu so that I can investigate ?

trahay commented 3 years ago

Thanks for sending me your input file. It does contain \r\n at the end of each line, and read does not remove the \r, which causes the problem. Commit #4056837 fix the problem by removing \r 'manually'. Can you confirm that this fixes your problem ?

gioluca2 commented 3 years ago

I save it by notepad++ in Windows and I have to change to unix format. Sorry. I hope with this modify it works. I'am on wsl2 and using docker

Il Sab 7 Nov 2020, 16:16 François Trahay notifications@github.com ha scritto:

Thanks for sending me your input file. It does contain \r\n at the end of each line, and read does not remove the \r, which causes the problem. Commit #4056837 fix the problem by removing \r 'manually'. Can you confirm that this fixes your problem ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/trahay/bbb-downloader/issues/17#issuecomment-723458081, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFT43UJH6TDEVKUCPZOYAEDSOVQENANCNFSM4TF5274Q .

trahay commented 3 years ago

Actually, with commit #4056837 capture-full-replay.sh now supports input files that contain \r, so you don't need to change your file to unix format.