Skip to content

Fix gop analysis of raw stream #248

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

Merged
merged 4 commits into from
May 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/AvTranscoder/file/FormatContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class AvExport FormatContext
* @param position: can be in AV_TIME_BASE units, in frames... depending on the flag value
* @param flag: seeking mode (AVSEEK_FLAG_xxx)
* @return seek status
* @warn seeking on a raw bitstreams (without any container) could produce an error (because of a lack of timing information)
* @see flushDecoder
*/
bool seek(const uint64_t position, const int flag);
Expand Down
20 changes: 16 additions & 4 deletions src/AvTranscoder/properties/FileProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ FileProperties::FileProperties(const FormatContext& formatContext)

void FileProperties::extractStreamProperties(IProgress& progress, const EAnalyseLevel level)
{
clearStreamProperties();

// if the analysis level wiil decode some streams parts, seek at the beginning
if(level > eAnalyseLevelHeader)
if(level > eAnalyseLevelHeader && ! isRawFormat())
const_cast<FormatContext*>(_formatContext)->seek(0, AVSEEK_FLAG_BACKWARD);

// clear properties
clearStreamProperties();

// reload properties
for(size_t streamIndex = 0; streamIndex < _formatContext->getNbStreams(); ++streamIndex)
{
switch(_formatContext->getAVStream(streamIndex).codec->codec_type)
Expand Down Expand Up @@ -120,7 +122,7 @@ void FileProperties::extractStreamProperties(IProgress& progress, const EAnalyse
}

// if the analysis level has decoded some streams parts, return at the beginning
if(level > eAnalyseLevelHeader)
if(level > eAnalyseLevelHeader && ! isRawFormat())
const_cast<FormatContext*>(_formatContext)->seek(0, AVSEEK_FLAG_BACKWARD);
}

Expand All @@ -145,6 +147,16 @@ std::string FileProperties::getFormatLongName() const
return _avFormatContext->iformat->long_name;
}

bool FileProperties::isRawFormat() const
{
if(getNbStreams() != 1)
return false;
// the format name should be the same as the codec name
if(getFormatName() == getStreamProperties().at(0)->getCodecName())
return true;
return false;
}

std::string FileProperties::getFormatMimeType() const
{
#if LIBAVFORMAT_VERSION_MAJOR <= 55
Expand Down
1 change: 1 addition & 0 deletions src/AvTranscoder/properties/FileProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AvExport FileProperties
std::string getFilename() const;
std::string getFormatName() const; ///< A comma separated list of short names for the format, or empty if unknown.
std::string getFormatLongName() const; ///< Descriptive name for the format, meant to be more human-readable than name, or empty if unknown.
bool isRawFormat() const; ///< Is there a container, or a raw bitstreams without access to timing information.
std::string getFormatMimeType() const; ///< Comma-separated list of mime types, or empty if unknown.

size_t getProgramsCount() const;
Expand Down