VideoHelp Forum

+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    I am downloading youtube streams containing US news nightly for viewing in daytime (CET).
    The videos are in 1 hour sections as mp4 files.
    This is all automated in scripts on my Ubuntu server using ffmpeg and youtube-dl.

    Now I am looking for a way to detect the presence of the news channel logo inside the video as start-end time pairs in seconds.
    I know where on the video screen it is located and also what the logo looks like.
    But I have searched unsuccessfully for a way to use ffmpeg or ffprobe to accomplish it.
    The closest I have come is in this thread on stackoverflow

    I have tested the command on one of my files like this:
    Code:
    ffprobe -f lavfi -i "movie=myvideo.mp4,blackdetect[out0]" -show_entries tags=lavfi.black_start,lavfi.black_end -of default=nw=1 -v quiet
    and it seems to detect the transitions into and out of commercials using the black detect, but it also detects such transitions within the commercial section and duplicates all output as shown in this small output section:
    Code:
    TAG:lavfi.black_start=55.533
    TAG:lavfi.black_start=55.533
    TAG:lavfi.black_end=57.833
    TAG:lavfi.black_end=57.833
    TAG:lavfi.black_start=778.467
    TAG:lavfi.black_start=778.467
    TAG:lavfi.black_end=779.067
    TAG:lavfi.black_end=779.067
    TAG:lavfi.black_start=839.033
    TAG:lavfi.black_start=839.033
    TAG:lavfi.black_end=839.067
    TAG:lavfi.black_end=839.067
    So this means I cannot use it to filter away the commercials.

    Instead I need a command that will look for the specific logo which is present when the video is not a commercial.
    Can this be done and if so how?
    Quote Quote  
  2. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by BosseB View Post
    I am downloading youtube streams containing US news nightly for viewing in daytime (CET).
    The videos are in 1 hour sections as mp4 files.
    This is all automated in scripts on my Ubuntu server using ffmpeg and youtube-dl.

    Now I am looking for a way to detect the presence of the news channel logo inside the video as start-end time pairs in seconds.
    I know where on the video screen it is located and also what the logo looks like.
    But I have searched unsuccessfully for a way to use ffmpeg or ffprobe to accomplish it.
    The closest I have come is in this thread on stackoverflow

    I have tested the command on one of my files like this:
    Code:
    ffprobe -f lavfi -i "movie=myvideo.mp4,blackdetect[out0]" -show_entries tags=lavfi.black_start,lavfi.black_end -of default=nw=1 -v quiet
    and it seems to detect the transitions into and out of commercials using the black detect, but it also detects such transitions within the commercial section and duplicates all output as shown in this small output section:
    Code:
    TAG:lavfi.black_start=55.533
    TAG:lavfi.black_start=55.533
    TAG:lavfi.black_end=57.833
    TAG:lavfi.black_end=57.833
    TAG:lavfi.black_start=778.467
    TAG:lavfi.black_start=778.467
    TAG:lavfi.black_end=779.067
    TAG:lavfi.black_end=779.067
    TAG:lavfi.black_start=839.033
    TAG:lavfi.black_start=839.033
    TAG:lavfi.black_end=839.067
    TAG:lavfi.black_end=839.067
    So this means I cannot use it to filter away the commercials.

    Instead I need a command that will look for the specific logo which is present when the video is not a commercial.
    Can this be done and if so how?
    see this thread - https://www.linuxquestions.org/questions/linux-software-2/ffmpeg-detect-on-screen-logo-4175687925/
    Quote Quote  
  3. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    I cannot see how that would help me make ffmpeg or ffprobe find the locations in the video file where the logo is present on screen...
    It seems like what you linked to is a way to extract the logo itself from an image or video, but that is not what I am after at all.

    What I need is the starting and ending time of all occurrences where the specific logo is on screen.

    The logo is always in a specific rectangle on the screen, so it can be defined as percentage of the w and h size of the video. (position x,y and size w,h)

    BTW:
    I have now noted that at least MSNBC has different colored logos in different parts of the video, they seem to change it now and then while the video plays...
    How can one handle that?

    I attach an example showing 3 variations of the MSNBC logo.
    Image Attached Images  
    Quote Quote  
  4. Member
    Join Date
    Feb 2006
    Location
    United States
    Search Comp PM
    Originally Posted by BosseB View Post
    I cannot see how that would help me make ffmpeg or ffprobe find the locations in the video file where the logo is present on screen...
    It seems like what you linked to is a way to extract the logo itself from an image or video, but that is not what I am after at all.

    What I need is the starting and ending time of all occurrences where the specific logo is on screen.

    The logo is always in a specific rectangle on the screen, so it can be defined as percentage of the w and h size of the video. (position x,y and size w,h)

    BTW:
    I have now noted that at least MSNBC has different colored logos in different parts of the video, they seem to change it now and then while the video plays...
    How can one handle that?

    I attach an example showing 3 variations of the MSNBC logo.
    did find this - https://answers.opencv.org/question/179798/video-processing-to-detect-a-logo-in-frames/
    not sure if this will help or not.
    Quote Quote  
  5. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    It is possible, although I'm not sure if its exactly what you want. Cut out a picture of your logo and then use Blackframe to find 100% image in cropped video.

    I used your image as a reference (186X130) and overlayed it on a videofrom frame 100 to 200 at location 10:10:
    Image
    [Attachment 61071 - Click to enlarge]


    Then I used the logo (change for your purposes)
    Image
    [Attachment 61072 - Click to enlarge]


    Use FFmpeg to search for 100 % for same image in the cropped area of the video where the logo resides. In my case it was 185x130 and I placed it at 10:10 of the video.

    Then use ffmpeg:
    Code:
    ffmpeg -i C:\Users\Bud\Desktop\854_480_test_Overlay.mp4 -loop 1 -i C:\Users\Bud\Desktop\MSNBC.jpg -an -filter_complex crop=186:130:10:10,"blend=difference:shortest=1,blackframe=100:60" -f null - 2> text.txt
    You can use 95-99 if 100 does not show anything becausre of the methods to create the image.

    The Text.txt file will have the usual ffm peg junk and then the lines with 100 % match (Frames 100 -200)
    Metadata:
    encoder : Lavc58.93.100 wrapped_avframe
    [Parsed_blackframe_2 @ 0747fec0] frame:100 pblack:100 pts:3333330 t:3.333330 type:P last_keyframe:0
    [Parsed_blackframe_2 @ 0747fec0] frame:101 pblack:100 pts:3366663 t:3.366663 type:B last_keyframe:0
    [Parsed_blackframe_2 @ 0747fec0] frame:102 pblack:100 pts:3399997 t:3.399997 type:B last_keyframe:0
    ~
    ~
    [Parsed_blackframe_2 @ 0747fec0] frame:198 pblack:100 pts:6599993 t:6.599993 type:P last_keyframe:0
    [Parsed_blackframe_2 @ 0747fec0] frame:199 pblack:100 pts:6633327 t:6.633327 type:B last_keyframe:0
    [Parsed_blackframe_2 @ 0747fec0] frame:200 pblack:100 pts:6666660 t:6.666660 type:B last_keyframe:0
    frame= 603 fps=0.0 q=-0.0 Lsize=N/A time=00:00:20.09 bitrate=N/A speed=47.7x
    video:240kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    Quote Quote  
  6. Member
    Join Date
    Oct 2021
    Location
    At Doom9
    Search PM
    [QUOTE=BosseB;2633000]
    Originally Posted by october262 View Post
    What I need is the starting and ending time of all occurrences where the specific logo is on screen.
    Not exactly what you need, but something similar: https://forum.doom9.org/showthread.php?t=176860
    You would need to mod stuff from there to your specific task.
    Quote Quote  
  7. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    [QUOTE=VoodooFX;2635277]
    Originally Posted by BosseB View Post
    Originally Posted by october262 View Post
    What I need is the starting and ending time of all occurrences where the specific logo is on screen.
    Not exactly what you need, but something similar: https://forum.doom9.org/showthread.php?t=176860
    You would need to mod stuff from there to your specific task.
    I decided it is too big an undertaking since the logo is actually not even a 100% indicator of valid video...
    So I have dropped the idea altogether.
    Quote Quote  
  8. If you are talking about a rolling news channel it will operate off an .m3u8 (poss .mpd if its dash) and the commercial breaks can be commented out by editing the m3u8 in notepad or NPP.
    Quote Quote  
  9. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    Originally Posted by codehound View Post
    If you are talking about a rolling news channel it will operate off an .m3u8 (poss .mpd if its dash) and the commercial breaks can be commented out by editing the m3u8 in notepad or NPP.
    I do not understand...
    How can one edit videos in Notepad (on Windows I presume)?
    These files are on Linux and they are about 200 MB in size each (in mp4 format).
    I download them using ffmpeg on the m3u8 stream.

    But editing videos using a text editor like Notepad or Notepad++ .................. ???????
    Quote Quote  
  10. He's suggesting you edit the playlist file before downloading the video -- so ads aren't included in your downloaded video.
    Quote Quote  
  11. Member
    Join Date
    Feb 2021
    Location
    Sweden
    Search Comp PM
    Originally Posted by jagabo View Post
    He's suggesting you edit the playlist file before downloading the video -- so ads aren't included in your downloaded video.
    What playlist file?
    The videos are downloaded using ffmpeg and previously using youtube-dl to mp4 files in a directory which I then play using Kodi while navigating "Files".
    The download uses the URL to the stream, originally a youtube URL but now an m32u8.
    I have no idea what you mean by "playlist file"...
    Quote Quote  
  12. m3u8 files are playlists. They are text files with a list of all the segments that comprise the video.

    https://en.wikipedia.org/wiki/M3U#M3U8

    ffmpeg (or other downloader) reads the m3u8 file then downloads and concatenates all the listed segments.
    Quote Quote