Output Container containes blank frames. #1760
Unanswered
Nagur-Basha1
asked this question in
1. Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am new to PyAV and trying to process an input container (highway.mp4, 15.1MB). I have attached the codec information extracted from VLC as an image.
My goal is to extract packets from the input and directly mux them into an output container (test_output.mp4) with a custom configuration (codec, FPS, height, width, etc.), without using the template argument in add_stream. However, the output video is generated with blank frames while retaining the same size and duration as the input.
I have tried different codecs, such as mp4v, avc1, libx264, libaom-avi, etc., and added various parameters, but the issue persists.
I also tried python versions 3.8 and 3.12, and av versions 10.0.0 and 14.1.0
Additionally, I encountered another issue: the video_stream object is non-serializable.
Environment
Python Version: 3.8.19 and 3.12.7
Ubuntu Version:
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble
PyAV Version: 10.0.0 and 14.1.0 (Installed the pyav with pip)
Code Snippet
import av
input_ = av.open("highway.mp4")
output = av.open("test_output.mp4", "w")
in_stream = input_.streams.video[0]
codec_name = "mpeg4"
out_stream = output.add_stream(codec_name, in_stream.average_rate)
out_stream.width = in_stream.codec_context.width
out_stream.height = in_stream.codec_context.height
out_stream.pix_fmt = in_stream.codec_context.pix_fmt
for packet in input_.demux(in_stream):
if packet.dts is None:
continue
packet.stream = out_stream
output.mux(packet)
input_.close()
output.close()
Expected Behavior
The output video should contain valid frames, not blank ones.
The video_stream object should be serializable.
Actual Behavior
The output video has blank frames with the same size and duration as the input.
The video_stream object is non-serializable.
Steps Taken to Troubleshoot
Tried multiple codecs (mpeg4, libaom-av1, mp4v, avc1, libx264).
![Screenshot from 2025-02-06 16-07-16](https://private-user-images.githubusercontent.com/160298771/410765062-77564438-76b3-40b6-92d6-3b7cb75d4038.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MzEwMTEsIm5iZiI6MTczOTUzMDcxMSwicGF0aCI6Ii8xNjAyOTg3NzEvNDEwNzY1MDYyLTc3NTY0NDM4LTc2YjMtNDBiNi05MmQ2LTNiN2NiNzVkNDAzOC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNFQxMDU4MzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01NTJjZGRiYzY2NDA2NjhhOTU0Yzk3ZWViMDg4ZmE5ODg2Y2ZmODlhYWNkYmUwMzFhMmUyNmRkNDJlZjVmNTM1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.9L5Ck8Um0kdzrmzSTNsjDNLUEXkolnBHHrtND2uXeHY)
Tested different parameter configurations.
No success in resolving the blank frame issue.
Request for Help
What could be causing the blank frames in the output?
How can I serialize the video_stream object?
Any suggestions or corrections to my approach?
Thanks in advance for your help!
Beta Was this translation helpful? Give feedback.
All reactions