Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (base) (venv) PS D:\Projects\engshell> python engshell.py --debug --showcode
- D:\Projects\engshell engshell>У меня есть файл C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4, с помощью ffmpeg (C:\Users\u
- ser\Desktop\test\ffmpeg.exe) я хочу сжать его в 2 раза, затем обрезать первые и последние 10 секунд и сохранить измененный файл c нижними
- прочерками вместо пробелов.
- D:\Projects\engshell engshell>compiling...
- import os
- import subprocess
- # Set the path to the input file
- input_file = r"C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4"
- # Set the path to the ffmpeg executable
- ffmpeg_path = r"C:\Users\user\Desktop\test\ffmpeg.exe"
- # Set the output file name
- output_file = os.path.join(os.path.dirname(input_file), os.path.basename(input_file).replace(" ", "_"))
- # Set the command to compress the video to half its size
- compress_command = f'"{ffmpeg_path}" -i "{input_file}" -vf "scale=iw/2:ih/2" -c:a copy "{output_file}_compressed.mp4"'
- # Set the command to trim the video
- trim_command = f'"{ffmpeg_path}" -i "{output_file}_compressed.mp4" -ss 00:00:10 -t 00:00:10 -async 1 "{output_file}_trimmed.mp4"'
- # Set the command to replace spaces with underscores in the output file name
- rename_command = f'rename "{output_file}_trimmed.mp4" "{output_file}_trimmed.mp4".replace(" ", "_")'
- # Run the commands
- subprocess.run(compress_command, shell=True)
- subprocess.run(trim_command, shell=True)
- subprocess.run(rename_command, shell=True)
- # Print the final result
- print(f"File saved as {output_file}_trimmed.mp4".replace(" ", "_"))
- D:\Projects\engshell engshell>running...
- ffmpeg version 2023-01-04-git-4a80db5fc2-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
- built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
- configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-ic
- onv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable
- -libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-
- libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --e
- nable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafound
- ation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf -
- -enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable
- -dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-
- libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --
- enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis -
- -enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
- libavutil 57. 43.100 / 57. 43.100
- libavcodec 59. 56.100 / 59. 56.100
- libavformat 59. 34.102 / 59. 34.102
- libavdevice 59. 8.101 / 59. 8.101
- libavfilter 8. 53.100 / 8. 53.100
- libswscale 6. 8.112 / 6. 8.112
- libswresample 4. 9.100 / 4. 9.100
- libpostproc 56. 7.100 / 56. 7.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\user\Desktop\test\Linkin Park — More the Victim.mp4':
- Metadata:
- major_brand : mp42
- minor_version : 0
- compatible_brands: mp42mp41
- creation_time : 2023-04-07T15:56:59.000000Z
- Duration: 00:02:42.16, start: 0.000000, bitrate: 619 kb/s
- 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
- 3.98 tbr, 24k tbn (default)
- Metadata:
- creation_time : 2023-04-07T15:56:59.000000Z
- handler_name : ?Mainconcept Video Media Handler
- vendor_id : [0][0][0][0]
- encoder : HEVC Coding
- Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
- Metadata:
- creation_time : 2023-04-07T15:56:59.000000Z
- handler_name : #Mainconcept MP4 Sound Media Handler
- vendor_id : [0][0][0][0]
- Stream mapping:
- Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
- Stream #0:1 -> #0:1 (copy)
- Press [q] to stop, [?] for help
- [libx264 @ 000001a505f408c0] using SAR=1/1
- [libx264 @ 000001a505f408c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
- [libx264 @ 000001a505f408c0] profile High, level 3.1, 4:2:0, 8-bit
- [libx264 @ 000001a505f408c0] 264 - core 164 r3103 941cae6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.ht
- 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
- 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
- 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
- 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
- =1:1.00
- Output #0, mp4, to 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_compressed.mp4':
- Metadata:
- major_brand : mp42
- minor_version : 0
- compatible_brands: mp42mp41
- encoder : Lavf59.34.102
- 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
- tbn (default)
- Metadata:
- creation_time : 2023-04-07T15:56:59.000000Z
- handler_name : ?Mainconcept Video Media Handler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.56.100 libx264
- Side data:
- cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
- Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
- Metadata:
- creation_time : 2023-04-07T15:56:59.000000Z
- handler_name : #Mainconcept MP4 Sound Media Handler
- vendor_id : [0][0][0][0]
- frame= 3888 fps=426 q=-1.0 Lsize= 23395kB time=00:02:42.15 bitrate=1181.9kbits/s speed=17.8x
- video:17002kB audio:6282kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.473040%
- [libx264 @ 000001a505f408c0] frame I:49 Avg QP:14.42 size: 10264
- [libx264 @ 000001a505f408c0] frame P:1183 Avg QP:21.15 size: 6804
- [libx264 @ 000001a505f408c0] frame B:2656 Avg QP:25.00 size: 3335
- [libx264 @ 000001a505f408c0] consecutive B-frames: 4.0% 11.5% 9.6% 74.9%
- [libx264 @ 000001a505f408c0] mb I I16..4: 25.1% 65.6% 9.3%
- [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%
- [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:
- 5.3%
- [libx264 @ 000001a505f408c0] 8x8 transform intra:71.0% inter:72.9%
- [libx264 @ 000001a505f408c0] coded y,uvDC,uvAC intra: 45.0% 45.5% 7.9% inter: 5.8% 6.5% 0.1%
- [libx264 @ 000001a505f408c0] i16 v,h,dc,p: 28% 27% 17% 29%
- [libx264 @ 000001a505f408c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 21% 18% 7% 4% 4% 5% 5% 7%
- [libx264 @ 000001a505f408c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 23% 17% 7% 7% 5% 7% 4% 5%
- [libx264 @ 000001a505f408c0] i8c dc,h,v,p: 52% 23% 18% 6%
- [libx264 @ 000001a505f408c0] Weighted P-Frames: Y:1.4% UV:1.2%
- [libx264 @ 000001a505f408c0] ref P L0: 64.1% 8.6% 18.9% 8.4% 0.1%
- [libx264 @ 000001a505f408c0] ref B L0: 83.4% 13.4% 3.2%
- [libx264 @ 000001a505f408c0] ref B L1: 96.0% 4.0%
- [libx264 @ 000001a505f408c0] kb/s:858.86
- ffmpeg version 2023-01-04-git-4a80db5fc2-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
- built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
- configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-ic
- onv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable
- -libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-
- libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --e
- nable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafound
- ation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf -
- -enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable
- -dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-
- libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --
- enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis -
- -enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
- libavutil 57. 43.100 / 57. 43.100
- libavcodec 59. 56.100 / 59. 56.100
- libavformat 59. 34.102 / 59. 34.102
- libavdevice 59. 8.101 / 59. 8.101
- libavfilter 8. 53.100 / 8. 53.100
- libswscale 6. 8.112 / 6. 8.112
- libswresample 4. 9.100 / 4. 9.100
- libpostproc 56. 7.100 / 56. 7.100
- Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_compressed.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf59.34.102
- Duration: 00:02:42.16, start: 0.000000, bitrate: 1181 kb/s
- 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
- 3.98 fps, 23.98 tbr, 24k tbn (default)
- Metadata:
- handler_name : ?Mainconcept Video Media Handler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.56.100 libx264
- Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
- Metadata:
- handler_name : #Mainconcept MP4 Sound Media Handler
- vendor_id : [0][0][0][0]
- Stream mapping:
- Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
- Stream #0:1 -> #0:1 (aac (native) -> aac (native))
- Press [q] to stop, [?] for help
- [libx264 @ 0000020f91f21300] using SAR=1/1
- [libx264 @ 0000020f91f21300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
- [libx264 @ 0000020f91f21300] profile High, level 3.1, 4:2:0, 8-bit
- [libx264 @ 0000020f91f21300] 264 - core 164 r3103 941cae6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.ht
- 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
- 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
- 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
- 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
- =1:1.00
- Output #0, mp4, to 'C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_trimmed.mp4':
- Metadata:
- major_brand : isom
- minor_version : 512
- compatible_brands: isomiso2avc1mp41
- encoder : Lavf59.34.102
- 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
- tbn (default)
- Metadata:
- handler_name : ?Mainconcept Video Media Handler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.56.100 libx264
- Side data:
- cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
- Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
- Metadata:
- handler_name : #Mainconcept MP4 Sound Media Handler
- vendor_id : [0][0][0][0]
- encoder : Lavc59.56.100 aac
- frame= 240 fps=0.0 q=-1.0 Lsize= 1277kB time=00:00:09.98 bitrate=1048.0kbits/s speed= 11x
- video:1109kB audio:160kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.649413%
- [libx264 @ 0000020f91f21300] frame I:4 Avg QP:15.88 size: 9106
- [libx264 @ 0000020f91f21300] frame P:66 Avg QP:21.15 size: 6550
- [libx264 @ 0000020f91f21300] frame B:170 Avg QP:24.90 size: 3917
- [libx264 @ 0000020f91f21300] consecutive B-frames: 2.1% 9.2% 3.8% 85.0%
- [libx264 @ 0000020f91f21300] mb I I16..4: 13.5% 79.5% 6.9%
- [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%
- [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:
- 5.0%
- [libx264 @ 0000020f91f21300] 8x8 transform intra:75.2% inter:78.4%
- [libx264 @ 0000020f91f21300] coded y,uvDC,uvAC intra: 44.9% 49.0% 7.9% inter: 6.2% 8.0% 0.1%
- [libx264 @ 0000020f91f21300] i16 v,h,dc,p: 26% 28% 17% 29%
- [libx264 @ 0000020f91f21300] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 18% 7% 4% 4% 6% 5% 7%
- [libx264 @ 0000020f91f21300] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 23% 18% 7% 7% 5% 7% 4% 5%
- [libx264 @ 0000020f91f21300] i8c dc,h,v,p: 51% 24% 18% 7%
- [libx264 @ 0000020f91f21300] Weighted P-Frames: Y:0.0% UV:0.0%
- [libx264 @ 0000020f91f21300] ref P L0: 62.2% 6.9% 21.6% 9.3%
- [libx264 @ 0000020f91f21300] ref B L0: 81.5% 15.2% 3.3%
- [libx264 @ 0000020f91f21300] ref B L1: 94.6% 5.4%
- [libx264 @ 0000020f91f21300] kb/s:906.85
- [aac @ 0000020f91db0840] Qavg: 662.428
- The syntax of the command is incorrect.
- D:\Projects\engshell engshell>File_saved_as_C:\Users\user\Desktop\test\Linkin_Park_—_More_the_Victim.mp4_trimmed.mp4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement