@@ -244,27 +244,6 @@ class AudioReencodeBuffer : public AudioOutput
244
244
return NULL ;
245
245
}
246
246
247
- int GetCount (long long time)
248
- {
249
- QMutexLocker locker (&m_bufferMutex);
250
-
251
- if (m_bufferList.isEmpty ())
252
- return 0 ;
253
-
254
- int count = 0 ;
255
- for (QList<AudioBuffer *>::iterator it = m_bufferList.begin ();
256
- it != m_bufferList.end (); ++it)
257
- {
258
- AudioBuffer *ab = *it;
259
-
260
- if (ab->m_time <= time)
261
- count++;
262
- else
263
- break ;
264
- }
265
- return count;
266
- }
267
-
268
247
long long GetSamples (long long time)
269
248
{
270
249
QMutexLocker locker (&m_bufferMutex);
@@ -1139,17 +1118,26 @@ int Transcode::TranscodeFile(const QString &inputname,
1139
1118
avfw->SetAudioCodec (" libmp3lame" );
1140
1119
1141
1120
if (hlsStreamID == -1 )
1121
+ {
1142
1122
hls = new HTTPLiveStream (inputname, newWidth, newHeight,
1143
1123
cmdBitrate,
1144
1124
cmdAudioBitrate, hlsMaxSegments,
1145
1125
segmentSize, audioOnlyBitrate);
1146
1126
1127
+ hlsStreamID = hls->GetStreamID ();
1128
+ if (!hls || hlsStreamID == -1 )
1129
+ {
1130
+ LOG (VB_GENERAL, LOG_ERR, " Unable to create new stream" );
1131
+ SetPlayerContext (NULL );
1132
+ return REENCODE_ERROR;
1133
+ }
1134
+ }
1135
+
1147
1136
hls->UpdateStatus (kHLSStatusStarting );
1148
1137
hls->UpdateStatusMessage (" Transcoding Starting" );
1149
1138
hls->UpdateSizeInfo (newWidth, newHeight, video_width, video_height);
1150
1139
1151
- if ((hlsStreamID != -1 ) &&
1152
- (!hls->InitForWrite ()))
1140
+ if (!hls->InitForWrite ())
1153
1141
{
1154
1142
LOG (VB_GENERAL, LOG_ERR, " hls->InitForWrite() failed" );
1155
1143
SetPlayerContext (NULL );
@@ -1942,57 +1930,54 @@ int Transcode::TranscodeFile(const QString &inputname,
1942
1930
}
1943
1931
1944
1932
// audio is fully decoded, so we need to reencode it
1945
- if (arb->GetCount (lastWrittenTime))
1933
+ AudioBuffer *ab = NULL ;
1934
+ while ((ab = arb->GetData (lastWrittenTime)) != NULL )
1946
1935
{
1947
- AudioBuffer *ab = NULL ;
1948
- while ((ab = arb-> GetData (lastWrittenTime)) != NULL )
1936
+ unsigned char *buf = ( unsigned char *)ab-> data () ;
1937
+ if (avfMode )
1949
1938
{
1950
- unsigned char *buf = (unsigned char *)ab->data ();
1951
- if (avfMode)
1939
+ if (did_ff != 1 )
1952
1940
{
1953
- if (did_ff != 1 )
1954
- {
1955
- long long tc = ab->m_time - timecodeOffset;
1956
- avfw->WriteAudioFrame (buf, audioFrame, tc);
1941
+ long long tc = ab->m_time - timecodeOffset;
1942
+ avfw->WriteAudioFrame (buf, audioFrame, tc);
1957
1943
1958
- if (avfw2)
1944
+ if (avfw2)
1945
+ {
1946
+ if ((avfw2->GetTimecodeOffset () == -1 ) &&
1947
+ (avfw->GetTimecodeOffset () != -1 ))
1959
1948
{
1960
- if ((avfw2->GetTimecodeOffset () == -1 ) &&
1961
- (avfw->GetTimecodeOffset () != -1 ))
1962
- {
1963
- avfw2->SetTimecodeOffset (
1964
- avfw->GetTimecodeOffset ());
1965
- }
1966
-
1967
- tc = ab->m_time - timecodeOffset;
1968
- avfw2->WriteAudioFrame (buf, audioFrame, tc);
1949
+ avfw2->SetTimecodeOffset (
1950
+ avfw->GetTimecodeOffset ());
1969
1951
}
1970
1952
1971
- ++audioFrame;
1953
+ tc = ab->m_time - timecodeOffset;
1954
+ avfw2->WriteAudioFrame (buf, audioFrame, tc);
1972
1955
}
1956
+
1957
+ ++audioFrame;
1973
1958
}
1974
- else
1959
+ }
1960
+ else
1961
+ {
1962
+ nvr->SetOption (" audioframesize" , ab->size ());
1963
+ nvr->WriteAudio (buf, audioFrame++,
1964
+ ab->m_time - timecodeOffset);
1965
+ if (nvr->IsErrored ())
1975
1966
{
1976
- nvr->SetOption (" audioframesize" , ab->size ());
1977
- nvr->WriteAudio (buf, audioFrame++,
1978
- ab->m_time - timecodeOffset);
1979
- if (nvr->IsErrored ())
1980
- {
1981
- LOG (VB_GENERAL, LOG_ERR,
1982
- " Transcode: Encountered irrecoverable error in "
1983
- " NVR::WriteAudio" );
1984
-
1985
- av_free (newFrame);
1986
- SetPlayerContext (NULL );
1987
- if (frameQueue)
1988
- frameQueue->stop ();
1989
- delete ab;
1990
- return REENCODE_ERROR;
1991
- }
1967
+ LOG (VB_GENERAL, LOG_ERR,
1968
+ " Transcode: Encountered irrecoverable error in "
1969
+ " NVR::WriteAudio" );
1970
+
1971
+ av_free (newFrame);
1972
+ SetPlayerContext (NULL );
1973
+ if (frameQueue)
1974
+ frameQueue->stop ();
1975
+ delete ab;
1976
+ return REENCODE_ERROR;
1992
1977
}
1993
-
1994
- delete ab;
1995
1978
}
1979
+
1980
+ delete ab;
1996
1981
}
1997
1982
1998
1983
if (!avfMode)
0 commit comments