I have a qcow2 image which I have converted to raw format, and then mount to my file system:
# qemu-img convert -O raw initial-image.qcow2 raw-image.img
# kpartx -av raw-image.img
add map loop0p1 (253:1): 0 41940992 linear /dev/loop0 2048
# mount /dev/mapper/loop0p1 ~/myImage
# ls ~/myImage
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
The size of ~/myImage mountpoint is checked with du command as follows:
# du -hx --max-depth=1 ~/myImage/
0 /root/myImage/dev
0 /root/myImage/proc
0 /root/myImage/run
0 /root/myImage/sys
36M /root/myImage/etc
40K /root/myImage/root
53M /root/myImage/var
12K /root/myImage/tmp
834M /root/myImage/usr
89M /root/myImage/boot
0 /root/myImage/home
0 /root/myImage/media
0 /root/myImage/mnt
0 /root/myImage/opt
0 /root/myImage/srv
1012M /root/myImage/
At this point I copied the contents of ~/myImage and pasted them inside ~/myImage-copy directory. Then I checked the size of the newly created directory. I expected the exact same size for each directory between ~/myImage and ~/myImage-copy, but it's not:
# cp -R myImage/ ~/myImage-copy
# du -hx --max-depth=1 ~/myImage-copy/
0 /root/myImage-copy/dev
0 /root/myImage-copy/proc
0 /root/myImage-copy/run
0 /root/myImage-copy/sys
36M /root/myImage-copy/etc
40K /root/myImage-copy/root
63M /root/myImage-copy/var
12K /root/myImage-copy/tmp
862M /root/myImage-copy/usr
89M /root/myImage-copy/boot
0 /root/myImage-copy/home
0 /root/myImage-copy/media
0 /root/myImage-copy/mnt
0 /root/myImage-copy/opt
0 /root/myImage-copy/srv
1.1G /root/myImage-copy/
From the paths above with different size, I chose /usr and I followed a branch of it until I conclude to an innermost directory which has different size, in order to inspect its files. Below is shown the size difference of an innermost directory:
# du -hx --max-depth=1 ~/myImage/usr/lib64/python2.7/json/
112K /root/myImage/usr/lib64/python2.7/json/
# du -hx --max-depth=1 ~/myImage-copy/usr/lib64/python2.7/json/
164K /root/myImage-copy/usr/lib64/python2.7/json/
However, by inspecting their file content, I can't see any difference related to their size. I don't know if the second column plays a role:
# ls -lah ~/myImage/usr/lib64/python2.7/json/
total 200K
drwxr-xr-x. 2 root root 280 Feb 3 11:17 .
drwxr-xr-x. 26 root root 20K Feb 3 11:17 ..
-rw-r--r--. 1 root root 14K Aug 13 2020 decoder.py
-rw-r--r--. 2 root root 12K Aug 13 2020 decoder.pyc
-rw-r--r--. 2 root root 12K Aug 13 2020 decoder.pyo
-rw-r--r--. 1 root root 17K Aug 13 2020 encoder.py
-rw-r--r--. 2 root root 14K Aug 13 2020 encoder.pyc
-rw-r--r--. 2 root root 14K Aug 13 2020 encoder.pyo
-rw-r--r--. 1 root root 15K Aug 13 2020 __init__.py
-rw-r--r--. 2 root root 14K Aug 13 2020 __init__.pyc
-rw-r--r--. 2 root root 14K Aug 13 2020 __init__.pyo
-rw-r--r--. 1 root root 2.3K Aug 13 2020 scanner.py
-rw-r--r--. 2 root root 2.2K Aug 13 2020 scanner.pyc
-rw-r--r--. 2 root root 2.2K Aug 13 2020 scanner.pyo
-rw-r--r--. 1 root root 997 Aug 13 2020 tool.py
-rw-r--r--. 2 root root 1.3K Aug 13 2020 tool.pyc
-rw-r--r--. 2 root root 1.3K Aug 13 2020 tool.pyo
# ls -lah ~/myImage-copy/usr/lib64/python2.7/json/
total 200K
drwxr-xr-x 2 root root 280 Mar 4 17:55 .
drwxr-xr-x 26 root root 20K Mar 4 17:55 ..
-rw-r--r-- 1 root root 14K Mar 4 17:55 decoder.py
-rw-r--r-- 1 root root 12K Mar 4 17:55 decoder.pyc
-rw-r--r-- 1 root root 12K Mar 4 17:55 decoder.pyo
-rw-r--r-- 1 root root 17K Mar 4 17:55 encoder.py
-rw-r--r-- 1 root root 14K Mar 4 17:55 encoder.pyc
-rw-r--r-- 1 root root 14K Mar 4 17:55 encoder.pyo
-rw-r--r-- 1 root root 15K Mar 4 17:55 __init__.py
-rw-r--r-- 1 root root 14K Mar 4 17:55 __init__.pyc
-rw-r--r-- 1 root root 14K Mar 4 17:55 __init__.pyo
-rw-r--r-- 1 root root 2.3K Mar 4 17:55 scanner.py
-rw-r--r-- 1 root root 2.2K Mar 4 17:55 scanner.pyc
-rw-r--r-- 1 root root 2.2K Mar 4 17:55 scanner.pyo
-rw-r--r-- 1 root root 997 Mar 4 17:55 tool.py
-rw-r--r-- 1 root root 1.3K Mar 4 17:55 tool.pyc
-rw-r--r-- 1 root root 1.3K Mar 4 17:55 tool.pyo
In addition, I checked the md5 hash of the files above as a view of their content. It seems there is no content differences between the same files:
# md5sum ~/myImage/usr/lib64/python2.7/json/*
598c681c82c582ca3f17950b4d5413c1 /root/myImage/usr/lib64/python2.7/json/decoder.py
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage/usr/lib64/python2.7/json/decoder.pyc
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage/usr/lib64/python2.7/json/decoder.pyo
007a9954ca6641b29564a0f0cb55096b /root/myImage/usr/lib64/python2.7/json/encoder.py
366d44efbfce1e5b4a3397b15f202765 /root/myImage/usr/lib64/python2.7/json/encoder.pyc
366d44efbfce1e5b4a3397b15f202765 /root/myImage/usr/lib64/python2.7/json/encoder.pyo
dd5db0c7fb7c531be4e14feebbdb52e8 /root/myImage/usr/lib64/python2.7/json/__init__.py
791c8dca2a86ce50ead04e918a17b508 /root/myImage/usr/lib64/python2.7/json/__init__.pyc
791c8dca2a86ce50ead04e918a17b508 /root/myImage/usr/lib64/python2.7/json/__init__.pyo
8d6660f10863f99ffdd9a95eeddd7b64 /root/myImage/usr/lib64/python2.7/json/scanner.py
59865f486b742aea959693c04cfce057 /root/myImage/usr/lib64/python2.7/json/scanner.pyc
59865f486b742aea959693c04cfce057 /root/myImage/usr/lib64/python2.7/json/scanner.pyo
ad879e2ba247d3d4a5cc71fe22db91d0 /root/myImage/usr/lib64/python2.7/json/tool.py
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage/usr/lib64/python2.7/json/tool.pyc
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage/usr/lib64/python2.7/json/tool.pyo
# md5sum ~/myImage-copy/usr/lib64/python2.7/json/*
598c681c82c582ca3f17950b4d5413c1 /root/myImage-copy/usr/lib64/python2.7/json/decoder.py
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage-copy/usr/lib64/python2.7/json/decoder.pyc
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage-copy/usr/lib64/python2.7/json/decoder.pyo
007a9954ca6641b29564a0f0cb55096b /root/myImage-copy/usr/lib64/python2.7/json/encoder.py
366d44efbfce1e5b4a3397b15f202765 /root/myImage-copy/usr/lib64/python2.7/json/encoder.pyc
366d44efbfce1e5b4a3397b15f202765 /root/myImage-copy/usr/lib64/python2.7/json/encoder.pyo
dd5db0c7fb7c531be4e14feebbdb52e8 /root/myImage-copy/usr/lib64/python2.7/json/__init__.py
791c8dca2a86ce50ead04e918a17b508 /root/myImage-copy/usr/lib64/python2.7/json/__init__.pyc
791c8dca2a86ce50ead04e918a17b508 /root/myImage-copy/usr/lib64/python2.7/json/__init__.pyo
8d6660f10863f99ffdd9a95eeddd7b64 /root/myImage-copy/usr/lib64/python2.7/json/scanner.py
59865f486b742aea959693c04cfce057 /root/myImage-copy/usr/lib64/python2.7/json/scanner.pyc
59865f486b742aea959693c04cfce057 /root/myImage-copy/usr/lib64/python2.7/json/scanner.pyo
ad879e2ba247d3d4a5cc71fe22db91d0 /root/myImage-copy/usr/lib64/python2.7/json/tool.py
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage-copy/usr/lib64/python2.7/json/tool.pyc
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage-copy/usr/lib64/python2.7/json/tool.pyo
So, what is the reason behind the size difference of the same content in du output?
My operating system is CentOS Linux release 7.9.2009.
I want to convert png to gif and i want to mention which are the frames i want to combine
eg: frame1.png and frame2.png.
I've tried using ffmpeg -i frames/%03d.png -vf fps=20 logo.gif but it is considering all the images in that directory, but i want only two images in that directory to be included in the gif i want to create. Thank you in advance.
Just use the ones you want:
magick -delay 80 nice1.png nice37.png animated.gif
By way of explanation and further example, I can make a red and a blue frame and morph between the two in 14 steps like this - making a total of 16 frames:
magick -size 20x100 xc:red xc:blue -morph 14 frame-%02d.png
If I append those frames side-by-side, you can see them all:
magick frame* +append side-by-side.png
And I can list them in the shell:
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-00.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-01.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-02.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-03.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-04.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-05.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-06.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-07.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-08.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-09.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-10.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-11.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-12.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-13.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-14.png
-rw-r--r-- 1 mark staff 278 28 Apr 13:45 frame-15.png
If I now want to select some to make an animated GIF, I can use the shell's "brace expansion" to select certain ones:
ls frame-0{2,3,9}.png
frame-02.png frame-03.png frame-09.png
Or the shell's "range expansion" to select a contiguous range:
ls frame-1[2-4].png
frame-12.png frame-13.png frame-14.png
Or the shell's "wildcard expansion":
ls frame-1?.png
frame-10.png frame-11.png frame-12.png frame-13.png frame-14.png frame-15.png
And that works with magick just the same as ls, so I can select a few frames for an animated GIF like this:
magick -delay 80 frame-0{2,4}.png frame-1*.png animated.gif
I am trying to split a video file into segments that are less than 10KB (ideally 5KB) using FFmpeg.
The video I am using is this one: https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4. It already has a low resolution.
I have tried specifying a very small -segment_time of 00:00:0.04:
ffmpeg -i BigBuckBunny_320x180.mp4 -c copy -map 0 -f segment -segment_time 00:00:0.04 BigBuckBunny_320x180_%03d.mp4
I have tried specifying sequential -segment_frames e.g. 1,2,3,4,5,6,7... etc.:
ffmpeg -i BigBuckBunny_320x180.mp4 -c copy -map 0 -f segment -segment_frames 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 -segment_list out.csv BigBuckBunny_320x180_%03d.mp4
I have also tried to force key frames:
ffmpeg -i BigBuckBunny_320x180.mp4 -force_key_frames "expr:gte(t,n_forced*0.04)" -c copy -map 0 -f segment -segment_frames 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 BigBuckBunny_320x180_%03d.mp4
All of these result in segments 0.5s long with varying file sizes averaging about 50KB.
username#My-Air:~/dev/video$ less out.csv
BigBuckBunny_320x180_000.mp4,0.000000,0.500000
BigBuckBunny_320x180_001.mp4,0.500000,1.000000
BigBuckBunny_320x180_002.mp4,1.000000,1.500000
BigBuckBunny_320x180_003.mp4,1.500000,2.000000
BigBuckBunny_320x180_004.mp4,2.000000,2.500000
BigBuckBunny_320x180_005.mp4,2.500000,3.000000
...
username#My-Air:~/dev/video/bunny_0.5s_splits$ ls -l
total 134552
-rw-r--r-- 1 username staff 16K 25 Mar 23:40 BigBuckBunny_320x180_000.mp4
-rw-r--r-- 1 username staff 26K 25 Mar 23:40 BigBuckBunny_320x180_001.mp4
-rw-r--r-- 1 username staff 36K 25 Mar 23:40 BigBuckBunny_320x180_002.mp4
-rw-r--r-- 1 username staff 44K 25 Mar 23:40 BigBuckBunny_320x180_003.mp4
-rw-r--r-- 1 username staff 40K 25 Mar 23:40 BigBuckBunny_320x180_004.mp4
-rw-r--r-- 1 username staff 38K 25 Mar 23:40 BigBuckBunny_320x180_005.mp4
-rw-r--r-- 1 username staff 43K 25 Mar 23:40 BigBuckBunny_320x180_006.mp4
-rw-r--r-- 1 username staff 44K 25 Mar 23:40 BigBuckBunny_320x180_007.mp4
-rw-r--r-- 1 username staff 50K 25 Mar 23:40 BigBuckBunny_320x180_008.mp4
-rw-r--r-- 1 username staff 49K 25 Mar 23:40 BigBuckBunny_320x180_009.mp4
-rw-r--r-- 1 username staff 50K 25 Mar 23:40 BigBuckBunny_320x180_010.mp4
-rw-r--r-- 1 username staff 51K 25 Mar 23:40 BigBuckBunny_320x180_011.mp4
-rw-r--r-- 1 username staff 51K 25 Mar 23:40 BigBuckBunny_320x180_012.mp4
-rw-r--r-- 1 username staff 57K 25 Mar 23:40 BigBuckBunny_320x180_013.mp4
-rw-r--r-- 1 username staff 53K 25 Mar 23:40 BigBuckBunny_320x180_014.mp4
-rw-r--r-- 1 username staff 57K 25 Mar 23:40 BigBuckBunny_320x180_015.mp4
-rw-r--r-- 1 username staff 57K 25 Mar 23:40 BigBuckBunny_320x180_016.mp4
-rw-r--r-- 1 username staff 61K 25 Mar 23:40 BigBuckBunny_320x180_017.mp4
...
It's strange that the timestamps are at exactly 0s and 0.5s. Is this limitation of FFmpeg? I couldn't find any documentation to verify this.
Is there any way to get these file sizes down to 5KB? Is it possible with FFmpeg? If not, is there another tool I could use? I looked at GStreamer but couldn't really see if it was possible and it seems very complicated.
Any help appreciated. Thanks.
OK I finally got what I wanted. I now have video segments all under 10KB averaging about 5KB. I used the following commands:
Compressed the original video file using ffmpeg's standard compression:
ffmpeg BigBuckBunny_320x180.mp4 BigBuckBunny_320x180_compressed.mp4
Set keyframe interval to 1 so every frame became a keyframe:
ffmpeg -i BigBuckBunny_320x180_compressed.mp4 -vcodec libx264 -x264-params keyint=1:scenecut=0 -acodec copy BigBuckBunny_320x180_compressed_frames.mp4
Split the resulting file into segments of length 0.04 which is about the length of one frame:
ffmpeg -i BigBuckBunny_320x180_compressed_frames.mp4 -c copy -map 0 -segment_time 00:00:0.04 -f segment -reset_timestamps 1 BigBuckBunny_320x180_compre
ssed_frames%03d.mp4
I resolved the previous issue where only the first segment was playing properly using: -reset_timestamps 1.
I get the below error message when I try to rsync from a local hard disk to a USB disk mounted at E: on Windows 10.
rsync: failed to set times on "/cygdrive/e/.": Invalid argument (22)
My rsync command is as below (path shortened for brevity):
rsync -rtv --delete --progress --modify-window=5 /cygdrive/d/path/to/folder/ /cygdrive/e/
I actually need to set modification times (on directories as well) and rsync actually sets modification times perfectly. It only fails to set times on root of the USB disk.
I experienced exactly the same problem.
I created a dir containing one text file and when trying to rsync it to an removable (USB) drive, I got the error. However, the file was copied to the destination. The problem is not reproducible if the destination is a folder (other than root) on the removable drive
I then repeated the process using a fixed drive as destination, and the problem was not reproducible
The 1st difference that popped up between the 2 drives, was the file system (for more details, check [MS.Docs]: File Systems Technologies):
FAT32 - on the removable drive
NTFS - on the fixed one
So this was the cause of my failure. Formatting the USB drive as NTFS fixed the problem:
The USB drive formatted as FAT32 (default):
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ ll /cygdrive/
total 20
dr-xr-xr-x 1 cfati None 0 Jul 14 17:58 .
drwxrwx---+ 1 cfati None 0 Jun 9 15:04 ..
d---r-x---+ 1 NT SERVICE+TrustedInstaller NT SERVICE+TrustedInstaller 0 Jul 13 22:21 c
drwxrwx---+ 1 SYSTEM SYSTEM 0 Jul 14 13:19 e
drwxr-xr-x 1 cfati None 0 Dec 31 1979 n
drwxr-xr-x 1 cfati None 0 Dec 31 1979 w
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ rsync -rtv --progress --modify-window=5 ./dir/ /cygdrive/w
sending incremental file list
rsync: failed to set times on "/cygdrive/w/.": Invalid argument (22)
./
a.txt
3 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/2)
sent 111 bytes received 111 bytes 444.00 bytes/sec
total size is 3 speedup is 0.01
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ ll /cygdrive/
total 20
dr-xr-xr-x 1 cfati None 0 Jul 14 17:58 .
drwxrwx---+ 1 cfati None 0 Jun 9 15:04 ..
d---r-x---+ 1 NT SERVICE+TrustedInstaller NT SERVICE+TrustedInstaller 0 Jul 13 22:21 c
drwxrwx---+ 1 SYSTEM SYSTEM 0 Jul 14 13:19 e
drwxr-xr-x 1 cfati None 0 Dec 31 1979 n
drwxr-xr-x 1 cfati None 0 Dec 31 1979 w
After formatting the USB drive as NTFS:
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ ll /cygdrive/
total 24
dr-xr-xr-x 1 cfati None 0 Jul 14 17:59 .
drwxrwx---+ 1 cfati None 0 Jun 9 15:04 ..
d---r-x---+ 1 NT SERVICE+TrustedInstaller NT SERVICE+TrustedInstaller 0 Jul 13 22:21 c
drwxrwx---+ 1 SYSTEM SYSTEM 0 Jul 14 13:19 e
drwxr-xr-x 1 cfati None 0 Dec 31 1979 n
drwxrwxrwx+ 1 Administrators Administrators 0 Jul 14 17:59 w
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ rsync -rtv --progress --modify-window=5 ./dir/ /cygdrive/w
sending incremental file list
./
a.txt
3 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/2)
sent 111 bytes received 38 bytes 298.00 bytes/sec
total size is 3 speedup is 0.02
cfati#cfati-e5550-0 /cygdrive/e/Work/Dev/StackOverflow/q045006385
$ ll /cygdrive/
total 24
dr-xr-xr-x 1 cfati None 0 Jul 14 17:59 .
drwxrwx---+ 1 cfati None 0 Jun 9 15:04 ..
d---r-x---+ 1 NT SERVICE+TrustedInstaller NT SERVICE+TrustedInstaller 0 Jul 13 22:21 c
drwxrwx---+ 1 SYSTEM SYSTEM 0 Jul 14 13:19 e
drwxr-xr-x 1 cfati None 0 Dec 31 1979 n
drwxrwxrwx+ 1 Administrators Administrators 0 Jul 14 13:19 w
As a side note, when I was at step #2., I was an idiot and kept the --delete arg, so til I hit Ctrl + C, it deleted some data. Luckily, it didn't get to delete crucial files / folders.
I'm reading this post about go and was trying to compile the source code found here
I downloaded the source code, compiled the first file with make and I can see the object is generated:
$pwd
/Users/oscarryz/code/go/rsc/rosetta/graph
$ls -ltR
total 136
-rw-r--r-- 1 oscarryz staff 61295 Sep 17 16:20 _go_.6
drwxr-xr-x 3 oscarryz staff 102 Sep 17 16:20 _obj
-rw-r--r-- 1 oscarryz staff 126 Sep 17 16:17 Makefile
-rw-r--r-- 1 oscarryz staff 2791 Sep 17 16:17 graph.go
./_obj:
total 0
drwxr-xr-x 3 oscarryz staff 102 Sep 17 16:20 rsc.googlecode.com
./_obj/rsc.googlecode.com:
total 0
drwxr-xr-x 3 oscarryz staff 102 Sep 17 16:20 hg
./_obj/rsc.googlecode.com/hg:
total 0
drwxr-xr-x 3 oscarryz staff 102 Sep 17 16:20 rosetta
./_obj/rsc.googlecode.com/hg/rosetta:
total 136
-rw-r--r-- 1 oscarryz staff 68486 Sep 17 16:20 graph.a
No my question is, how do I refer to that compiled code from the maze directory:
/Users/oscarryz/code/go/rsc/rosetta/maze/maze.go
Whose import declarations are:
import (
"bytes"
"fmt"
"rand"
"time"
"rsc.googlecode.com/hg/rosetta/graph"
)
And right now is failing to compile with the error message:
6g -o _go_.6 maze.go
maze.go:20: can't find import: rsc.googlecode.com/hg/rosetta/graph
make: *** [_go_.6] Error 1
Ok, I found it, wasn't that hard.
6g flags: -I DIR search for packages in DIR
I have to specify the -I option like this:
6g -I ../graph/_obj/ -o _go_.6 maze.go