Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Reading codec info in some video files (Read 5451 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Reading codec info in some video files

Reply #25
It somehow looks feasible, but I don't know how to achieve this on my own. I need someone willing to walk me through it.
Besides, this (replacing all "!.tags" with "[filename].tags) doesn't solve my initial question.
We'll still need to extract the width & height info from all the videos and inject it into the .tags files.

Re: Reading codec info in some video files

Reply #26
Can you add your !.tags files to fb2k's playlist in the same order as video files?

Re: Reading codec info in some video files

Reply #27
I could do any sorting allowed by foobar, e.g. %path_sort%
The problem is that there are less !.tags than video files, because some !.tags files have info for several files.
Example : I have about 800 videos + 2500 featurettes (additional videos).
That means 800 individual folders, and most of those individual folders have a "Featurettes" subfolder, containing one to dozens of additional videos, all handled by one single !.tags file.
The number of !.tags files would be between 1200 to 1600, for a total of 3300 videos. You get the idea.

Re: Reading codec info in some video files

Reply #28
Ok, here is my second attempt to offer brutal solution :D
1) Enter
Code: [Select]
chcp
in windows command line. Remember digital value from it. (for example, in my case this is 866)
2) Add all video files to fb2k' s playlist.
Select all, use foo_texttools to copy text with command
Code: [Select]
"D:\0__CODECS\FFmpeg\ffprobe.exe" -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "%path%" >"c:\resolutions\%list_index%.txt"
(use your path to ffprobe.exe)
3) Create somewhere empty txt file with any name.
Open it with Notepad++
Set code page to the same you got with chcp command (in my case this is Encoding->Character set->Cyrillic->OEM 866).
Then paste results from foo_texttols, save, close.
Change extension from txt to bat.
4) Create folder "resolutions" on disk C.
5) Run bat file you got in paragraph 3.
It will create many txt files in folder resolutions.
6) In this folder create bat file with command
Code: [Select]
copy /b "*.txt" out.txt
and run it. File out.txt will be created in the same folder.
6) Open out.txt, remove last ampty line, select all, copy.
7) Add all your !.tags files to fb2k's playlist and do sorting to the same order as video files.
Select all, go to Properties->Tools->Automatically fill values (Source: Clipboard: line per track, Pattern %width%x%height%)

(If all paths to video files contain only ASCII characters, you can skip changing code page in Notepad++)

Re: Reading codec info in some video files

Reply #29
Thanks Rollin, that looks great, but have you read that I have much more video files than !.tags files ?
AFAIK your solution would only work with exactly the same number of video files and !.tags files, right ?

Re: Reading codec info in some video files

Reply #30
If you add !.tags file (that contain tags for several video files) to playlist, it will be displayed as several tracks, right? So amount of tracks in playlist will be the same as amount of tracks for video files.

Re: Reading codec info in some video files

Reply #31
That's true !
So I probably need to use %path_sort% to make sure that both playlists have exactly the same order.

Re: Reading codec info in some video files

Reply #32
OK, I think I can do this.
I have managed to create 2 huge playlists sorted identically : real video files (3505 items), and !.tags files (3505 items).
I have sorted them identically, then I have checked them both thoroughly. They seem identically sorted, so I am ready to work with them.

There's just this part that of your post that I don't understand : "use foo_texttools to copy text with command"
In foo_texttools dropdown menu I have "Copy Title" / "Copy Artist Name" / "Copy File Name" / "Copy File Size" / "Customize" and "Advanced".
So what should I do ? Thanks.

 

Re: Reading codec info in some video files

Reply #33
go to File-Preferences-Tools-Text tools and create new command
this new command will become available in dropdown menu

Re: Reading codec info in some video files

Reply #34
OK, so your method works :) There is just one small problem that needs to be fixed before I can launch the big operation.

About 7 files out of the 3505 generate problems (I hope I haven't missed anything) :
- 676 : "Invalid TIFF header as EXIF data" => 676.txt is still OK, I have checked
- 1416 : "SEI type 5 size 5544 truncated at 5531" => 1416.txt is still OK
- 2159 : "Invalid frame dimensions 0x0" => 2159.txt has 3 lines : 1280x720, then an empty line, then again 1280x720
- 2383 : "Invalid frame dimensions 0x0" => 2383.txt has 3 lines : 1280x720, then an empty line, then again 1280x720
- 3379 : "Invalid frame dimensions 0x0" => 3379.txt has 3 lines : 1920x1080, then an empty line, then again 1920x1080
- 3388 : "Invalid frame dimensions 0x0" => 3388.txt has 3 lines : 1920x1080, then an empty line, then again 1920x1080
- 3416 : "No frame!" => 3416.txt is still OK

So maybe in your code, we should check if the error is "Invalid frame dimensions 0x0", and make sure the resulting .txt file still has only one line, not three.
Because the "out.txt" file needs to have exactly 3505 lines, no more, no less.
Could you help me with that please ?

Re: Reading codec info in some video files

Reply #35
EDIT - Nevermind, I corrected the mistakes one by one (there were 4 more mistakes in lines 17, 484, 3389, 3401), until the "out.txt" file was exactly 3505 lines.
Then I did the rest of the procedure and it all worked out beautifully. Thank you ! :)
Now I have to check thoroughly that there are no mistakes in the newly created %width% and %height% tags. Fingers crossed !

Re: Reading codec info in some video files

Reply #36
Can you test if using -v panic instead of -v error in command will change results on problematic files?

Re: Reading codec info in some video files

Reply #37
I've just tried. Actually it's worse, because it doesn't signal any errors in red in the batch window, but the resulting .txt files still have the errors within them.

Re: Reading codec info in some video files

Reply #38
@Rollin , actually there's something that would help me with the previous script.
Could you add a line that says that in case of ANY kind of error, big or small, ANY unexpected behaviour, etc., the script will simply pause and wait for a key to continue ? That would really save me.
(please look up 4 posts for several examples of errors)

Re: Reading codec info in some video files

Reply #39
Nevermind, I managed otherwise. Thanks anyway. :)

Re: Reading codec info in some video files

Reply #40
Hello.How to determine the video codec in the video file being played? I do so, but it doesn't work.
Code: [Select]
if (metadb && metadb.Path.indexOf('codec_video') >= 0) { //??????
            gr.DrawImage(видеофайл, half_width-175, 1, 175, 174, 0, 0, видеофайл.Width, видеофайл.Height, 0, 100);
} else {
            gr.DrawImage(аудиофайл, half_width-175, 1, 175, 174, 0, 0, аудиофайл.Width, аудиофайл.Height, 0, 100);
}
YouTube Music

Re: Reading codec info in some video files

Reply #41
For title formatting it is $info(video_codec).

Re: Reading codec info in some video files

Reply #42
Rollin,I am not interested in the codec itself, but in the method of determining its presence in the played file:
Code: [Select]
if (????('$info(video_codec)') >= 0) {};
YouTube Music

Re: Reading codec info in some video files

Reply #43
Clearly not the right thread for javascript nonsense but here you go...

Code: [Select]
var f = metadb ? metadb.GetFileInfo() : null;
if (f && f.InfoFind("video_codec") > -1) {
 // yay
} else {
// boo
}

Re: Reading codec info in some video files

Reply #44
marc2k3,Thank you.
YouTube Music