Advertisement
Guest User

console

a guest
Apr 22nd, 2023
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 16.31 KB | None | 0 0
  1. (base) (venv) PS D:\Projects\engshell> python engshell.py --debug --showcode
  2. D:\Projects\engshell engshell>У меня есть файл C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4, с помощью ffmpeg (C:\Users\u
  3. ser\Desktop\test\ffmpeg.exe) я хочу сжать его в 2 раза, затем обрезать первые и последние 10 секунд и сохранить измененный файл c нижними
  4.  прочерками вместо пробелов.
  5. D:\Projects\engshell engshell>compiling...
  6. import os                                                                                                                        
  7. import subprocess                                                                                                                
  8.                                                                                                                                  
  9. # Set the path to the input file                                                                                                
  10. input_file = r"C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4"                                                    
  11. # Set the path to the ffmpeg executable                                                                                          
  12. ffmpeg_path = r"C:\Users\user\Desktop\test\ffmpeg.exe"                                                                          
  13. # Set the output file name                                                                                                      
  14. output_file = os.path.join(os.path.dirname(input_file), os.path.basename(input_file).replace(" ", "_"))                          
  15. # Set the command to compress the video to half its size                                                                        
  16. compress_command = f'"{ffmpeg_path}" -i "{input_file}" -vf "scale=iw/2:ih/2" -c:a copy "{output_file}_compressed.mp4"'          
  17. # Set the command to trim the video                                                                                              
  18. trim_command = f'"{ffmpeg_path}" -i "{output_file}_compressed.mp4" -ss 00:00:10 -t 00:00:10 -async 1 "{output_file}_trimmed.mp4"'
  19. # Set the command to replace spaces with underscores in the output file name                                                    
  20. rename_command = f'rename "{output_file}_trimmed.mp4" "{output_file}_trimmed.mp4".replace(" ", "_")'                            
  21. # Run the commands                                                                                                              
  22. subprocess.run(compress_command, shell=True)                                                                                    
  23. subprocess.run(trim_command, shell=True)                                                                                        
  24. subprocess.run(rename_command, shell=True)                                                                                      
  25. # Print the final result                                                                                                        
  26. print(f"File saved as {output_file}_trimmed.mp4".replace(" ", "_"))                                                              
  27. D:\Projects\engshell engshell>running...                                                                                        
  28. ffmpeg version 2023-01-04-git-4a80db5fc2-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  29.   built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  30.   configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-ic
  31. onv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable
  32. -libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-
  33. libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --e
  34. nable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafound
  35. ation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf -
  36. -enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable
  37. -dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-
  38. libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --
  39. enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis -
  40. -enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint        
  41.   libavutil      57. 43.100 / 57. 43.100
  42.   libavcodec     59. 56.100 / 59. 56.100
  43.   libavformat    59. 34.102 / 59. 34.102
  44.   libavdevice    59.  8.101 / 59.  8.101
  45.   libavfilter     8. 53.100 /  8. 53.100
  46.   libswscale      6.  8.112 /  6.  8.112
  47.   libswresample   4.  9.100 /  4.  9.100
  48.   libpostproc    56.  7.100 / 56.  7.100
  49. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4':
  50.   Metadata:
  51.     major_brand     : mp42
  52.     minor_version   : 0
  53.     compatible_brands: mp42mp41
  54.     creation_time   : 2023-04-07T15:56:59.000000Z
  55.   Duration: 00:02:42.16, start: 0.000000, bitrate: 619 kb/s
  56.   Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 298 kb/s, 23.98 fps, 2
  57. 3.98 tbr, 24k tbn (default)
  58.     Metadata:
  59.       creation_time   : 2023-04-07T15:56:59.000000Z
  60.       handler_name    : ?Mainconcept Video Media Handler
  61.       vendor_id       : [0][0][0][0]
  62.       encoder         : HEVC Coding
  63.   Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
  64.     Metadata:
  65.       creation_time   : 2023-04-07T15:56:59.000000Z
  66.       handler_name    : #Mainconcept MP4 Sound Media Handler
  67.       vendor_id       : [0][0][0][0]
  68. Stream mapping:
  69.   Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
  70.   Stream #0:1 -> #0:1 (copy)
  71. Press [q] to stop, [?] for help
  72. [libx264 @ 000001a505f408c0] using SAR=1/1
  73. [libx264 @ 000001a505f408c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
  74. [libx264 @ 000001a505f408c0] profile High, level 3.1, 4:2:0, 8-bit
  75. [libx264 @ 000001a505f408c0] 264 - core 164 r3103 941cae6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.ht
  76. ml - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 tre
  77. llis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=17 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 int
  78. erlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
  79.  keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq
  80. =1:1.00
  81. Output #0, mp4, to 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_compressed.mp4':
  82.   Metadata:
  83.     major_brand     : mp42
  84.     minor_version   : 0
  85.     compatible_brands: mp42mp41
  86.     encoder         : Lavf59.34.102
  87.   Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 24k
  88. tbn (default)
  89.     Metadata:
  90.       creation_time   : 2023-04-07T15:56:59.000000Z
  91.       handler_name    : ?Mainconcept Video Media Handler
  92.       vendor_id       : [0][0][0][0]
  93.       encoder         : Lavc59.56.100 libx264
  94.     Side data:
  95.       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  96.   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
  97.     Metadata:
  98.       creation_time   : 2023-04-07T15:56:59.000000Z
  99.       handler_name    : #Mainconcept MP4 Sound Media Handler
  100.       vendor_id       : [0][0][0][0]
  101. frame= 3888 fps=426 q=-1.0 Lsize=   23395kB time=00:02:42.15 bitrate=1181.9kbits/s speed=17.8x    
  102. video:17002kB audio:6282kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.473040%
  103. [libx264 @ 000001a505f408c0] frame I:49    Avg QP:14.42  size: 10264
  104. [libx264 @ 000001a505f408c0] frame P:1183  Avg QP:21.15  size:  6804
  105. [libx264 @ 000001a505f408c0] frame B:2656  Avg QP:25.00  size:  3335
  106. [libx264 @ 000001a505f408c0] consecutive B-frames:  4.0% 11.5%  9.6% 74.9%
  107. [libx264 @ 000001a505f408c0] mb I  I16..4: 25.1% 65.6%  9.3%
  108. [libx264 @ 000001a505f408c0] mb P  I16..4:  3.9% 20.5%  3.8%  P16..4:  8.7%  2.7%  0.9%  0.0%  0.0%    skip:59.5%
  109. [libx264 @ 000001a505f408c0] mb B  I16..4:  1.1%  3.9%  0.7%  B16..8: 15.6%  3.9%  0.9%  direct: 2.2%  skip:71.7%  L0:57.8% L1:37.0% BI:
  110. 5.3%
  111. [libx264 @ 000001a505f408c0] 8x8 transform intra:71.0% inter:72.9%
  112. [libx264 @ 000001a505f408c0] coded y,uvDC,uvAC intra: 45.0% 45.5% 7.9% inter: 5.8% 6.5% 0.1%
  113. [libx264 @ 000001a505f408c0] i16 v,h,dc,p: 28% 27% 17% 29%
  114. [libx264 @ 000001a505f408c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 21% 18%  7%  4%  4%  5%  5%  7%
  115. [libx264 @ 000001a505f408c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 23% 17%  7%  7%  5%  7%  4%  5%
  116. [libx264 @ 000001a505f408c0] i8c dc,h,v,p: 52% 23% 18%  6%
  117. [libx264 @ 000001a505f408c0] Weighted P-Frames: Y:1.4% UV:1.2%
  118. [libx264 @ 000001a505f408c0] ref P L0: 64.1%  8.6% 18.9%  8.4%  0.1%
  119. [libx264 @ 000001a505f408c0] ref B L0: 83.4% 13.4%  3.2%
  120. [libx264 @ 000001a505f408c0] ref B L1: 96.0%  4.0%
  121. [libx264 @ 000001a505f408c0] kb/s:858.86
  122. ffmpeg version 2023-01-04-git-4a80db5fc2-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  123.   built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  124.   configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-ic
  125. onv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable
  126. -libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-
  127. libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --e
  128. nable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafound
  129. ation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf -
  130. -enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable
  131. -dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-
  132. libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --
  133. enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis -
  134. -enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint        
  135.   libavutil      57. 43.100 / 57. 43.100
  136.   libavcodec     59. 56.100 / 59. 56.100
  137.   libavformat    59. 34.102 / 59. 34.102
  138.   libavdevice    59.  8.101 / 59.  8.101
  139.   libavfilter     8. 53.100 /  8. 53.100
  140.   libswscale      6.  8.112 /  6.  8.112
  141.   libswresample   4.  9.100 /  4.  9.100
  142.   libpostproc    56.  7.100 / 56.  7.100
  143. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_compressed.mp4':
  144.   Metadata:
  145.     major_brand     : isom
  146.     minor_version   : 512
  147.     compatible_brands: isomiso2avc1mp41
  148.     encoder         : Lavf59.34.102
  149.   Duration: 00:02:42.16, start: 0.000000, bitrate: 1181 kb/s
  150.   Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], 858 kb/s, 2
  151. 3.98 fps, 23.98 tbr, 24k tbn (default)
  152.     Metadata:
  153.       handler_name    : ?Mainconcept Video Media Handler
  154.       vendor_id       : [0][0][0][0]
  155.       encoder         : Lavc59.56.100 libx264
  156.   Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
  157.     Metadata:
  158.       handler_name    : #Mainconcept MP4 Sound Media Handler
  159.       vendor_id       : [0][0][0][0]
  160. Stream mapping:
  161.   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  162.   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
  163. Press [q] to stop, [?] for help
  164. [libx264 @ 0000020f91f21300] using SAR=1/1
  165. [libx264 @ 0000020f91f21300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
  166. [libx264 @ 0000020f91f21300] profile High, level 3.1, 4:2:0, 8-bit
  167. [libx264 @ 0000020f91f21300] 264 - core 164 r3103 941cae6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.ht
  168. ml - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 tre
  169. llis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=17 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 int
  170. erlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
  171.  keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq
  172. =1:1.00
  173. Output #0, mp4, to 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_trimmed.mp4':
  174.   Metadata:
  175.     major_brand     : isom
  176.     minor_version   : 512
  177.     compatible_brands: isomiso2avc1mp41
  178.     encoder         : Lavf59.34.102
  179.   Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 24k
  180. tbn (default)
  181.     Metadata:
  182.       handler_name    : ?Mainconcept Video Media Handler
  183.       vendor_id       : [0][0][0][0]
  184.       encoder         : Lavc59.56.100 libx264
  185.     Side data:
  186.       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  187.   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
  188.     Metadata:
  189.       handler_name    : #Mainconcept MP4 Sound Media Handler
  190.       vendor_id       : [0][0][0][0]
  191.       encoder         : Lavc59.56.100 aac
  192. frame=  240 fps=0.0 q=-1.0 Lsize=    1277kB time=00:00:09.98 bitrate=1048.0kbits/s speed=  11x    
  193. video:1109kB audio:160kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.649413%
  194. [libx264 @ 0000020f91f21300] frame I:4     Avg QP:15.88  size:  9106
  195. [libx264 @ 0000020f91f21300] frame P:66    Avg QP:21.15  size:  6550
  196. [libx264 @ 0000020f91f21300] frame B:170   Avg QP:24.90  size:  3917
  197. [libx264 @ 0000020f91f21300] consecutive B-frames:  2.1%  9.2%  3.8% 85.0%
  198. [libx264 @ 0000020f91f21300] mb I  I16..4: 13.5% 79.5%  6.9%
  199. [libx264 @ 0000020f91f21300] mb P  I16..4:  4.6% 24.0%  3.0%  P16..4:  8.9%  2.2%  0.6%  0.0%  0.0%    skip:56.7%
  200. [libx264 @ 0000020f91f21300] mb B  I16..4:  1.4%  5.9%  0.8%  B16..8: 17.1%  4.3%  0.9%  direct: 2.3%  skip:67.3%  L0:56.0% L1:38.9% BI:
  201. 5.0%
  202. [libx264 @ 0000020f91f21300] 8x8 transform intra:75.2% inter:78.4%
  203. [libx264 @ 0000020f91f21300] coded y,uvDC,uvAC intra: 44.9% 49.0% 7.9% inter: 6.2% 8.0% 0.1%
  204. [libx264 @ 0000020f91f21300] i16 v,h,dc,p: 26% 28% 17% 29%
  205. [libx264 @ 0000020f91f21300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 18%  7%  4%  4%  6%  5%  7%
  206. [libx264 @ 0000020f91f21300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 23% 18%  7%  7%  5%  7%  4%  5%
  207. [libx264 @ 0000020f91f21300] i8c dc,h,v,p: 51% 24% 18%  7%
  208. [libx264 @ 0000020f91f21300] Weighted P-Frames: Y:0.0% UV:0.0%
  209. [libx264 @ 0000020f91f21300] ref P L0: 62.2%  6.9% 21.6%  9.3%
  210. [libx264 @ 0000020f91f21300] ref B L0: 81.5% 15.2%  3.3%
  211. [libx264 @ 0000020f91f21300] ref B L1: 94.6%  5.4%
  212. [libx264 @ 0000020f91f21300] kb/s:906.85
  213. [aac @ 0000020f91db0840] Qavg: 662.428
  214. The syntax of the command is incorrect.
  215. D:\Projects\engshell engshell>File_saved_as_C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_trimmed.mp4
  216.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement