Giter VIP home page Giter VIP logo

Comments (6)

vocationeers avatar vocationeers commented on July 24, 2024 1

If modified like below the code seems to work fine. At least for my file I can confirm that all data is now retrieved as it should

        for line in iter(p.stdout.readline, b''):
                line = line.decode('UTF-8')
    
                if '[SIDE_DATA]' in line:
                    side_data = True
                    print("Found side data")
                    continue
                    #Ignore SIDE DATA
                elif '[/SIDE_DATA]' in line and stream:
                    side_data = False
                    continue
 
                if (side_data):
                    continue
                    #Skip Side data tags 

                if '[STREAM]' in line:
                    stream = True
                    data_lines = []
                elif '[/STREAM]' in line and stream:
                    stream = False
                    # noinspection PyUnboundLocalVariable
                    self.streams.append(FFStream(data_lines))
                elif stream:
                    data_lines.append(line)

from ffprobe-python.

hugomcruz avatar hugomcruz commented on July 24, 2024

My file has a SIDE_DATA tag which is not expected in the code.

I update the code and added some logic to ignore the SIDE_DATA for now.

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

        stream = False
        self.streams = []
        self.video = []
        self.audio = []
        self.subtitle = []
        self.attachment = []
        
        side_data = False

        for line in iter(p.stdout.readline, b''):
            line = line.decode('UTF-8')
            
            if(side_data):
                continue
                #Skip Side data tags
                
            
            if '[SIDE_DATA]' in line:
                side_data = True
                print("Found side data")
                continue
                #Ignore SIDE DATA
            elif '[/SIDE_DATA]' in line and stream:
                side_data = False
                continue
            

            if '[STREAM]' in line:
                stream = True
                data_lines = []
            elif '[/STREAM]' in line and stream:
                stream = False
                # noinspection PyUnboundLocalVariable
                self.streams.append(FFStream(data_lines))
            elif stream:
                data_lines.append(line)

        self.metadata = {}
        is_metadata = False
        stream_metadata_met = False

from ffprobe-python.

vocationeers avatar vocationeers commented on July 24, 2024

Just tried your code as I have the same issue in a project of mine and it did not work for me. It prints "Found side data" and retrieves media information, but I do not get any data for the video/audio streams anymore.
For your file the stream data is before the SideData, in mine it comes after the side data.

This is what my file data looks like:
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=11279/663750
codec_tag_string=avc1
codec_tag=0x31637661
width=1920
height=1080
coded_width=1920
coded_height=1088
closed_captions=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=331875/11279
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=360928
duration=4.010311
bit_rate=15268606
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=118
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:rotate=90
TAG:creation_time=2021-03-01T13:12:13.000000Z
TAG:language=eng
TAG:handler_name=VideoHandle
[SIDE_DATA]
side_data_type=Display Matrix
displaymatrix=
00000000: 0 65536 0
00000001: -65536 0 0
00000002: 0 0 1073741824
rotation=-90
[/SIDE_DATA]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/48000
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/48000
start_pts=0
start_time=0.000000
duration_ts=192512
duration=4.010667
bit_rate=193787
max_bit_rate=192000
bits_per_raw_sample=N/A
nb_frames=188
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2021-03-01T13:12:13.000000Z
TAG:language=eng
TAG:handler_name=SoundHandle

from ffprobe-python.

hugomcruz avatar hugomcruz commented on July 24, 2024

You are right. My logic is wrong. All the data after the SIDE_DATA will be ignored. In my case it worked as I was only using data that was "before" the SIDE_DATA.

I did not have time to test, or do a proper diff. Give it a try and give me some feedback. Later I will try it on my side.

I am not involved in the development of this code, but I will propose a merge if this works fine.

Thanks for the feedback.


Can you try to move this piece of code below:

if(side_data):
continue
#Skip Side data tags


for line in iter(p.stdout.readline, b''):
line = line.decode('UTF-8')

       # Piece of code was here
        
        if '[SIDE_DATA]' in line:
            side_data = True
            print("Found side data")
            continue
            #Ignore SIDE DATA
        elif '[/SIDE_DATA]' in line and stream:
            side_data = False
            continue

    #New place for the piece of code
    if(side_data):
            continue
            #Skip Side data tags

    ### Rest of the code continues

from ffprobe-python.

altryne avatar altryne commented on July 24, 2024

I'm uploading an iphone created MOV file and getting this exact issue with ffprobe-python, but nothing seems wrong on command line?

from ffprobe-python.

hugomcruz avatar hugomcruz commented on July 24, 2024

https://github.com/hugomcruz/ffprobe-python

I did a fork where I fixed some of those issues about 2 years ago when I created a programme to process my iphone videos.

from ffprobe-python.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.