How to bulk extract bitrate data from videos and output them in a text file?
up vote
1
down vote
favorite
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file, or output list which I can copy and paste into a text file.
I have installed ffmpeg.
So, for example, the output of fffmpeg -i movie1.mkv is;
Metadata:
encoder : libebml v1.2.0 + libmatroska v1.1.0
creation_time : 2011-04-09T18:18:05.000000Z
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : movie1
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title : DTS-ES 5.1 @ 1509 Kbps
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Commentary
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
The "bitrate: 10698 kb/s" is the crucial part I am after here.
Lets pretend all three movies have the same bitrate.
I would like to extract the bitrate information from all three videos, and have them output as;
movie1.mkv 10698
movie2.mkv 10698
movie3.mkv 10698
How would I go about extracting and outputing this information in bulk?
I've been trying a combination of finding by file name, ffmpeg, and then | to grep. e.g ; find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | grep "bitrate:"
Current attempts;
1. The command; ffmpeg -i movie1.mkv 2>&1 | grep bitrate | sed 's/bitrate: (.*), kb/1/g'
Returns;
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
2. The command; find . -name "*.mkv" -exec ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "${~/Downloads/1%.mkv}" ';
'
Returns
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
I feel that I'm close here, and that there's just something wrong with the find and recalling the output of find into ffprobe.
ffmpeg grep cat mkv
add a comment |
up vote
1
down vote
favorite
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file, or output list which I can copy and paste into a text file.
I have installed ffmpeg.
So, for example, the output of fffmpeg -i movie1.mkv is;
Metadata:
encoder : libebml v1.2.0 + libmatroska v1.1.0
creation_time : 2011-04-09T18:18:05.000000Z
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : movie1
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title : DTS-ES 5.1 @ 1509 Kbps
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Commentary
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
The "bitrate: 10698 kb/s" is the crucial part I am after here.
Lets pretend all three movies have the same bitrate.
I would like to extract the bitrate information from all three videos, and have them output as;
movie1.mkv 10698
movie2.mkv 10698
movie3.mkv 10698
How would I go about extracting and outputing this information in bulk?
I've been trying a combination of finding by file name, ffmpeg, and then | to grep. e.g ; find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | grep "bitrate:"
Current attempts;
1. The command; ffmpeg -i movie1.mkv 2>&1 | grep bitrate | sed 's/bitrate: (.*), kb/1/g'
Returns;
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
2. The command; find . -name "*.mkv" -exec ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "${~/Downloads/1%.mkv}" ';
'
Returns
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
I feel that I'm close here, and that there's just something wrong with the find and recalling the output of find into ffprobe.
ffmpeg grep cat mkv
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file, or output list which I can copy and paste into a text file.
I have installed ffmpeg.
So, for example, the output of fffmpeg -i movie1.mkv is;
Metadata:
encoder : libebml v1.2.0 + libmatroska v1.1.0
creation_time : 2011-04-09T18:18:05.000000Z
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : movie1
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title : DTS-ES 5.1 @ 1509 Kbps
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Commentary
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
The "bitrate: 10698 kb/s" is the crucial part I am after here.
Lets pretend all three movies have the same bitrate.
I would like to extract the bitrate information from all three videos, and have them output as;
movie1.mkv 10698
movie2.mkv 10698
movie3.mkv 10698
How would I go about extracting and outputing this information in bulk?
I've been trying a combination of finding by file name, ffmpeg, and then | to grep. e.g ; find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | grep "bitrate:"
Current attempts;
1. The command; ffmpeg -i movie1.mkv 2>&1 | grep bitrate | sed 's/bitrate: (.*), kb/1/g'
Returns;
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
2. The command; find . -name "*.mkv" -exec ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "${~/Downloads/1%.mkv}" ';
'
Returns
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
I feel that I'm close here, and that there's just something wrong with the find and recalling the output of find into ffprobe.
ffmpeg grep cat mkv
I have several videos in a folder;
~/Downloads/movie1.mkv
~/Downloads/movie2.mkv
~/Downloads/movie3.mkv
I would like to extract the bitrate for each file, and output the data into a single text file, or output list which I can copy and paste into a text file.
I have installed ffmpeg.
So, for example, the output of fffmpeg -i movie1.mkv is;
Metadata:
encoder : libebml v1.2.0 + libmatroska v1.1.0
creation_time : 2011-04-09T18:18:05.000000Z
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
title : movie1
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
Metadata:
title : DTS-ES 5.1 @ 1509 Kbps
Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
title : Commentary
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
The "bitrate: 10698 kb/s" is the crucial part I am after here.
Lets pretend all three movies have the same bitrate.
I would like to extract the bitrate information from all three videos, and have them output as;
movie1.mkv 10698
movie2.mkv 10698
movie3.mkv 10698
How would I go about extracting and outputing this information in bulk?
I've been trying a combination of finding by file name, ffmpeg, and then | to grep. e.g ; find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | grep "bitrate:"
Current attempts;
1. The command; ffmpeg -i movie1.mkv 2>&1 | grep bitrate | sed 's/bitrate: (.*), kb/1/g'
Returns;
Duration: 00:04:27.71, start: 0.000000, bitrate: 10698 kb/s
2. The command; find . -name "*.mkv" -exec ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "${~/Downloads/1%.mkv}" ';
'
Returns
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
~/Downloads/1%.mkv: No such file or directory
I feel that I'm close here, and that there's just something wrong with the find and recalling the output of find into ffprobe.
ffmpeg grep cat mkv
ffmpeg grep cat mkv
edited Nov 13 at 12:28
asked Nov 13 at 10:05
Martin JS
153
153
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
To screen:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' "
To file result.txt:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
somefile1.mkv 1788 kb/s
somefile2.mkv 1681 kb/s
...
Formatted output example:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n 'Filename: {}, Bitrate is: ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
Filename: somefile1.mkv, Bitrate is: 1788 kb/s
Filename: somefile2.mkv, Bitrate is: 1681 kb/s
...
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?
– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
|
show 7 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
To screen:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' "
To file result.txt:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
somefile1.mkv 1788 kb/s
somefile2.mkv 1681 kb/s
...
Formatted output example:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n 'Filename: {}, Bitrate is: ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
Filename: somefile1.mkv, Bitrate is: 1788 kb/s
Filename: somefile2.mkv, Bitrate is: 1681 kb/s
...
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?
– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
|
show 7 more comments
up vote
1
down vote
accepted
To screen:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' "
To file result.txt:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
somefile1.mkv 1788 kb/s
somefile2.mkv 1681 kb/s
...
Formatted output example:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n 'Filename: {}, Bitrate is: ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
Filename: somefile1.mkv, Bitrate is: 1788 kb/s
Filename: somefile2.mkv, Bitrate is: 1681 kb/s
...
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?
– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
|
show 7 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
To screen:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' "
To file result.txt:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
somefile1.mkv 1788 kb/s
somefile2.mkv 1681 kb/s
...
Formatted output example:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n 'Filename: {}, Bitrate is: ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
Filename: somefile1.mkv, Bitrate is: 1788 kb/s
Filename: somefile2.mkv, Bitrate is: 1681 kb/s
...
To screen:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' "
To file result.txt:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n '{} ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
somefile1.mkv 1788 kb/s
somefile2.mkv 1681 kb/s
...
Formatted output example:
find . -name "*.mkv" -print0 | xargs -0 -i{} sh -c " echo -n 'Filename: {}, Bitrate is: ' && ffmpeg -i '{}' 2>&1 | sed -n -e 's/^.*bitrate: //p' " > result.txt
You will see in file result.txt:
Filename: somefile1.mkv, Bitrate is: 1788 kb/s
Filename: somefile2.mkv, Bitrate is: 1681 kb/s
...
edited Nov 13 at 13:38
answered Nov 13 at 10:49
S_Flash
886117
886117
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?
– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
|
show 7 more comments
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?
– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
I keep getting the "missing argument to `-exec " error
– Martin JS
Nov 13 at 11:56
Try:
find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?– S_Flash
Nov 13 at 12:01
Try:
find . -name "*.mkv" -exec ffmpeg -i "${1%.mkv}" | sed -n -e 's/^.*bitrate: //p'
What output you get?– S_Flash
Nov 13 at 12:01
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
Still getting the "missing argument to `-exec " error. I have found that : ffprobe -v error -show_entries format=bit_rate -of default=noprint_wrappers=1:nokey=1 "movie1.mkv" returns just the bit rate, so if somehow the output of find, and the use echo can be used with that, it might do the trick
– Martin JS
Nov 13 at 12:03
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I added the ';', and it returned with a "No such file or directory error three times, so I think there's an issue in the finding of the file name, and passing it to ffmpeg.
– Martin JS
Nov 13 at 12:39
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
I found errors and edited my answer with some new examples
– S_Flash
Nov 13 at 12:43
|
show 7 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1092499%2fhow-to-bulk-extract-bitrate-data-from-videos-and-output-them-in-a-text-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown