Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error probing file #14

Open
hugomcruz opened this issue Feb 27, 2021 · 6 comments
Open

Error probing file #14

hugomcruz opened this issue Feb 27, 2021 · 6 comments

Comments

@hugomcruz
Copy link

Error:

(python-v-env) hcruz@Hugos-MacBook-Pro personal-file-processor % python3 demo.py
Traceback (most recent call last):
File "demo.py", line 38, in
video_creation_datetime("/Users/hcruz/Documents/development/python/personal-file-processor/IMG_0119.MOV")
File "demo.py", line 22, in video_creation_datetime
metadata=FFProbe(filepath)
File "/Users/hcruz/Documents/development/python/python-v-env/lib/python3.8/site-packages/ffprobe/ffprobe.py", line 54, in init
self.streams.append(FFStream(data_lines))
File "/Users/hcruz/Documents/development/python/python-v-env/lib/python3.8/site-packages/ffprobe/ffprobe.py", line 114, in init
self.dict.update({key: value for key, value, *_ in [line.strip().split('=')]})
File "/Users/hcruz/Documents/development/python/python-v-env/lib/python3.8/site-packages/ffprobe/ffprobe.py", line 114, in
self.dict.update({key: value for key, value, *_ in [line.strip().split('=')]})
ValueError: not enough values to unpack (expected at least 2, got 1)

FFPROBE OUTPUT
(python-v-env) hcruz@Hugos-MacBook-Pro personal-file-processor % ffprobe IMG_0119.MOV
ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.28)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IMG_0119.MOV':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2021-01-11T09:59:47.000000Z
com.apple.quicktime.location.ISO6709: +10.7792+106.7464+000.499/
com.apple.quicktime.make: Apple
com.apple.quicktime.model: iPhone 6
com.apple.quicktime.software: 12.5
com.apple.quicktime.creationdate: 2021-01-11T16:59:47+0700
Duration: 00:00:02.37, start: 0.000000, bitrate: 11021 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 10880 kb/s, 30.02 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 180
creation_time : 2021-01-11T09:59:47.000000Z
handler_name : Core Media Video
encoder : H.264
Side data:
displaymatrix: rotation of -180.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 90 kb/s (default)
Metadata:
creation_time : 2021-01-11T09:59:47.000000Z
handler_name : Core Media Audio
Stream #0:2(und): Data: none (mebx / 0x7862656D), 23 kb/s (default)
Metadata:
creation_time : 2021-01-11T09:59:47.000000Z
handler_name : Core Media Metadata
Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
Metadata:
creation_time : 2021-01-11T09:59:47.000000Z
handler_name : Core Media Metadata
Unsupported codec with id 0 for input stream 2
Unsupported codec with id 0 for input stream 3

@hugomcruz
Copy link
Author

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

@vocationeers
Copy link

vocationeers commented Mar 1, 2021

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

@hugomcruz
Copy link
Author

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

@vocationeers
Copy link

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)

@altryne
Copy link

altryne commented Mar 21, 2023

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

@hugomcruz
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants